A simple HTTP-based Tic-Tac-Toe game server implemented in C using the libmicrohttpd library.
This project implements a web-based Tic-Tac-Toe game where:
- The player plays as 'X'
- The computer plays as 'O'
- The game runs in a web browser
- The game logic is handled by a C-based HTTP server
- Simple, clean web interface
- RESTful API for game interactions
- Computer opponent making random moves
- Full game state tracking
- Win/loss/draw detection
- C compiler (gcc or clang)
- libmicrohttpd library
- Standard C libraries (stdio, stdlib, string, time)
[Instructions for building the project would go here.]
This will start the server on port 8888. Open your web browser and navigate to http://localhost:8888
to play the game.
Endpoint | Method | Description |
---|---|---|
/ |
GET | Returns the game interface (HTML) |
/move |
POST | Makes a player move. Send JSON: {"position": 0-8} |
/reset |
POST | Resets the game to initial state |
The game board is represented as a 3x3 grid with positions numbered 0-8:
0 | 1 | 2
-----------
3 | 4 | 5
-----------
6 | 7 | 8
Moves return JSON responses in the following format:
{
"board": [0, 1, 2, 0, 0, 0, 0, 0, 0],
"message": "Player X's turn",
"gameOver": false
}
Where:
board
is an array of 9 integers (0=empty, 1=X, 2=O)message
indicates game statusgameOver
is true when the game has concluded
The server uses libmicrohttpd to handle HTTP requests and maintain game state. The application: Initializes the game state
- Processes player moves
- Makes computer moves
- Checks for win/loss/draw conditions
- Returns updated game state to the client
This project is open source and available under the MIT license.
- Uses libmicrohttpd for HTTP server functionality
- Simple, educational implementation of HTTP-based game logic