|
| 1 | +# A Nested TicTacToe game using Java Swing. |
| 2 | +*** |
| 3 | +## The user is initially displayed with an option to choose your opponent, either against the computer or a friend. |
| 4 | + |
| 5 | +![Capture_NestedTicTacToe_MainMenu]() |
| 6 | + |
| 7 | +--- |
| 8 | +Play alternates between the user(player1) who initially is X and the player2/CPU which is O. |
| 9 | + |
| 10 | +Image displaying a game between the user and CPU: |
| 11 | + |
| 12 | +![Capture_NestedTicTacToe_vsComputer]() |
| 13 | + |
| 14 | +--- |
| 15 | +When a player plays his move by clicking on a tile, a new Window is opened which starts a new game(A Nested Game), the winner of the nested game gets his mark set on the main board. |
| 16 | + |
| 17 | +![Capture_NestedTicTacToe_vsComputerNested]() |
| 18 | + |
| 19 | +--- |
| 20 | +This continues for all the tiles, until there's a winner on the main board. |
| 21 | + |
| 22 | +![Capture_NestedTicTacToe_vsComputerNested_Winner]() |
| 23 | + |
| 24 | +The score of the main game as well as the nested games gets recorded accordingly. |
| 25 | + |
| 26 | +![Capture_NestedTicTacToe_vsComputerNested_2]() |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +After the game(in the main board) ends a dialog box is displayed announcing the result and the score. The user is given an option for a re-match(play again). |
| 31 | + |
| 32 | +![Capture_TicTacToe_vsComputer_Winner]() |
| 33 | + |
| 34 | +--- |
| 35 | +If the user selects 'Yes' on the Play again option, a new game starts, but now the user (player 1) is O and the cpu/player2 is X. |
| 36 | +The mark ('X' and 'O') alternates every new game. X always plays first. |
| 37 | + |
| 38 | +*** |
| 39 | +When the option of playing against the computer is selected, the program automatically plays its turn. |
| 40 | +Initially the user is X and CPU is O. |
| 41 | + |
| 42 | +The computer's strategy is first to complete 3 O's in a row, or if that is not possible, to block a row of 3 X's, or if that is not possible, to move randomly. |
| 43 | + |
| 44 | +*** |
| 45 | +After the end of a game, if the user selects 'No' on the Play again option, the frame resets to the main menu of options and all the scores are reseted. |
| 46 | + |
| 47 | +Image displaying a new game between Player 1 & Player 2 (vs Friend): |
| 48 | + |
| 49 | +![Capture_NestedTicTacToe_vsFriend]() |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +The score between the two players is also recorded and displayed at the bottom, it updates after every game. |
| 54 | + |
| 55 | +Top panel displays labels which indicate the turn of each player and their corresponding mark (either X or O). |
| 56 | + |
| 57 | +*** |
| 58 | +Note: |
| 59 | +The code for NestedTicTacToe can be more compact if similar methods are joined and values distinguished with flags. |
| 60 | +The TicTacToe code is from https://github.com/04xRaynal/TicTacToe_JavaSwing.git |
| 61 | +and only the nested components are added on top of it. |
| 62 | + |
0 commit comments