Skip to content

Li-Suqi/AwaleGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awale Game, Chat, and Multiplayer Server

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.

Overview

  • 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.

Prerequisites

  • A C toolchain (clang/gcc) and make
  • macOS or Linux (Windows requires WinSock and should compile with MSVC/MinGW with minor tweaks)

Build

  • Build all binaries:
    • make
  • Clean artifacts:
    • make clean

Run — Local Awale Game (single player)

  • 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.

Run — Chat Server and Client

  1. Start the chat server (listens on 1977):
    • ./bin/chat/server
  2. Connect with one or more clients:
    • ./bin/chat/client 127.0.0.1 Alice
    • ./bin/chat/client 127.0.0.1 Bob
  3. Type lines in the client; messages are broadcast to all other clients.
  4. Press Ctrl+D (EOF) or stop the server to disconnect.

Run — Multiplayer Awale Server

  1. Start the game server (listens on 1977):
    • ./bin/game_server/server
  2. 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
  3. In each client, use these commands (case-sensitive):
    • LOGIN <username> — Log in with a unique name
    • LIST — Show online users
    • CHALLENGE <username> — Challenge a user to a game
    • ACCEPT — Accept your pending challenge
    • MOVE <index> — Make a move (0-11)
    • LISTGAMES — Show active games and their IDs
    • OBSERVE <game_id> — Observe a game by ID
    • UNOBSERVE — Stop observing
    • MSG <text> — Send a global chat message
    • MSGTO <username> <text> — Send a private chat message to a user
    • HELP — Show available commands

Gameplay Notes

  • 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.

Logging

  • The game server appends events to server.log with timestamps (login, challenges, moves, game over, observer join/leave).

Notes for Windows

  • 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).

AI Usage

  • 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.

License

This repository is for educational use. No license is provided.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors