LudL Language

Intro

LudL stands for LudL Language. It is a domain-specific language (DSL) designed to codify game rules and is compatible with the Turnbase ecosystem.

Basic Syntax

  • A ruleset consists of a series of function directives followed by a series of receiver directives
  • Example: fibonacci
1
2
3
4
5
6
 DEF fib $n:
   IF LESS $n 2:
     RETURN 1;
   END_IF
   RETURN PLUS fib PLUS $n -1 fib PLUS $n -2;
 END_DEF
  • Receivers are special functions that are called when game play messages are received from the frontend.
    • For example, if the game is chess, when a player makes a move the frontend might send a message to the backend like move_token Pw4 e4, indicating that the player is attempting to move the token specified by Pw4 to the container e4. The backend then executes the receiver named move_token with the appropriate arguments to see whether the action was legal and updates the game state accordingly.
  • Functions and receivers consist of:
    • an opening statement declaring the signature of the form DEF or RECEIVE
    • a body consisting of a sequence of statements
    • an ending statement of the form END_DEF or END_RECEIVE to close the directive
  • A ruleset must have at least one receiver directive to be valid.