Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8bbe519

Browse files
Merge pull request avinashkranjan#1569 from ayush-09/master
AI_Tic_Tac_toe_Game
2 parents d5fa0f5 + 9ec48e7 commit 8bbe519

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)

AltStyle によって変換されたページ (->オリジナル) /