A simple command-line version of the Tic Tac Toe game that allows users to play against each other or against an AI.
- About the Project
- Technical Implementation Highlights
- Getting Started
- Usage
- License
- Acknowledgements
-
The game is played on a 3x3 grid.
-
Option to choose whether the human player or AI starts the game first.
-
Players take turns marking a cell with their symbol ('X' or 'O').
-
To input their symbol, players use the numpad (1 to 9) corresponding to the grid cells as follows:
1 | 2 | 3 --------- 4 | 5 | 6 --------- 7 | 8 | 9
For example, to place their symbol in the top-left cell, a player would input '1', and for the bottom-right cell, they would input '9'.
-
The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
-
If all cells are filled and no player has won, the game ends in a draw.
-
Demonstrates a modular code structure that enhances readability, maintainability, and extensibility of the game.
-
Showcases robust error handling mechanisms to gracefully handle invalid inputs and unexpected scenarios, enhancing user experience and software reliability.
-
Scalability: Extendable codebase for future feature additions or modifications.
To get started with this project, you have two options:
- Using PyPI: Install the package directly from the Python Package Index (PyPI) using pip. PyPI always provides stable and tested versions.
- Local Build: Build and install the package locally. Local builds may contain the newest features but could also be unstable and potentially buggy.
Choose the method that best suits your needs and follow the respective instructions below.
When using PyPI, pip automatically handles dependencies, ensuring that all required packages are installed.
For local builds, install dependencies with:
pip install -r requirements.txt
pip install tictacai
- Clone the repo
git clone https://github.com/vivekkdagar/TicTacAI/tree/main
- Go to the project directory
cd tictacai
- Build the package
python3 -m build
- Install the package
cd dist
pip install *gz
It provides the following command-line interface:
1. Play against Human
tictacai human
This command starts a game where two humans can play against each other.
2. Play against AI
tictacai ai
This command starts a game where a human can play against the AI.
- Display Scores
tictacai scores
This command displays statistics about the game, such as total matches played, player wins, draws, etc.
One thing to note is scores are stored in a JSON file in Document/TicTacAI so if it is deleted, scores are reset to 0.
Distributed under the MIT License. See LICENSE for more information.