34 lines
908 B
JavaScript
34 lines
908 B
JavaScript
|
const fumen = require('tetris-fumen');
|
||
|
const { argv } = require('node:process');
|
||
|
const { fumenPageToInputState, fumenPagePlayMove, runFishCli } = require('./src/utils');
|
||
|
|
||
|
const CONFIG = [
|
||
|
// '--limit-nodes', '1000',
|
||
|
// '--limit-steps', '5',
|
||
|
// '--limit-time', '1000',
|
||
|
];
|
||
|
|
||
|
async function main() {
|
||
|
if (argv.length != 3) {
|
||
|
throw new Error('usage: node list <url>');
|
||
|
}
|
||
|
|
||
|
let url = argv[2];
|
||
|
let pages = fumen.decoder.decode(url);
|
||
|
if (pages.length !== 1) {
|
||
|
throw new Error('expected exactly one page');
|
||
|
}
|
||
|
|
||
|
let inputState = fumenPageToInputState(pages[0]);
|
||
|
let output = await runFishCli(['best', ...CONFIG], inputState);
|
||
|
for (let move of output.moves) {
|
||
|
pages.push(fumenPagePlayMove(pages[0], move, { lock: true }));
|
||
|
}
|
||
|
|
||
|
pages.push({ comment: '' });
|
||
|
|
||
|
console.log(fumen.encoder.encode(pages));
|
||
|
}
|
||
|
|
||
|
main().catch(e => console.error(e));
|