What You'll Build
- A Tic Tac Toe game with:
- Classic 3x3 grid with X and O markers
- AI opponent using minimax algorithm (unbeatable on hard mode)
- Win and draw detection with visual line-through
- Score tracking across multiple rounds
- Smooth animations for placing marks
- Play again functionality
Tool: Bolt (no coding needed) Difficulty: Beginner Time: ~20 minutes Coding required: None
You're going to build the classic Tic Tac Toe game — but with a twist. Your version will have an AI opponent that uses the minimax algorithm, making it mathematically unbeatable on the hardest difficulty. Players will face off against the computer, trying to get three in a row on a 3x3 grid while the AI blocks their every move. It's the perfect blend of simple rules and clever logic.
Tic Tac Toe is the ideal first vibe coding project. The game has clear, simple rules that are easy to describe in a prompt, and the result is immediately playable and satisfying. Bolt builds the entire game from a single prompt in seconds, and you'll iterate with follow-up prompts to add polish. By the end, you'll have a game you'd be proud to show anyone.
What You Need
The Founding Prompt
Go to bolt.new and paste this prompt:
Build a Tic Tac Toe game with the following specifications: Board: - 3x3 grid centered on the page - Each cell is a large clickable square (at least 120px) - Grid lines are thick and dark gray - Clean white background inside each cell Gameplay: - Player is X and always goes first - AI opponent plays as O - Player clicks an empty cell to place their X - AI responds automatically after a 400ms delay - Implement the minimax algorithm so the AI plays optimally and never loses - Only empty cells should be clickable Win detection: - Check for 3 in a row horizontally, vertically, and diagonally after every move - When someone wins, draw a line through the winning 3 cells (a colored line that crosses through them) - X wins: green line, O wins: red line - Show a message above the board: "You Win!", "AI Wins!", or "It's a Draw!" - Detect draws when all 9 cells are filled with no winner Score tracking: - Show a scoreboard above the board: "You: [X] — AI: [O] — Draws: [D]" - Scores persist across rounds until the page is refreshed Controls: - "Play Again" button appears after each game ends - "Reset Scores" button to clear the scoreboard - Style buttons with rounded corners and a blue background Styling: - Modern, minimal design - X marks in blue, O marks in red - Use a large bold font for X and O (font-size: 64px) - Centered layout with max-width of 450px - Responsive for mobile screens
Click Generate and wait for Bolt to build your game.
Step 1: Test the Game Logic
Click a cell to place your X and watch the AI respond with O. Try to win — if the minimax algorithm is working correctly, the best you should manage is a draw. Test that the win detection correctly identifies horizontal, vertical, and diagonal wins. Play a few rounds to make sure the score counter updates.
Step 2: Add Difficulty Levels
An unbeatable AI is fun for a challenge, but beginners want a chance to win. Add difficulty settings so the AI makes mistakes on easier modes.
Add a difficulty selector with three options displayed as buttons above the board: Easy, Medium, and Hard. - Easy: The AI picks a random empty cell 70% of the time, and uses minimax 30% of the time - Medium: The AI uses minimax 70% of the time and picks randomly 30% of the time - Hard: The AI always uses minimax (current behavior, unbeatable) Highlight the currently selected difficulty button. Default to Medium. Reset the board when difficulty is changed but keep the scores.
Step 3: Add Animations
Static marks are boring. Add smooth animations so placing X and O feels satisfying and polished.
Add animations to the game: - When X is placed, animate it drawing in with a stroke animation (the lines of the X draw from center outward, 300ms) - When O is placed, animate it drawing in as a circle stroke (draws clockwise, 300ms) - When a game ends in a win, animate the winning line drawing across the three cells (400ms) - When "Play Again" is clicked, fade out all marks simultaneously (200ms) before clearing the board - Add a subtle scale-up effect on cells when hovered (1.05 scale, only on empty cells) - Add a slight bounce animation to the result message when it appears
Step 4: Add Game History
Let players review their past games. Add a history panel that records the outcome of each round.
Add a game history section below the board. After each game, record: - Game number (1, 2, 3, etc.) - Result (Win, Loss, or Draw) - Difficulty level - Number of moves played Display as a compact list showing the last 10 games. Each entry should be color-coded: green for wins, red for losses, gray for draws. Add a "Clear History" button at the bottom. Store history in localStorage so it persists on refresh.
Step 5: Add Sound Effects
Sound feedback makes each move feel impactful. Add distinct sounds for placing marks and game outcomes.
Add sound effects using the Web Audio API (generate programmatically, no audio files): - Place X: crisp tap sound (short sine wave at 600Hz, 60ms) - Place O: slightly deeper tap (sine wave at 400Hz, 60ms) - Player wins: happy ascending chime (C5, E5, G5 played quickly) - AI wins: descending tone (G4, E4, C4 played quickly) - Draw: single neutral tone (A4, 200ms) - Invalid click (on occupied cell): very short buzz (100Hz, 30ms) - Add a mute toggle button (speaker icon) in the top-right corner
Step 6: Make It Mobile Friendly
The game should feel great on phones with large tap targets and proper sizing.
Optimize the game for mobile devices: - On screens under 500px wide, make the grid cells fill the available width (90vw max, cells as squares) - Increase the touch target size — each cell should be at least 90px on mobile - Add 16px padding around the game container - Make sure the scoreboard and buttons stack vertically on small screens - Prevent double-tap zoom on iOS by adding touch-action: manipulation to the game area - Test that tapping cells works reliably (use touchstart events alongside click events)
Step 7: Deploy and Share
Your Tic Tac Toe game is ready to share. Click the Deploy button in Bolt to publish your game to a live URL. Bolt handles hosting automatically — you'll get a link in seconds. Challenge your friends to try beating the AI on Hard mode.
Level Up Your Game
Try these follow-up prompts to make your game even better:
Add a two-player mode:
Add a "2 Player" mode toggle next to the difficulty buttons. In 2 Player mode, two humans take turns clicking cells (no AI). Show "Player 1 (X)" and "Player 2 (O)" labels. Track scores separately for the 2 Player mode. Switch the turn indicator above the board to show whose turn it is.
Add a timer:
Add a move timer. Each player has 10 seconds to make a move. Show a countdown timer above the board that resets after each move. If time runs out, that player forfeits the round. Display the timer as a circular progress ring that depletes. In AI mode, only apply the timer to the human player.
Add a larger board:
Add a "5x5 Mode" option. In this mode, the board is 5x5 and players need 4 in a row to win instead of 3. Adjust the AI to work on the larger board (use minimax with depth limit of 4 for performance). Show which mode is active. Adjust cell sizes so the larger board fits on screen.
Add high score saving:
Track a win streak counter — how many games in a row the player has won. Show the current streak and the best-ever streak above the scoreboard. Save the best streak to localStorage. When the player beats their best streak, show a "New Record!" message with a brief gold flash animation.
Add themes:
Add a theme picker with 3 options: Classic (current black and white), Neon (dark background with glowing cyan X and magenta O), and Chalk (textured beige background with hand-drawn looking marks). Each theme should change the grid lines, mark colors, and background. Save the selected theme to localStorage.
Want persistent high scores? Follow our leaderboard guide to connect your game to a database.
Common Errors
Blank screen after prompt If Bolt generates a blank screen, add to your prompt: "Make sure the game renders immediately on page load with no user setup required."
Game not responding to keyboard Add to your prompt: "Ensure keyboard event listeners are attached to the document, not a specific element. Auto-focus the game container on load."
Mobile touch controls not working Add to your prompt: "Add touch event handlers for mobile. Include visible on-screen buttons for all controls on screens under 768px wide."