An C project that implements:
- A local Awale console game
- A simple TCP chat server and client
- A multiplayer Awale game server with a command-driven client
The code is portable (POSIX + minimal WinSock guards) and built via a single Makefile.
src/game/— Awale game logic and a local CLI (bin/awale).src/chat/— Broadcast chat server (bin/chat/server) and client (bin/chat/client).src/game_server/— Awale multiplayer game server (bin/game_server/server) and client (bin/game_server/client).
Default TCP port is 1977 for both Chat and Game Server. Logs from the game server are appended to server.log.
- A C toolchain (
clang/gcc) andmake - macOS or Linux (Windows requires WinSock and should compile with MSVC/MinGW with minor tweaks)
- Build all binaries:
make
- Clean artifacts:
make clean
- Start the local CLI game:
./bin/awale
- Enter a hole index each turn and follow the prompts.
- Indices are
0-11:- Player 1 holes:
0-5(bottom row) - Player 2 holes:
6-11(top row) - The game ends when no valid moves remain; it prints the winner or a draw.
- Player 1 holes:
- Start the chat server (listens on
1977):./bin/chat/server
- Connect with one or more clients:
./bin/chat/client 127.0.0.1 Alice./bin/chat/client 127.0.0.1 Bob
- Type lines in the client; messages are broadcast to all other clients.
- Press
Ctrl+D(EOF) or stop the server to disconnect.
- Start the game server (listens on
1977):./bin/game_server/server
- Connect clients with a nickname (sent on connect, but you still need to LOGIN):
./bin/game_server/client 127.0.0.1 Alice./bin/game_server/client 127.0.0.1 Bob
- In each client, use these commands (case-sensitive):
LOGIN <username>— Log in with a unique nameLIST— Show online usersCHALLENGE <username>— Challenge a user to a gameACCEPT— Accept your pending challengeMOVE <index>— Make a move (0-11)LISTGAMES— Show active games and their IDsOBSERVE <game_id>— Observe a game by IDUNOBSERVE— Stop observingMSG <text>— Send a global chat messageMSGTO <username> <text>— Send a private chat message to a userHELP— Show available commands
- First player is chosen randomly when a game starts.
- Board prints as ASCII for clarity; scores and turns are announced.
- When the game ends, the server declares the winner to both players and observers.
- The game server appends events to
server.logwith timestamps (login, challenges, moves, game over, observer join/leave).
- The code includes WinSock initialization/cleanup stubs.
- You may need to compile with MSVC or MinGW and adjust include/linker flags for WinSock (
ws2_32).
- ChatGPT has helped me to understand the socket programming concepts and system call usage in the code.
- I have discussed with ChatGPT about the structure and logic of the game server, and I have got feedback about the steps to implement the multiplayer awale game.
- I have used ChatGPT and TRAE to help me debug the code and fix errors.
- I have used TRAE's auto code completion to edit C code (headers, function declarations).
- I have used Chinese to write the annotations in the code, and used TRAE to translated them into English across modules.
- I have used TRAE to drafted and refined README.md.
This repository is for educational use. No license is provided.