I’m tinkering with a framework to implement board games in c# (similar to boardgame.io in JS) part of that is getting a handle on turn structures. (What is a round? what is a turn? who gets to go when? etc)

So I’ve gone through all my games and looked for recurring patterns and exceptions to them and here’s what I’ve collected so far:

  • There’s always at least one structure that handles how player act or “take turns”
    • the vast majority of games do traditional turns - one player does things, then then another,
      • usually in a fixed order maybe going forward some times and backward other times.
      • sometimes the order can change
      • also possible are:
        • turn order decks (you don’t know who goes next but know that everyone gets a turn)
        • action tracks (where whoever is furthest back gets to go next, possibly resulting in an uneven number of turns)
        • the next player is dependent on an action of the previous player
    • it’s also possible that players can play simultaneously
      • a complete free for all is pretty common
      • it’s also possible that players can act freely to some point, then have to wait for everyone else to catch up
    • another consideration, both for concurrent and sequential play is that sometimes some players are excluded (Codenames for example lets all guessers on a given team act concurrently but not the leaders or the other team)
    • there can be different rules at different times (like first picking a tile in sequence then everyone can place it simultaneously)
    • and there can be nested rules (like every player gets to run an auction but in every auction each player get’s to bid as well)
    • one relatively common special case is where certain actions on a player’s turn result in decisions being needed from other players (trades, attacks, “each player …” effects)
  • there are often structures that simply subdivide another structure
    • they can occur at any level. A game may be divided into “setup” and “play”, a round could be divided into different phases but a single player’s turn might also be divided into smaller steps.
    • these subdivision usually restrict / specify which actions are allowed in them
    • these subdivision often come with limits like: you can only do N actions
    • sometimes a player can “pass” sometimes they cannot

I’m wondering if anyone can think of an instance that is not covered by these “rules”.

  • Rather than trying to define abstractions for turns and rounds, maybe you could implement the game state (and possibly individual players) as a finite state machine.

    In this model, the way you set up the states and transitions for a particular game will capture its idiosyncracies in turn and round order.

    •  Kempeth   ( @Kempeth@feddit.de ) OP
      link
      fedilink
      English
      311 months ago

      That’s what I’m currently doing. But I’m not yet sure if a straight FSM is such a great fit. There’s not good mapping for the concept of turns in a single level FSM. You can do it of course but if you have multiple such models or nested instances where each player gets to react to specific actions on each player’s regular turn, each of them is gonna push the the properties needed to manage that into the shared state.

      So I’m currently at nested state machines. This way the implementation details for alternating between players can be hidden from the higher level states.