Motore guidato dai dati con due scene di prova (Piazza e salita alla Fortezza), percorsi su area concava, clic intelligente e pressione lunga, test della soluzione completa in node e nel browser con Playwright. Nel documento la leggenda del nonno. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
715 B
JavaScript
18 lines
715 B
JavaScript
// Fa avanzare il gioco come farebbe un giocatore impaziente: tempo che scorre e battute saltate.
|
|
export function settle(game, { maxSteps = 20000 } = {}) {
|
|
const said = [];
|
|
for (let i = 0; i < maxSteps; i++) {
|
|
if (game.speech) {
|
|
said.push(game.speech);
|
|
game.skip();
|
|
}
|
|
if (!game.busy && !game.walking && !game.queue.length && !game.task) return said;
|
|
game.update(0.05);
|
|
}
|
|
throw new Error('Il gioco non si ferma: ' + JSON.stringify(game.snapshot()));
|
|
}
|
|
|
|
export function memoryStorage() {
|
|
return { data: {}, getItem(k) { return this.data[k] ?? null; }, setItem(k, v) { this.data[k] = String(v); }, removeItem(k) { delete this.data[k]; } };
|
|
}
|