Player Code:
  • You are X (player 0).
  • Your move() function will be passed a data structure:
    { player_number:0, board:[-1,-1,-1,-1,-1,-1,-1,-1,-1] }
  • The 'board' array represents each square on the board, from top left [0] to bottom right [8]. The value is either a -1 if the space is empty, or the player number if it's taken (0 or 1).
  • Your player is a constructor that returns an object with a move() method. It must return the square number of your move [0-8].
  • Tic-Tac-Toe is a solvable game. If you code your player well, you should never lose!