DOGMud Engine Overview

A Go MUD engine with a YAML-authored world

DOGMud Engine Overview A Go MUD engine with a YAML-authored world One Go process On disk Telnet players · MUD clients, screen readers · Architecture component Telnet players MUD clients, screen readers Browser players · bundled web client · Architecture component Browser players bundled web client Telnet listeners · :33333 · :44444 · AI :55555 · One Go process · goroutine per connection Telnet listeners :33333 · :44444 · AI :55555 goroutine per connection HTTP + WebSocket · internal/web · :8090 · /ws · One Go process · web client + admin tools HTTP + WebSocket internal/web · :8090 · /ws web client + admin tools Connection pipeline · connections + inputhandlers · One Go process · reads in, and writes back out Connection pipeline connections + inputhandlers reads in, and writes back out World tick loop · MainWorker · 50 ms turns · One Go process · 80 turns = one 4 s round World tick loop MainWorker · 50 ms turns 80 turns = one 4 s round Rooms · internal/rooms · One Go process Rooms internal/rooms Mobs · internal/mobs · One Go process Mobs internal/mobs Users & characters · internal/users · characters · One Go process Users & characters internal/users · characters Modules · gmcp · weather · time · playtest · One Go process · attach via event listeners Modules gmcp · weather · time · playtest attach via event listeners Mob instance saves · mobs.instances · On disk · training, skills, gold, gear Mob instance saves mobs.instances training, skills, gold, gear YAML world data · _datafiles/world/dogmud · On disk · read once at boot YAML world data _datafiles/world/dogmud read once at boot Room instance saves · rooms.instances · On disk · floor items, gold, containers Room instance saves rooms.instances floor items, gold, containers telnet HTTP · WebSocket commands queued Message events raw socket write websocket text frame events templates overlay, if saved overlay, if saved Legend Frontend Backend Database Message bus External

Edge, in and out

  • • Telnet on :33333 and :44444, AI clients on a separate :55555
  • • HTTP on :8090 serves the web client and upgrades /ws
  • • Either transport ends up as the same ConnectionDetails, and internal/inputhandlers runs the login, IAC and ANSI chain on it
  • • Game text does not travel back through the listener goroutine or the HTTP server
  • • That goroutine still writes the splash, the login flow and the prompt redraw itself
  • • ConnectionDetails.Write is the single split: a websocket text frame, or a raw socket write

Game loop

  • • MainWorker fires a turn every 50 ms; 80 turns make a 4 second round
  • • Every tick takes one global world lock, so game state stays single-writer
  • • Combat, mob AI, quests and achievements are all event listeners
  • • Game text is queued as an events.Message rather than written where it is produced
  • • Message_SendMessage drains those events inside the tick, parses ANSI, and calls connections.SendTo

World data

  • • Rooms, mobs, items, quests and dialogue are hand-authored YAML
  • • The template always loads; a saved instance is layered on top only if one exists
  • • There are two save layers, not one: rooms.instances/ unmarshals straight onto the room struct
  • • mobs.instances/ copies a fixed record instead, so a mob save can only carry the fields that record declares
  • • Player saves live in users/ and are not part of the instance overlay