A Tic Tac Toe game written in C with CLI, Nano AI opponents, LAN multiplayer, and cloudflared-based Internet multiplayer.
-
Single Player vs AI
- Easy: Random moves (great for beginners)
- Medium: Blocks wins and tries to win
- Hard: Minimax algorithm
-
Two Player (Local)
- Play on the same machine
- Choose your symbol (X or O)
-
LAN Multiplayer
- Host or join games via TCP sockets
- Encrypted session with passphrase-based handshake
- Real-time board synchronization
-
Internet Multiplayer (CLI)
- Host a game over the internet using
cloudflaredtunnel service - Join with a shared cloudflared link/hostname
- Uses the same encrypted game handshake as LAN mode
- If
cloudflaredis missing, the game can prompt to install it
- Host a game over the internet using
LAN security is session-based and negotiated when a client connects:
- The client attempts a secure session using OpenSSL.
- If OpenSSL negotiation fails, it falls back to legacy compatibility mode.
- A connection is considered secure only when:
connected && security_ready && mode != NONE.
⚠ Legacy mode is provided for compatibility and does not provide encryption. It should only be used on trusted local networks.
- Passphrase key material is derived using PBKDF2-HMAC-SHA256 (200,000 iterations).
- The handshake exchanges a salt and client/server nonces, then derives
directional keys (
client → serverandserver → client). - Game packets are protected using AES-256-GCM authenticated encryption.
- Each frame includes a sequence number; replayed or stale sequence values are rejected.
-
Uses the older custom key/nonce stream + frame MAC path for compatibility.
-
Still enforces monotonic nonce checks to reject replayed frames.
-
OpenSSL mode is stronger and preferred for production LAN play.
-
CLI
- ANSI color themes (Default, Dark, Light, Retro)
- Enhanced bright color palette
- AI thinking indicators
- Unicode board rendering with ASCII fallback
- Live full-screen board redraw (video-like terminal flow)
- About page in main menu (author/contact/version)
- Code-driven sound effects (toggle in settings)
-
GUI (SDL2)
- Main menu flow aligned with CLI (AI, Local, LAN, Scores, Settings, About)
- Keyboard + mouse navigation
- In-window LAN host/join setup with encrypted handshake
- Live board rendering with game-over overlays and rematch flow
-
Customizable Settings
- Board sizes: 3x3, 4x4, 5x5
- Optional timer per move
- Configurable color themes
- Toggle sound effects
- C compiler (gcc, clang, or MSVC)
- CMake 3.10 or higher
# Linux/macOS
cmake -S . -B build-linux
cmake --build build-linux -j
# Windows (Visual Studio or Ninja)
cmake -S . -B build-windows
cmake --build build-windows --config ReleaseExecutable output is generated under build-<os>/bin/.
Use the scripts in building-scripts/:
- Linux:
bash building-scripts/install-linux.sh - macOS:
bash building-scripts/install-macos.sh - Windows:
powershell -ExecutionPolicy Bypass -File .\building-scripts\install-windows.ps1 - Termux:
bash building-scripts/install-termux.sh - Linux -> Windows cross-build:
bash building-scripts/build-windows-from-linux.sh
Each installer asks for:
Installmode (copy into a bin directory for regular use) orTestmode (build only inbuild-<os>/bin/inside the repo)
In Install mode, scripts detect existing installs:
- If not installed yet, they do a normal install flow.
- If already installed, they ask whether to:
- Update existing install
- Uninstall/remove it
- Install to another path
Termux users should launch with bash building-scripts/run-termux.sh.
--gui is intentionally blocked on Termux.
# Run (Linux/macOS)
./build-linux/bin/tictactoe-cx
# Launch GUI mode (when SDL2 is available)
./build-linux/bin/tictactoe-cx --gui
# Print version and exit
./build-linux/bin/tictactoe-cx --versionIf your terminal shows visual artifacts, you can force compatibility mode:
TICTACTOE_NO_LIVE=1 TICTACTOE_ASCII=1 ./build-linux/bin/tictactoe-cx- Use Up/Down arrows and Enter to navigate menus
- Enter moves as
23or2 3(row, column) - In game, press
Qto return to menu - Open About from main menu for game/author/version details
- Open Internet Multiplayer.
- Host:
- choose Host Internet Game
- share the generated cloudflared link with your opponent.
- Join:
- choose Join Internet Game
- paste the host link (or hostname) and connect.
Notes:
- Both players should have
cloudflaredinstalled. - The game can attempt automatic install when
cloudflaredis missing.
- Launch with
--gui - Use Arrow Keys + Enter or Mouse Click
- In game, click cells to move
- Press Esc to return to main menu
On first run, the game asks where to create its data directory. Default location:
- Linux/macOS/Termux:
~/.tictactoe-cx-config/ - Windows:
%USERPROFILE%\.tictactoe-cx-config\
Inside that directory:
config.inisaves/highscores.txt
Settings in config.ini include:
- Board size (3-5)
- AI difficulty
- Timer settings
- Color theme
- Sound enabled/disabled
The directory and files are auto-created and can be edited manually.
TicTacToe-CX/
├── src/
│ ├── main.c # Main game loop and menus
│ ├── game.c/h # Core game logic
│ ├── cli.c/h # CLI rendering with ANSI colors
│ ├── ai.c/h # AI opponents
│ ├── network.c/h # LAN multiplayer
│ ├── internet.c/h # Cloudflared tunnel integration
│ └── utils.c/h # Data/config/score storage helpers
├── building-scripts/ # Install/test build scripts
├── CMakeLists.txt
└── README.md
See LICENSE file.
- voltsparx - voltsparx@gmail.com