Boardgame.io: an engine for creating turn-based games using JavaScript
61–69 of 69 posts
Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#62This engine uses a Redux-like architecture. You have a State type (containing data like "the position of the black kingside rook") and a stream of in-game actions (like "knight to F3"). Each action is handled by a pure function which converts the current State to a new State. You can either transmit State deltas from the server to the client, or just transmit the actions themselves ( https://longwelwind.net/blog/netw…
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.Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#63Earlier quoted context omitted.
My main pain point with any sort of Flux-like state management is transitions [1]. The state of UI is not fully described by the state of the game [2]. If I play a card, the game state can be instantly updated to the next decison-making point, but in reality I want to show steps of the game through animations, some of which are concurrent and some of which are consecutive. That usually ends up in a mess; and I've nev…
I toyed with an approach once that separated animations from game state updates. Every player action could cause a cascade of updates, which would all be resolved “instantly” to the point no more cascaded updates were left to be processed. While this is happening, any update that includes an animation pushes that to an “animation stack”, then the animations are played back one by one to show the player what happened.…
Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#64Earlier quoted context omitted.
How does secret state fit in this? If you want each player hand to be secret, then each player has its own state?
boardgame.io only runs game logic on the server, and it censors the State just before sending it to each client. This strategy makes the UI feel less responsive, but it keeps things simple. The Swords and Ravens blog post recommends resolving actions on the client when they don't require secret information, but resolving other actions on the server. You'd also need to resolve actions on the server when they involve R…
For actions that require secret information, you would filter the actions sent to the client of any secret information and make sure the code handling the action can handle both the action and the filtered actins.
For actions involving RNG, make all randomness rely on a seed. This seed would be stored server-side and passed along the action when sent to the client. This makes sure the clients can deterministically reproduce the update.
Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#65Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#66Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#67This engine uses a Redux-like architecture. You have a State type (containing data like "the position of the black kingside rook") and a stream of in-game actions (like "knight to F3"). Each action is handled by a pure function which converts the current State to a new State. You can either transmit State deltas from the server to the client, or just transmit the actions themselves ( https://longwelwind.net/blog/netw…
My main pain point with any sort of Flux-like state management is transitions [1]. The state of UI is not fully described by the state of the game [2]. If I play a card, the game state can be instantly updated to the next decison-making point, but in reality I want to show steps of the game through animations, some of which are concurrent and some of which are consecutive. That usually ends up in a mess; and I've nev…
I ended up using ref's heavily to avoid stale closure and async re-render issues. Which basically amounts to circumventing React and interacting with the DOM directly.
Re: Boardgame.io: an engine for creating turn-based games using JavaScript
#68Earlier quoted context omitted.
Still needs clearer language IMO.
I just checked and it says MIT licensed. What am I missing?
boardgame.io - MIT licensed open-source JS library.
boardgamelab.app - Proprietary platform for designing and playtesting board games.