super(id);
this.moves = [];
this.board = Array(9).fill("");
+ this.next_player = "X";
}
/* Returns Boolean indicating whether move was legal and added. */
if (this.board[square])
return false;
- this.board[square] = 'X';
+ this.board[square] = this.next_player;
this.moves.push(square);
+ if (this.next_player === "X")
+ this.next_player = "O";
+ else
+ this.next_player = "X";
+
return true;
}