Tic Tac Toe is a classic two-player game where players take turns marking a space in a 3x3 grid with their respective symbols (X or O). This implementation allows players to play against each other or against an AI bot with adjustable difficulty levels. The bot uses strategic algorithms to provide a challenging experience.
The project is organized into the following key components:
-
GameLogic.swift: Contains the core game logic, including the rules of Tic Tac Toe, AI decision-making, and game state management. This file handles player moves, checks for winners, and implements the AI's behavior based on the selected difficulty level.
-
ContentView.swift: The main user interface of the application, built using SwiftUI. This file defines the layout of the game board, handles user interactions, and displays the current game state, including scores and messages.
-
Persistence.swift: Manages data persistence using Core Data, allowing for future enhancements such as saving game history or player statistics.
-
Assets.xcassets: Contains image assets and color sets used in the application, ensuring a visually appealing design.
-
Supporting Files: Includes project configuration files, such as the Info.plist and project settings, which are necessary for the app's functionality.
This project is built using the following technologies:
-
Swift: The primary programming language used for developing the application, providing a modern and safe coding experience.
-
SwiftUI: A user interface toolkit that allows for declarative UI design, making it easy to create responsive and dynamic interfaces.
-
Core Data: A framework used for data management and persistence, allowing for the storage of game data and player statistics.
-
Xcode: The integrated development environment (IDE) used for building and testing the application, providing tools for debugging and performance analysis.
- Two Game Modes: Play against a friend or an AI bot.
- Adjustable AI Difficulty: Choose between Easy, Medium, and Hard difficulty levels for the AI.
- Smart AI: The AI prioritizes taking the center, blocking winning moves, and taking corners.
- Score Tracking: Keep track of scores for both players.
- Responsive Design: The game is designed to be user-friendly and visually appealing.
To run the Tic Tac Toe game locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/kstbyev/tic-tac-toe.git
-
Open the Project: Open the project in Xcode.
-
Run the App: Select a simulator or a connected device and click the "Run" button in Xcode.
- Start the app, and you will see the Tic Tac Toe grid.
- Choose whether to play against a friend or the AI by toggling the option.
- If playing against the AI, select the desired difficulty level.
- Take turns placing your symbols in the grid.
- The game will announce the winner or declare a draw when applicable.
- You can reset the game at any time using the "Reset Game" button.
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Create a pull request describing your changes.

