User prompt
on computer's move first check to see if 'O' could win using an available space before preventing an 'X' win
User prompt
your new code incorrectly leaves X's in every space
User prompt
on computer's move check to see if 'X' could win on its next move and block it, else continue with using next available space
User prompt
in the computerMove function, check the remaining unoccupied spaces to see if player 'X' could win and choose that space instead of the first available unoccupied space, thus preventing an 'X' win
User prompt
when it is the computers turn, first check to see if there is a possible win for 'X' - if so block it
User prompt
make the computer move more intelligent by checking for a potential 3 X's in a line and blocking it with an 'O'
Code edit (1 edits merged)
Please save this source code
User prompt
when there is a draw, you are incorrectly displaying "Draw Wins!" instead is should be just "Draw!"
User prompt
you should be displaying game over play again after 'O' wins
User prompt
after the user (human) plays the 'X' move, you are correctly making a computer generated 'O' move but then play should toggle back to the user to play another 'X' move
User prompt
the user should only play the 'X' moves the computer should play the 'O' moves
User prompt
get the computer to play to 'O' moves
User prompt
show current player: X at start of game
User prompt
remove the restart button
User prompt
If a Draw is reached you should offer to lay again, like you do when there is a win
User prompt
The 'X' player is correctly shown on the first move, but then the 'O' player should play next, instead, this code is always showing an 'X'
User prompt
Now it is incorrectly displaying Draw! after one move. Draw! should only be displayed if neither player has won and there are no more places to move
User prompt
Now it is incorrectly displaying Draw Wins! after one move
User prompt
do not display Draw! after the first 'X' has played
User prompt
you only allow 'X' to play never 'O'
User prompt
you are also wrongly displaying Draw! at the start of the game
===================================================================
--- original.js
+++ change.js
@@ -122,28 +122,8 @@
});
}
};
});
-// Class for the restart button
-var RestartButton = Container.expand(function () {
- var self = Container.call(this);
- self.attachAsset('restartButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.down = function (x, y, obj) {
- // Reset the board
- board.resetBoard();
- // Reset the pieces
- for (var i = 0; i < 3; i++) {
- for (var j = 0; j < 3; j++) {
- board.grid[i][j].setPlayer('');
- }
- }
- // Update the game status
- updateStatus();
- };
-});
/****
* Initialize Game
****/
@@ -185,10 +165,5 @@
board.makeMove(gridX, gridY);
if (board.currentPlayer !== 'X') {
updateStatus();
}
-};
-// Initialize the restart button
-var restartButton = new RestartButton();
-restartButton.x = 2048 / 2;
-restartButton.y = 2732 - 200;
-game.addChild(restartButton);
\ No newline at end of file
+};
\ No newline at end of file
A large letter 'O' as in tic tac toe, coloured blue. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A large letter 'X' as in tic tac toe coloured red, in a similar style to the O-player image. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. No surrounding circle nor square.