|
Zappy Server
C++ game server: world, rules, scheduler, network
|
C game server (built in C++). Single process, single thread, poll()-driven. Owns the world, enforces the rules, talks to AI clients and GUI clients over one TCP port.
Deep dive: full protocol tables, per-class notes and design rationale live in the implementation reference. This page is the map.
GRAPHIC → GUI, any other valid team → AI.-c = slots per team, -f = time-unit frequency. GRAPHIC is reserved and rejected as a team name.
| Layer | Lives in | Job |
|---|---|---|
network/ | Listener, Connection, ClientManager | sockets, line buffering, the poll() set |
core/ | Server, World, Scheduler, GameClock, Args | game state + logic + timing, no network knowledge |
protocol/ | AiParser, GuiParser, Serializer | parse client lines / build wire strings |
game/ | CommandDispatcher, GuiNotifier, commands/ | route lines to handlers, broadcast state to GUIs |
Two rules hold the design together:
World is pure** — it mutates state and knows nothing about sockets or timers, so it is unit-testable in isolation. The server layer observes the result.Scheduler owns all timing** — every action (duration = cost / freq) is a timed callback. The scheduler's next-fire time is fed straight to poll() as the timeout.c takes c / freq seconds. sst (GUI changes freq) rescales every pending timer. Game ticks are the integral of freq over time (GameClock), so they stay correct across speed changes.20 / freq seconds: floor(w * h * density) per type.300 / freq ritual; participants frozen meanwhile; cross-team allowed.Scheduler, CommandDispatcher, Serializer, parsers, World, broadcastDirection.tests/e2e/): fork the real binary, talk raw TCP, assert on the wire bytes.