Skip to content

saurabhduhariya/Tic-Tac-Toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Advanced Tic Tac Toe Game

Live Demo GitHub LinkedIn

A modern, feature-rich Tic Tac Toe game with AI, user authentication, and responsive design


โœจ Features

๐ŸŽฎ Game Modes

  • ๐Ÿค– AI vs Human - Challenge an intelligent AI opponent
  • ๐Ÿ‘ฅ Human vs Human - Play with friends locally
  • ๐ŸŽฏ Multiple Match Types - Single game, Best of 3/5/7, or custom rounds

๐Ÿ” User Authentication

  • ๐Ÿ“ Sign Up/Login - Secure user registration and authentication
  • ๐Ÿ‘ค User Profiles - Personalized gaming experience
  • ๐Ÿ”’ JWT Authentication - Secure session management

๐Ÿ“ฑ Responsive Design

  • ๐Ÿ“ฑ Mobile Optimized - Perfect gameplay on all devices
  • ๐Ÿ’ป Desktop Enhanced - Rich experience on larger screens
  • ๐ŸŽจ Modern UI - Clean, intuitive interface with smooth animations

๐Ÿง  Smart AI

  • ๐ŸŽฏ Minimax Algorithm - Challenging AI opponent
  • โšก Real-time Moves - Instant AI responses
  • ๐ŸŽฒ Strategic Gameplay - AI makes optimal moves

๐ŸŽช Advanced Features

  • ๐Ÿ“Š Match Tracking - Round-by-round score tracking
  • ๐Ÿ† Win Detection - Animated strike-through for wins
  • ๐Ÿ”„ Game State Management - Seamless game flow
  • ๐Ÿ’ซ Smooth Animations - Engaging visual feedback

๐Ÿ› ๏ธ Tech Stack

Frontend

React Vite TailwindCSS JavaScript

Backend

Node.js Express.js MongoDB JWT

Deployment

Vercel


๐Ÿš€ Quick Start

Prerequisites

  • Node.js 16+ installed
  • MongoDB database (local or cloud)

1. Clone the Repository

git clone https://github.com/saurabhduhariya/tic-tac-toe.git
cd tic-tac-toe

2. Backend Setup

cd Backend
npm install

# Create .env file with your MongoDB URI
echo "MONGO_URI=your_mongodb_connection_string" > .env
echo "JWT_SECRET=your_jwt_secret_key" >> .env

npm start

3. Frontend Setup

cd ../Frontend
npm install
npm run dev

4. Open Your Browser

Navigate to http://localhost:5173 and start playing! ๐ŸŽฎ


๐ŸŽฎ How to Play

๐ŸŽฏ Game Modes

  1. vs AI: Challenge the computer - you're X, AI is O
  2. vs Human: Local multiplayer - take turns on the same device

๐Ÿ† Match Types

  • Single Game: One quick round
  • Best of 3/5/7: First to win majority of rounds
  • Custom: Set your own number of rounds (1-100)

๐Ÿ“ฑ Controls

  • Desktop: Click on any empty square
  • Mobile: Tap on any empty square
  • Responsive: Seamless experience across all devices

๐Ÿ—๏ธ Project Structure

tic-tac-toe/
โ”œโ”€โ”€ ๐Ÿ“ Frontend/                 # React frontend
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ components/       # React components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Auth/         # Authentication components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Game/         # Game-related components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Sidebar/      # Game controls
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Tic-Tac-Toe/  # Core game components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ AI/           # AI logic
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ utils/            # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ index.css         # Global styles
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ package.json
โ”œโ”€โ”€ ๐Ÿ“ Backend/                  # Node.js backend
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Controllers/          # Route controllers
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Middleware/           # Auth middleware
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ models/               # Database models
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Routes/               # API routes
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ index.js              # Server entry point
โ””โ”€โ”€ ๐Ÿ“„ README.md                 # You are here! ๐Ÿ“

๐Ÿง  AI Algorithm

The AI uses the Minimax algorithm with the following features:

  • ๐ŸŽฏ Perfect Play: AI never loses, only wins or draws
  • โšก Optimized Performance: Efficient move calculation
  • ๐ŸŽฒ Strategic Depth: Looks ahead to make optimal moves
  • ๐Ÿ”ฎ Predictive Analysis: Considers all possible outcomes
// Simplified AI logic
function minimax(board, depth, isMaximizing) {
  // Base cases: check for terminal states
  if (checkWinner(board) === AI_PLAYER) return 10 - depth;
  if (checkWinner(board) === HUMAN_PLAYER) return depth - 10;
  if (isDraw(board)) return 0;
  
  // Recursive minimax with alpha-beta pruning
  // ... (full implementation in /Frontend/src/components/AI/aiLogic.js)
}

๐ŸŒŸ Key Features Breakdown

๐ŸŽจ UI/UX Features

  • โœจ Smooth animations and transitions
  • ๐ŸŽฏ Interactive hover effects
  • ๐Ÿ“ฑ Mobile-first responsive design
  • ๐ŸŒ™ Dark theme with cyan accents
  • ๐Ÿ”„ Loading states and feedback

๐Ÿ”ง Technical Features

  • โšก Fast React with Vite
  • ๐ŸŽจ Utility-first CSS with Tailwind
  • ๐Ÿ” Secure JWT authentication
  • ๐Ÿ“Š Real-time game state management
  • ๐Ÿš€ Optimized for performance

๐ŸŽฎ Game Features

  • ๐Ÿ† Win detection with strike animation
  • ๐Ÿ“Š Multi-round match support
  • ๐ŸŽฏ Custom round configuration
  • ๐Ÿ’พ Game state persistence
  • ๐Ÿ”„ Instant game reset

๐Ÿš€ Deployment

Frontend (Vercel)

cd Frontend
npm run build
# Deploy to Vercel

Backend (Vercel)

cd Backend
# Configure vercel.json for serverless deployment
# Deploy to Vercel

๐Ÿค Contributing

Contributions are welcome! Here's how to get started:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒŸ Create a feature branch
    git checkout -b feature/amazing-feature
  3. ๐Ÿ’พ Commit your changes
    git commit -m 'Add amazing feature'
  4. ๐Ÿ“ค Push to the branch
    git push origin feature/amazing-feature
  5. ๐ŸŽฏ Open a Pull Request

๐Ÿ› Bug Reports

Found a bug? Please open an issue with:

  • ๐Ÿ“ Clear description
  • ๐Ÿ”„ Steps to reproduce
  • ๐Ÿ’ป Expected vs actual behavior
  • ๐Ÿ“ฑ Device/browser information

๐Ÿ‘จโ€๐Ÿ’ป Developer

Saurabh Prajapat

GitHub LinkedIn

Full Stack Developer passionate about creating engaging web experiences


๐Ÿ™ Acknowledgments

  • ๐ŸŽฎ Inspiration from classic Tic Tac Toe
  • ๐Ÿง  Minimax algorithm for AI implementation
  • ๐ŸŽจ Modern UI/UX design principles
  • ๐Ÿ“ฑ Mobile-first responsive design approach

๐ŸŽฎ Ready to Play?

Play Now

Made with โค๏ธ by Saurabh Prajapat

โญ If you enjoyed this project, please give it a star! โญ


๐ŸŽฎ Game on! โ€ข ๐Ÿš€ Built with modern web technologies โ€ข ๐Ÿ“ฑ Responsive design โ€ข ๐Ÿง  Smart AI

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published