So I made this other game... (Nonaga)

Thanks for the feedback!

I implemented your suggestion as follows:

type alias Player =
    { player : Color, tokens : Set Platform }


type alias Model =
    { currentPlayer : Color
    , turnPhase : TurnPhase
    , board : Board
    , players : List Player
    , lastMovedPlatform : Platform
    , selectedToken : Maybe Token
    , selectedPlatform : Maybe Platform
    }

In practice I have the following problems with this model:

  • I still can’t directly access a player’s tokens (like the Dict Color (Set Platform) would have).
  • It is more involved to can’t check if a platform is empty and I loose the constraint of “one token max on a platform”.
  • This introduces some additional nesting that makes the update a bit more complex.

The pros being:

  • This does seem to model the game better, with improved names and straightforward types.
  • It avoids the Dict wrangling which is quite nice, though.
  • Domain functions dealing with Player type are nice.

I am considering going back to a Dict Platform Color, but with nice helper functions to get a player’s set of tokens, move the token, etc… And see which I like better

This is clearly overthinking it, but well, I have time and the goal is to improve :slight_smile:

The updated code is here : https://ellie-app.com/gNx2FTFYR3za1

2 Likes