Closed runar-rkmedia closed 1 year ago
This was mostly due to Undo (game.go) not setting the seed and state for the randomizer. This caused inconsistencies for games that used the seed. A test for this case has now been added.
Resetting the seed and state for randomized games are a bit more complicated. I'm thinking of ways to simplify this.
Currently, the game can be started with an initial seed. For randomized games, this seed is used at the start to generate the first cells from an empty board. the boardAtStart
-property is set after the cells have been generated.
Perhaps we could move setting the boardAtStart
to an earlier stage. This probably means that for randomized games, it will be an all empty board, and for challenge-games, it will always equal the template. By this logic, we can simply remove the whole property, and recreate the starting-board based on the rules and template.
There are actually a few properties that affect this:
seed
/ state
: We need to have these properties as they were at the beginning of the board. We currently save this value (storage: data-column), but for randomized games it is calculated after the initial cells has been set up. See startingCells
startingCells
: Currently only affects randomized games, but they affect the seed /state, since it uses the randomizer at the beginning to create this many randomized cells. This value should be added to the rule-table.boardAtStart
: As mentioned in my comment above, we might not need it. It is never needed for randomized games, only for challenge/tutorial-games. I suggest we remove this property, and remove the column. We can get the value from the game-template if needed.Should have been solved now, in one of the later changes. If I remember correctly, this was fixed in b324a9210ebed8fd7b92ded301ad347e78b2585d where the hash for a rule did not take into account every parameter. I've now added a test with reflection that should ensure that even as more fields are added, the hash of the id should include those new fields.
I've also thought about changing the structure of rules, to be a very much smaller structure, but I don't think it matters.
Investigation needed. Looks like it is related to the compaction of the instruction/replay
Api-response on failed hint: