Skip to content

Instantly share code, notes, and snippets.

@epidemian
Last active May 2, 2023 23:27
Show Gist options
  • Save epidemian/db49af82fb196fefaf10c08dffc594d7 to your computer and use it in GitHub Desktop.
Save epidemian/db49af82fb196fefaf10c08dffc594d7 to your computer and use it in GitHub Desktop.
Snake gameplay gif recorder

The gameplay gif you can see on https://github.com/epidemian/snake is a lie. It was not played by a person, but recorded move-by-move.

The code on record-moves.js was used to first record "player" moves one by one and then the code on replay-moves.js was used to replay them on the game.

The readme-moves.json file contains the moves used on the README.

To record the gif, byzanz-record was used, which is the only tool I found that could generate good quality gifs with good-enough frame rate.

[[],[],[],[],[{"x":0,"y":-1}],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[{"x":-1,"y":0}],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0},{"x":1,"y":0}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[{"x":1,"y":0}],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0}],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0},{"x":0,"y":1}],[],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":1,"y":0}],[],[],[],[{"x":0,"y":1}],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[{"x":1,"y":0}],[],[],[{"x":0,"y":1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[],[],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1},{"x":1,"y":0}],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":-1}],[{"x":-1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[{"x":0,"y":1}],[],[],[{"x":1,"y":0}],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
var moves = [[]]
// Override tickTime so game never advances on its own.
window.tickTime = () => Number.MAX_VALUE
// Advance world with space bar.
document.addEventListener('keydown', (e) => {
if (e.keyCode === 32) {
updateWorld()
drawWorld()
moves.push([])
}
})
// Override changeDirection() to record moves.
var originalChangeDirection = window.changeDirection
window.changeDirection = (dir) => {
moves[moves.length - 1].push(dir)
originalChangeDirection(dir)
}
// Override Math.random() so it always returns same pseudo-random values.
var LCG = seed => () => (seed = Math.imul(741103597, seed) >>> 0 ) / 2 ** 32
Math.random = LCG(0xF0000)
// Restart game to start recording.
startGame()
drawWorld()
// After recording for a while, print moves with:
// console.log(JSON.stringify(moves))
var moves = []
// Override Math.random() so it always returns same pseudo-random values.
var LCG = seed => () => (seed = Math.imul(741103597, seed) >>> 0 ) / 2 ** 32
Math.random = LCG(0xF0000)
var originalUpdateWorld = window.updateWorld
window.updateWorld = () => {
var tickMoves = moves.shift() || []
for (var move of tickMoves) {
changeDirection(move)
}
originalUpdateWorld()
}
startGame()
drawWorld()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment