A visually enhanced game of Tic Tac Toe with a twist and a formidable AI opponent! This isn't your standard 3-in-a-row; the "infinite" rule adds a layer of complexity where your oldest piece disappears after you've placed three. Can you outsmart the AI?
- Classic Tic Tac Toe Goal: Be the first to get three of your marks (X or O) in a row, column, or diagonal.
- Infinite Rule: Once a player has 3 marks on the board, placing their 4th mark will cause their oldest existing mark to be removed. This keeps the board dynamic!
- Challenging AI: Play against a bot using the Minimax algorithm (with adjustable search depth) to provide a tough opponent.
- Visual Enhancements: Custom color scheme and clean UI built with Tkinter.
- Removal Highlighting: The piece that is next in line to be removed (if you place another piece) is highlighted with a distinct background color.
- Score Tracking: Keeps track of wins between the Human and the Bot across rounds.
- Auto-Restart: The game automatically restarts shortly after a win, loss, or draw.
- Python 3
- Tkinter (Python's standard GUI library - usually built-in)
- Objective: Get 3 of your marks (you'll be assigned X or O) in a line.
- Gameplay: Click on an empty square to place your mark.
- The Infinite Rule: Pay attention! After you have 3 marks down, your next move will place your 4th mark AND remove your 1st mark. The highlighted piece (with the darker background) shows which one will disappear next.
- Turns: The game alternates turns between you and the AI bot. The status bar indicates whose turn it is.
There are three ways to play:
1. Just open the website: You can play the game live in your browser by clicking here: Click Here
2. Running from Source:
- Ensure you have Python 3 installed.
- Clone this repository or download the source code.
- Rename the main script file if you chose a different name (e.g.,
infinite_tictactoe_ai.py). - Make sure the
icon.icofile is in the same directory as the script. - Run the script from your terminal:
bash python infinite_tictactoe_ai.py - (Tkinter is typically included with standard Python installations. No external libraries are needed.)
3. Using the Executable:
- Download the pre-compiled executable file (
infinite_tictactoe_ai.exeor similar) from thedist/directory (if provided in the release/repository). - Ensure the
icon.icofile is included alongside the.exein thedist/directory if it wasn't bundled correctly (the provided PyInstaller command should bundle it). - Double-click the
.exefile to run the game directly on Windows.
Think you've mastered Tic Tac Toe? Think again! The AI opponent in this version uses a strong Minimax search algorithm, making it incredibly difficult to defeat, especially with the added complexity of the infinite rule.
- Can you find a winning strategy?
- Can you even force a draw consistently?
Test your strategic thinking and see if you can beat the bot!
If you want to create the .exe file yourself:
- Install PyInstaller:
pip install pyinstaller - Make sure
icon.icois in the same directory as your.pyscript. - Run the following command in your terminal from that directory (replace
infinite_tictactoe_ai.pyif you used a different name):pyinstaller --onefile --add-data "icon.ico;." --windowed --icon=icon.ico infinite_tictactoe_ai.py - The executable will be created in the
distsub-directory.
Contributions, bug reports, and feature suggestions are welcome! Please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details (optional - consider adding a LICENSE file).
