state value already has Player value and we could use it. However, there is a problem because playTurn method may create new world but doesn't updatePlayer value.
I think GameState record should be implemented as:
Such version won't cause problems with incorrect references to the actual player. Finally, we can remove player parameter from playTurn method and simplify a liitle bit main:
Love the detailed suggestion. I'm aiming to get the game simulation further along and have a unit-test focused article up this weekend.
On the GameState.Player suggestion - yeah, I did find that issue in my article3 branch I'm working on for the next article and have made a fix for that issue.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the great series! Keep up the good work.
By the way, I found a little issue in the current implementation. It's related to
GameState
record and how it's used.First of all, additional
player
value actually isn't needed here:state
value already hasPlayer
value and we could use it. However, there is a problem becauseplayTurn
method may create new world but doesn't updatePlayer
value.I think
GameState
record should be implemented as:Such version won't cause problems with incorrect references to the actual player. Finally, we can remove
player
parameter fromplayTurn
method and simplify a liitle bitmain
:Love the detailed suggestion. I'm aiming to get the game simulation further along and have a unit-test focused article up this weekend.
On the
GameState.Player
suggestion - yeah, I did find that issue in myarticle3
branch I'm working on for the next article and have made a fix for that issue.