Add script for testing move suggestions

This commit is contained in:
tali 2023-03-04 22:05:05 -05:00
parent 3e52b6fb71
commit 58ae5a67f3
3 changed files with 36 additions and 0 deletions

33
fumen-utils/best.js Normal file
View File

@ -0,0 +1,33 @@
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));

1
fumen-utils/example-url Normal file
View File

@ -0,0 +1 @@
v115@lgA8CeA8OeA8CeC8BeC8BeC8AeE8AeC8AeN8AeA8Je?AgWZAFLDmClcJSAVzbSAVG88AYP88A5sjxCvAAAA

2
fumen-utils/rebuild.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
exec cargo build --manifest-path ../fish/Cargo.toml --release --features=fish-cli