https://github.com/jankammerath/tictactoevibe
A simple HTTP-based Tic-Tac-Toe game server implemented in C using the libmicrohttpd library.
https://github.com/jankammerath/tictactoevibe
c-programming computer-opponent game-development http-server libmicrohttpd open-source rest-api simple-game tic-tac-toe web-game
Last synced: about 1 month ago
JSON representation
A simple HTTP-based Tic-Tac-Toe game server implemented in C using the libmicrohttpd library.
- Host: GitHub
- URL: https://github.com/jankammerath/tictactoevibe
- Owner: jankammerath
- License: mit
- Created: 2025-03-13T18:28:24.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-03-14T12:08:27.000Z (about 2 months ago)
- Last Synced: 2025-03-14T12:33:32.428Z (about 2 months ago)
- Topics: c-programming, computer-opponent, game-development, http-server, libmicrohttpd, open-source, rest-api, simple-game, tic-tac-toe, web-game
- Language: C
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tic-Tac-Toe Game Server
A simple HTTP-based Tic-Tac-Toe game server implemented in C using the libmicrohttpd library.## Overview
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## Features
- Simple, clean web interface
- RESTful API for game interactions
- Computer opponent making random moves
- Full game state tracking
- Win/loss/draw detection## Requirements
- C compiler (gcc or clang)
- libmicrohttpd library
- Standard C libraries (stdio, stdlib, string, time)## Building the Project
[Instructions for building the project would go here.]## Running the Server
This will start the server on port 8888. Open your web browser and navigate to `http://localhost:8888` to play the game.## API Endpoints
| 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 |## Game Board Layout
The game board is represented as a 3x3 grid with positions numbered 0-8:```
0 | 1 | 2
-----------
3 | 4 | 5
-----------
6 | 7 | 8
```## Response Format
Moves return JSON responses in the following format:```json
{
"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 status
- `gameOver` is true when the game has concluded# Architecture
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# License
This project is open source and available under the MIT license.# Acknowledgments
- Uses libmicrohttpd for HTTP server functionality
- Simple, educational implementation of HTTP-based game logic