Guest User

Untitled

a guest
Apr 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. /* Stolen from TicTacToe tutorial: */
  2. const TicTacToe = Game({
  3. setup: () => ({ cells: Array(9).fill(null) }),
  4. flow: { endGameIf: (G, ctx) => false },
  5. moves: {
  6. clickCell(G, ctx, id) {
  7. const cells = [...G.cells];
  8. if (cells[id] === null) { cells[id] = ctx.currentPlayer; }
  9. return { ...G, cells };
  10. },
  11. },
  12. });
  13. /* end tutorial stuff */
  14.  
  15. for (let cell of [0, 1, 2, 3, 4, 5, 6, 7]) TicTacToe.moves.clickCell(cell);
  16.  
  17. const clicks = [];
  18. for (let i = 0; i < 9; i++) clicks.push([i]);
  19. console.log(TicTacToe.getLegalMoves({ clickCell: clicks })); // Would be { clickCell: [8] }
Add Comment
Please, Sign In to add comment