Boardgame.io


Boardgame.io

this is part of a technical writeup, for the initial concept, see Jam Entry

To implement the game, I needed a library to develop against. To do this, I used: https://boardgame.io/

This library is fairly bare-bones (e.g. doesn't have any rendering) but also useful for designing a video game based around a board game.

The way it works is the library stores all of your game's state in a single object, and you interact with it via functions you write (moves, evets, etc)

At a core level, all your state is immutable. Instead of manipulating game state directly, you write functions that take in the previous game state, and output new state.

e.g. drawing a card might take in a list of cards, and return a new list of cards with one less.

This might sound strange, but is a very useful concept. Not just for boardgames, but this kind of pattern is commonly used in web development too.

The advantage is: when you write code to render your game, it can just take in a copy of the state and you're confident that none of the rendering will accidentally break some other area of the code.

Immutable game state can be very useful when designing complex systems such as a board game, where the play can interact with many pieces all at once, but must maintain a consistent set of rules.