Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Stolen from TicTacToe tutorial: */
- const TicTacToe = Game({
- setup: () => ({ cells: Array(9).fill(null) }),
- flow: { endGameIf: (G, ctx) => false },
- moves: {
- clickCell(G, ctx, id) {
- const cells = [...G.cells];
- if (cells[id] === null) { cells[id] = ctx.currentPlayer; }
- return { ...G, cells };
- },
- },
- });
- /* end tutorial stuff */
- for (let cell of [0, 1, 2, 3, 4, 5, 6, 7]) TicTacToe.moves.clickCell(cell);
- const clicks = [];
- for (let i = 0; i < 9; i++) clicks.push([i]);
- console.log(TicTacToe.getLegalMoves({ clickCell: clicks })); // Would be { clickCell: [8] }
Add Comment
Please, Sign In to add comment