PuzzleScript
Lambda the Ultimate - Programming Languages Weblog 2014-01-07
Summary:
I haven't seen this discussed here yet: http://www.puzzlescript.net/
It is an HTML5-based puzzle game engine that uses a simple language for patterns and substitutions to describe game rules. For example (taken from their introduction), the basic block-pushing logic of a Sokoban game can be given as:
[ > Player | Crate ] -> [ > Player | > Crate ]
This line says that when the engine sees the pattern to the left of ->
, it should replace it with the pattern on the right. In this case, the rule can be read as something like: when there is a row or column ([]
) that contains a player object (Player
) next to (|
) a crate object (Crate
), and the player is trying to move toward the crate (>
), then (->
) make the crate move in the same direction.
Rules are matched and applied iteratively at each step (i.e., when the player acts), until there are no more matches, and then movement takes place. There are mechanisms for influencing the order in which rules are run, and for forcing subsets of the rules to be iterated. By default, rules apply to both rows and columns, but horizontal- or vertical-only rules can be created.
It is an interesting example of a very narrowly-focused DSL, based on a (relatively) uncommon model of computation. It's also very fun to play with!