An open API service indexing awesome lists of open source software.

https://github.com/f1scher7/tic_tac_toe-ai

This is a Python implementation of Tic Tac Toe game with an AI opponent. The game allows players to play against each other or against an AI with different levels of difficulty.
https://github.com/f1scher7/tic_tac_toe-ai

pygame-games python3

Last synced: 3 months ago
JSON representation

This is a Python implementation of Tic Tac Toe game with an AI opponent. The game allows players to play against each other or against an AI with different levels of difficulty.

Awesome Lists containing this project

README

        

# Tic Tac Toe AI

This is a Python implementation of Tic Tac Toe game with an AI opponent. The game allows players to play against each other or against an AI with different levels of difficulty.

## Features

- **Player vs Player Mode:** Players can play against each other on the same device.
- **Player vs AI Mode:** Players can play against an AI opponent.
- **AI Difficulty Levels:** The AI opponent has different difficulty levels:
- Level 0: Random moves.
- Level 1: AI uses the minimax algorithm to make intelligent moves.
- **Visual Feedback:** Visual indication of the game progress, including marking winning lines and indicating whose turn it is.
- **Interactive Interface:** Players can interact with the game using mouse clicks or keyboard inputs.


## How to Play

- **Player vs Player Mode:**
- Two players take turns clicking on the empty squares to mark their moves.
- The game ends when one player wins or there is a tie.
- **Player vs AI Mode:**
- The player makes moves by clicking on the empty squares.
- If playing against the AI, choose the AI difficulty level by pressing keys:
- Press `0` for random AI.
- Press `1` for AI using the minimax algorithm.
- The AI makes its move after the player's move.
- The game ends when either the player or the AI wins, or there is a tie.
- **Game Controls:**
- Press `g` to switch between Player vs Player and Player vs AI modes.
- Press `r` to reset the game board.

## Example operation

![Zrzut ekranu 2024-04-08 193603](https://github.com/f1scher7/tic_tac_toe-AI/assets/115926717/d250c8b8-1764-4bd3-962f-95bff24f525a)

## Author

- Maks Szyło - [email protected].

## License

This project is licensed under the [MIT License](LICENSE).