A Windows desktop Tic-Tac-Toe game written in C++ using the Win32 API. You play as X against a computer opponent that uses the Minimax algorithm with alpha-beta pruning.
- 3x3 game board rendered as clickable buttons
- Resizable window — buttons scale with it
- AI opponent using Minimax with alpha-beta pruning (unbeatable)
- Color-coded cells: blue for X, red for O
- Detects wins, losses, and ties with a play-again prompt
- Windows OS
- A C++ compiler with Win32 support (e.g. MSVC or MinGW)
MSVC:
cl /EHsc tictactoe.cpp /link user32.lib gdi32.lib
MinGW:
g++ tictactoe.cpp -o tictactoe.exe -lgdi32 -luser32 -mwindows
- Run the executable.
- You are X and always go first.
- Click any empty cell to place your move.
- The computer responds automatically.
- First to get three in a row wins. If the board fills with no winner, it's a tie.
- At game over, choose to play again or quit.
The AI is optimal - at best you can force a draw. It will never lose.