Building a Domain Model in Elixir Part 2

I have now got a bit further with my domain model of the Pandemic game. There are very few complex examples of functional domain models. The problem is that problems that benefit from this approach are normally too complex to make a good example.

Pandemic is a complex cooperative board game. Players race to find cures for 4 diseases. There are lots of ways to lose. It’s a Euro game so it has built in termination options. You lose if:

– You can’t draw from the player deck

– On the 8th outbreak

– If you run out of any one of the 4 disease counters and are unable to place one.

The team wins if all 4 diseases have a cure.

This now has a model of the cities with the links between them. The this was test driven with some useful checks. I used exhaustive property tests to check the link validity. This includes checks that all links are reversable, that no city links to itself and that there are no orphan cities. These caught a number of cut and paste errors.

The next part is a model of the board state. This includes the initial draw of cards, the infection of new cities and the cascade of an outbreak.

This follows an Elixir pattern of using functions in modules using struts. Every non-query function takes and returns the struct defined in the module. This makes composition much easier.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s