Tic-Tac-Toe game built with React + TypeScript + Vite.
Read project walkthrough on: Substack
This is a fully-functional Tic Tac Toe game with the following features:
- Multiple Game Modes: Play against a friend or challenge the AI
- Difficulty Levels: Choose from Easy, Medium, or Hard AI opponents
The AI in Hard mode uses the Minimax algorithm with Alpha-Beta pruning to make optimal moves, making it almost unbeatable!
Read project walkthrough on: Substack
- React - UI library
- TypeScript - Type safety
- Vite - Build tool and development server
- Tailwind CSS - Utility-first CSS framework
The project is organized into the following folder structure to ensure clarity and maintainability:
react-tic-tac-toe/
├── src/
│ ├── components/ # Reusable React components (e.g., Board, Square)
│ ├── types/ # common types shared across components
│ ├── utils/ # Utility functions (e.g., checkWinner, minimax)
│ ├── App.tsx # Main application component
│ ├── main.tsx # Entry point of the application
├── public/ # Static assets (e.g., favicon, index.html)
├── eslint.config.js # linting rules
├── index.html # index file
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite configuration
components/
: Contains all the React components used in the application. Each component is modular and focuses on a specific part of the UI.types/
: Contains common types that shared across components.utils/
: Houses utility functions for game logic, such as checking for a winner and implementing AI.
Follow these simple steps to get a local copy up and running:
- Node.js (version 16.x or later)
- npm or yarn
-
Clone the repository
git clone https://github.com/jjteoh-thewebdev/react-tic-tac-toe.git
-
Navigate to the project directory
cd react-tic-tac-toe
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser and navigate to
http://localhost:5173
To create a production build:
npm run build
The build artifacts will be located in the dist/
directory.
Distributed under the MIT License. See LICENSE
file for more information.
Creator - [email protected]
Project Link: https://github.com/jjteoh-thewebdev/react-tic-tac-toe