Skip to content

evans-0/Tictactoe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation


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.


✨ Features

  • 🤖 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 ioctl and adapts the UI

📁 Structure

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

🚀 Build & Run

git clone https://github.com/evans-0/Tictactoe.git
cd Tictactoe/tictactoe-c
make
./game

To clean build artifacts:

make clean

Requires: GCC and a Unix terminal (Linux/macOS)


🎮 Gameplay

┌─────────────────────────────────┐
│          TIC-TAC-TOE            │
│                                 │
│  Options:                       │
│      1. Single Player           │
│      2. Double Player           │
│      3. Exit                    │
│                                 │
│  Enter choice: _                │
└─────────────────────────────────┘
  1. Choose Single or Two Player
  2. Set the grid size
  3. Enter player name(s) and symbol (X or O)
  4. Choose number of games in the series
  5. Play — scores are tracked across all matches!

📸 Screenshot

Tictactoe Screenshot


⚙️ How it's built

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.


About

A lightweight, two-player Tic-tac-toe game that runs entirely in the terminal - built in C with a simple Makefile build system.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors