Skip to content

fschuetz/mud-server

Repository files navigation

MUD Server

A concept study for ANSI capable mud server to interoperate with the BalcCon Badge.

Software Design

High Level Architecture

TODO - connection manager / world task

Concurrency Model

In order to allow multiple users access the mud we need some sort of concurrency. The main models to choose from are:

  • OS threads

    Easy to use, however has a big overhead and needs us to deal with synchronization problems.

  • Coroutines

    Not well supported and not ideal for server code.

  • Event-driven programming

    Usually results in non linear control flow. Data flow and errors are hard to follow.

  • Actor model

    Divides concurent calculations in actors. Actors communicate through fallible messages. Unclear how to address flow control and retry logic.

  • Rust Async

    Performant for high amount of parallel operations with high latency (especially I/O operations). Not ideal for parallell computations.

(DECISION) The async model will be used. The software will be implented in Rust using tokio as the engine for async.

Asorted notes:

Protocol:

  • General considerations message format: Type |
  • Command message format: CMD
  • Data message format:

AI Actors:

  • Run in own thread each like a simulated player

Misc stuff:

  • Client keypair: Must be ed25519
  • Calling from a client: ssh -i ~/.ssh/id_ed25519 -o "UserKnownHostsFile=/dev/null" -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no localhost -p 2222

Grammar

Support for the following clauses:

  1. (sbuject implied as self) verb Examples: - Look

  2. (subject implied as self) verb - object. Examples: - Look at object - Read book - Open port

  3. (subject implied as self) verb - adjective - object Examples: - Look at old book - Read yellow paper - Open rusty port

  4. verb - object - preposition - object Examples: - Attack ICE with exploit - Examine port with portscan

  5. verb - adjective - object - preposition- adjective - object - Attack black ICE with weak exploit - Use ancient glasses to read old book

In order to develop a language that the programm understands, we need to develop a syntax and semantics.

We provide the syntay in BNF as a basis to build the parser. The BNF can be tested at BNF Playgound

// TODO - maybe just allow one adverb for simplicity sake

 <sentence> ::= <action> | <command>
 <action> ::= <verb> <blank> <adverblist> <blank> <object> ("." | E)
 <command> ::= "help" (<blank> <topic> | E) | "inventory"
 <adverblist> ::= <adverb> | <adverb> (","+ <blank>* | <blank>+) <adverblist> | E
 <adverb> ::= "quickly" | "slowly"
 <do> ::= "do"
 <verb> ::= "look" | "read" | "enter" | "connect" | "access" | "open"
 <object> ::= <article> ("port" | "ram bank" | "quickhack")
 <article> ::= ("the" <blank> | E)
 <topic> ::= "verbs" | "inventory" | "combat" 
 <blank> ::= " "+

Terminal cursor movement Test\r\n\x1B[0;0HThis is a test" See also: https://docs.rs/termion/latest See also: https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html