nicolodavis
Joined 9 years ago
Joined 9 years ago
I chose to go with a monadic approach in boardgamelab.app (I'm not limited by language features since I'm designing it from the ground up for this use case). The language is pure and functional with managed effects. You can express things like:
set of cards -> filter by action cards -> choose -> [card]
do stuff with [card]
written in a synchronous style, while under the hood it:1. suspends the rule.
2. waits for the user to make a choice.
3. resumes the rule with the choice made by the user.
(note: listed above is a simplified text representation. The Boardgame Lab structure editor uses a block-based visual language.)
If written in Haskell, the underlying monad would look something like this:
{-# LANGUAGE ExistentialQuantification #-}
newtype Rule a = Rule {fn :: State -> (RuleResult a, State)}
data RuleResult a
= Done a
| forall x. Show x => Choose [x] (x -> Rule a)
instance Monad Rule where
m >>= k = Rule $ \state ->
case fn m state of
(Done a, state') -> fn (k a) state'
(Choose list m', state') -> (Choose list (m' >=> k), state')
i.e. each rule returns either a completed result or a choice along with a continuation of the remainder of the rule past that choice.More recently, I've been working on https://boardgamelab.app/, which uses a visual programming language to model game rules while also taking care of the UI layer.
1. James Ross: https://www3.nd.edu/~afreddos/courses/43151/ross-immateriali...
2. Edward Feser: https://www.newdualism.org/papers/E.Feser/Feser-acpq_2013.pd...
3. John Searle: https://philosophy.as.uky.edu/sites/default/files/Is%20the%2...
Do you happen to have any links to the documents that your previous bishop wrote?
You get the benefits of writing code composed of neat delineated expressions that nest arbitrarily but without the verbosity that parentheses add to the source file.
Just asking out of curiosity and maybe readers can learn a thing or two about making documentation more accessible.
Comparing the two languages, I would say that Rust's enums and pattern matching make it easier to work with for my specific use case.
I use TypeScript / Svelte for DOM interactions and only call into Rust code for the state updates (treating it like a black box).
boardgame.io - MIT licensed open-source JS library.
boardgamelab.app - Proprietary platform for designing and playtesting board games.