🎯 Overview
TicTacToe Game is a modern version of the classic strategy game, implemented in Python using Pygame for graphics and Pygbag for web deployment. Play against the computer or another player, aiming to align three marks in a row, column, or diagonal.
This project demonstrates:
- Python fundamentals: control flow, data structures, and event handling
- Pygame: graphical interface, game loop, and input management
- Pygbag: packaging and running Python games in the browser
🚀 Features & Mechanics
Classic Gameplay
Play TicTacToe against the computer (AI) or another player.
AI Opponent
Computer uses minimax algorithm for optimal moves.
Responsive Design
Playable on desktop and mobile browsers.
Restart & Exit
Restart with button, exit with button or menu.
Portfolio Colors
Uses your portfolio's color palette for a modern look.
Game Flow
- Start the game and choose your move by clicking a cell.
- Alternate turns between player and computer.
- Win by aligning three marks in a row, column, or diagonal.
- Game ends with a win or draw. Restart or exit as desired.
🛠️ Technologies & Deployment
- Python 3.x: Main programming language
- Pygame: Graphics, event handling, and game loop
- Pygbag: Converts Python/Pygame games to run in the browser (WebAssembly)
- HTML5/CSS3: Used for web packaging and styling
Pygbag Web Deployment
- Rename your main file to
main.py (required by Pygbag)
- Install pygbag:
pip install pygbag
- Build for web:
python -m pygbag --build .
- Open
build/web/index.html in your browser
- Ready for publishing on any static web host
# Example build command
python -m pygbag --build .
🎮 How to Play
Start Game
Run main.py locally or open index.html (web build) in your browser.
Make a Move
Click on a cell to place your mark (X or O).
Alternate Turns
Player X starts, then the computer (O) or second player moves.
Win or Draw
Align three marks to win, or fill the board for a draw.
Restart & Exit
Use the Restart or Close Game buttons at the bottom.
Controls
- Mouse: Click cells to play, buttons to restart/exit
- Touch: Tap cells and buttons on mobile
🌟 Highlights & Customization
- Zero dependencies for web: Runs in browser with Pygbag, no installation needed
- Responsive design: Playable on desktop and mobile
- Customizable appearance: Easily change colors and board size in
main.py
- Educational: Great for learning Python, Pygame, and web deployment
- Clean code structure: Well-organized and commented for easy extension
🚦 Project Status
✅ Completed
✅ Tested
✅ Responsive
✅ Web-ready
✅ Educational
All features implemented and tested. Play locally or in your browser. Clean, secure, and optimized code for learning and fun!