Note that there are some explanatory texts on larger screens.

plurals
  1. POAny patterns for modelling board games?
    text
    copied!<p>For fun, I'm trying to write one of my son's favorite board games as a piece of software. Eventually I expect to build a WPF UI on top of it, but right now I'm building the machine that models the games and its rules.</p> <p>As I do this, I keep seeing problems that I think are common to many board games, and perhaps others have already solved them better than I will. </p> <p>(Note that AI to play the game, and patterns around high performance are not interesting to me.)</p> <p>So far my patterns are:</p> <ul> <li><p>Several immutable types representing entities in the game box, e.g. dice, checkers, cards, a board, spaces on the board, money, etc.</p></li> <li><p>An object for each player, which contains the players resources (e.g. money, score), their name, etc.</p></li> <li><p>An object that represents the state of the game: the players, who's turn it is, the layout of the peices on the board, etc.</p></li> <li><p>A state machine that manages the turn sequence. For example, many games have a small pre-game where each player rolls to see who goes first; that's the start state. When a player's turn starts, first they roll, then they move, then they have to dance in place, then other players guess what breed of chicken they are, then they receive points.</p></li> </ul> <p>Is there some prior art I can take advantage of?</p> <p><strong>EDIT:</strong> One thing I realized recently is that game state can be split in to two categories:</p> <ul> <li><p><strong>Game artifact state</strong>. "I have $10" or "my left hand is on blue".</p></li> <li><p><strong>Game sequence state</strong>. "I have rolled doubles twice; the next one puts me in jail". A state machine may make sense here.</p></li> </ul> <p><strong>EDIT:</strong> What I'm really looking for here is the <em>best</em> way to implement multiplayer turn-based games like Chess or Scrabble or Monopoly. I'm sure I could create such a game by just working through it start to finish, but, like other Design Patterns, there are probably some ways to make things go much more smoothly that aren't obvious without careful study. That's what I'm hoping for. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload