create fumen-replay script for use with tidepool data
This commit is contained in:
parent
2a083b1cf5
commit
fdae258965
|
@ -0,0 +1,37 @@
|
|||
import { argv } from 'node:process'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { encoder as fumenEncoder } from 'tetris-fumen'
|
||||
import { Simul } from './lib/sim.js'
|
||||
|
||||
export async function main(args) {
|
||||
if (args.length < 1) {
|
||||
throw new Error('no input file specified');
|
||||
}
|
||||
|
||||
let buf = await readFile(args[0]);
|
||||
let data = JSON.parse(buf.toString('utf-8'));
|
||||
if (!data.moves) {
|
||||
throw new Error('cannot generate replay without moves; pass --list-moves flag to tidepool');
|
||||
}
|
||||
|
||||
let sim = new Simul(data.seed, data.config);
|
||||
let pages = [];
|
||||
for (let move of data.moves) {
|
||||
let mino = {
|
||||
type: move.type,
|
||||
rotation: {
|
||||
'north': 'spawn',
|
||||
'east': 'right',
|
||||
'south': 'reverse',
|
||||
'west': 'left',
|
||||
}[move.orientation],
|
||||
x: move.x,
|
||||
y: move.y,
|
||||
};
|
||||
pages.push(sim.play(mino));
|
||||
}
|
||||
|
||||
console.log(fumenEncoder.encode(pages));
|
||||
}
|
||||
|
||||
main(argv.slice(2));
|
|
@ -131,7 +131,7 @@ function getGarbageLevel(matrix) {
|
|||
return level;
|
||||
}
|
||||
|
||||
if (true) {
|
||||
if (false) {
|
||||
// see `tidepool::sim::test::test_deterministic()`
|
||||
let sim = new Simul("0x1234567800ABCDEF", {
|
||||
goal: 100,
|
||||
|
|
Loading…
Reference in New Issue