A fully-featured Tic-Tac-Toe game that runs in your terminal — written in C from scratch. Play against a friend or challenge the computer, on any grid size you want, with a randomized color UI that looks different every time you launch it.
- 🤖 Single Player — play against a computer opponent
- 👥 Two Player — local multiplayer on the same machine
- 📐 Custom Grid Size — not just 3×3, pick any size you want
- ✏️ Custom Names & Symbols — choose X or O, enter your name
- 🏆 Multi-game Series — play N games in a row with score tracking
- 🎨 Random Color UI — terminal header picks a new random RGB color on every launch
- 📏 Terminal-aware Layout — detects your terminal size with
ioctland adapts the UI
Tictactoe/
└── tictactoe-c/
├── main.c # Entry point, UI, game loop
├── grid.c # Grid rendering
├── mark.c # Player and computer move logic
├── check.c # Win/draw condition checking
├── win.c # Win pattern calculations
├── play.c # Game flow per match
└── Makefile
git clone https://github.com/evans-0/Tictactoe.git
cd Tictactoe/tictactoe-c
make
./gameTo clean build artifacts:
make cleanRequires: GCC and a Unix terminal (Linux/macOS)
┌─────────────────────────────────┐
│ TIC-TAC-TOE │
│ │
│ Options: │
│ 1. Single Player │
│ 2. Double Player │
│ 3. Exit │
│ │
│ Enter choice: _ │
└─────────────────────────────────┘
- Choose Single or Two Player
- Set the grid size
- Enter player name(s) and symbol (X or O)
- Choose number of games in the series
- Play — scores are tracked across all matches!
| Module | Responsibility |
|---|---|
main.c |
Terminal UI, ANSI colors, game loop, menu |
grid.c |
Board rendering |
mark.c |
Human and computer move handling |
check.c |
Checking win/draw conditions |
win.c |
Precomputing win patterns (row, col, diagonals) |
play.c |
Per-match game flow |
The UI uses raw ANSI escape codes for cursor positioning, colors, and terminal clearing — no external libraries.
