- ๐ค 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
- ๐ Sign Up/Login - Secure user registration and authentication
- ๐ค User Profiles - Personalized gaming experience
- ๐ JWT Authentication - Secure session management
- ๐ฑ Mobile Optimized - Perfect gameplay on all devices
- ๐ป Desktop Enhanced - Rich experience on larger screens
- ๐จ Modern UI - Clean, intuitive interface with smooth animations
- ๐ฏ Minimax Algorithm - Challenging AI opponent
- โก Real-time Moves - Instant AI responses
- ๐ฒ Strategic Gameplay - AI makes optimal moves
- ๐ 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
- Node.js 16+ installed
- MongoDB database (local or cloud)
git clone https://github.com/saurabhduhariya/tic-tac-toe.git
cd tic-tac-toecd 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 startcd ../Frontend
npm install
npm run devNavigate to http://localhost:5173 and start playing! ๐ฎ
- vs AI: Challenge the computer - you're X, AI is O
- vs Human: Local multiplayer - take turns on the same device
- 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)
- Desktop: Click on any empty square
- Mobile: Tap on any empty square
- Responsive: Seamless experience across all devices
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! ๐
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)
}- โจ Smooth animations and transitions
- ๐ฏ Interactive hover effects
- ๐ฑ Mobile-first responsive design
- ๐ Dark theme with cyan accents
- ๐ Loading states and feedback
- โก Fast React with Vite
- ๐จ Utility-first CSS with Tailwind
- ๐ Secure JWT authentication
- ๐ Real-time game state management
- ๐ Optimized for performance
- ๐ Win detection with strike animation
- ๐ Multi-round match support
- ๐ฏ Custom round configuration
- ๐พ Game state persistence
- ๐ Instant game reset
cd Frontend
npm run build
# Deploy to Vercelcd Backend
# Configure vercel.json for serverless deployment
# Deploy to VercelContributions are welcome! Here's how to get started:
- ๐ด Fork the repository
- ๐ Create a feature branch
git checkout -b feature/amazing-feature
- ๐พ Commit your changes
git commit -m 'Add amazing feature' - ๐ค Push to the branch
git push origin feature/amazing-feature
- ๐ฏ Open a Pull Request
Found a bug? Please open an issue with:
- ๐ Clear description
- ๐ Steps to reproduce
- ๐ป Expected vs actual behavior
- ๐ฑ Device/browser information
- ๐ฎ Inspiration from classic Tic Tac Toe
- ๐ง Minimax algorithm for AI implementation
- ๐จ Modern UI/UX design principles
- ๐ฑ Mobile-first responsive design approach
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