A game scripting language for rapid prototyping and story logic:
``` // declare initial state as 'phrases', one phrase per line happy money 70
// define rules of the format: INPUT = OUTPUT happy . money X . > X 50 . - X 50 Y = sad . money Y
// final state will be: // sad // money 20 ```
Rules are of the format INPUT = OUTPUT
, where INPUT
and OUTPUT
are lists that use period (.
) as a separator between items:
- INPUT
is a list of one or more conditions that must pass for the rule to be executed. The conditions can either be state phrases that must exist or predicates (such as >
) that must evaluate to true. Any matching state phrases are consumed by the rule on execution.
- OUTPUT
is a list of state phrases that will be generated by the rule if it is executed.
- Identifiers that use capital letters (X
and Y
in the snippet above) are variables that will be assigned when the rule is executed.
Evaluating a throne script involves executing any rule that matches the current state until the set of matching rules is exhausted. Rules are executed in a random order and may be executed more than once.
Strongly influenced by https://www.cs.cmu.edu/~cmartens/ceptre.pdf.