Skip to content

Commit 9ec48e7

Browse files
authored
Create README.md
1 parent 2d6e0a3 commit 9ec48e7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

AI TicTacToe/src/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# TicTacToe Game
2+
3+
A simple implementation of the Tic Tac Toe game in Python.
4+
5+
## Rules of the Game
6+
Tic Tac Toe is a classic game played on a 3x3 grid. Two players take turns placing their markers (X or O) on the board, aiming to get three of their marks in a row (horizontally, vertically, or diagonally) before the opponent does. If all the positions on the board are filled and no player has won, the game ends in a tie.
7+
8+
## How to Play
9+
1. Run the `play_tic_tac_toe()` function in a Python environment.
10+
2. Player 1 will be prompted to choose either X or O.
11+
3. The players will take turns entering their positions on the board, ranging from 1 to 9. The board is displayed after each move.
12+
4. The game continues until one player wins or the board is full.
13+
5. After the game ends, players are given the option to play again.
14+
15+
## Functions
16+
- `display_board(board)`: Prints the current state of the Tic Tac Toe board.
17+
- `player_input()`: Prompts the first player to choose X or O and assigns the markers to player 1 and player 2 accordingly.
18+
- `place_marker(board, marker, position)`: Places the given marker (X or O) at the specified position on the board.
19+
- `win_check(board, mark)`: Checks if the given mark (X or O) has won the game.
20+
- `choose_first()`: Randomly selects which player goes first.
21+
- `space_check(board, position)`: Checks if a particular position on the board is empty.
22+
- `full_board_check(board)`: Checks if the board is full.
23+
- `player_choice(board)`: Asks the current player to choose a position to place their marker and returns the chosen position.
24+
- `replay()`: Asks the players if they want to play again.
25+
26+
## Usage
27+
1. Clone the repository or download the `tic_tac_toe.py` file.
28+
2. Open the file in a Python environment (e.g., IDLE, Jupyter Notebook, or any text editor with Python support).
29+
3. Run the script to start the game.
30+
4. Follow the prompts and enter your choices accordingly.
31+
5. Enjoy playing Tic Tac Toe!

0 commit comments

Comments
 (0)