Open IceSelkie opened 2 months ago
Here is an example game that includes a seed string, and terminates at turn 2 (but is a win if the seed is removed or set to "").
EDIT: I uploaded wrong file. This one is correct: example_hansim_game.json
Counterproposal: It should just reject a JSON with both seed and a deck, since it means that the end-user has a corrupt JSON and/or is confused.
Yes that is indeed a better solution. It solve the problem and doesn't assume that either should take precedence over the other.
can you submit a pr?
Upon further testing, it appears that the seed typically takes precedence over the passed deck, but sometimes the deck is required to meet certain requirements but is then ignored.
Cases:
{players:["a","b","c"], seed:"", actions:[play 1, ...], deck:[ ... correct 50 card deck ... ]}
Input: deck and no seed
Result: Replay starts normally, using passed deck. Expected.{players:["a","b","c"], seed:"p3v0s123", actions:[play 1, ...], deck:[ ... correct 50 card deck ... ]}
Input: deck and seed
Result: Replay starts normally. Expected.{players:["a","b","c"], seed:"p3v0s123", actions:[play 1, ...], deck:[ ... incorrect 50 card deck ... ]}
Input: deck and seed, seed matches actions but deck does not
Result: Replay starts normally, ignoring passed deck, using seed only. Unexpected. Passed deck can also be comprised entirely of blue 5s or any other card and still be fine.{players:["a","b","c"], seed:"incorrect-seed", actions:[play 1, ...], deck:[ ... 50 card deck matching actions ... ]}
Input: deck and seed, deck matches actions but seed does not
Result: Replay starts normally, ignoring passed deck, generating new deck from seed; The game is truncated at first move that doesn't match the generated deck. Unexpected.{players:["a","b","c"], seed:"p3v0s123", actions:[play 1, ...], deck:[]}
Input: seed and empty deck
Result: "[...] invalid target (card order) of 1." Unexpected: it has the seed and no deck.{players:["a","b","c"], seed:"p3v0s123", actions:[play 1, ...]}
Input: seed and no deck
Result: "[...] invalid target (card order) of 1." Unexpected: it has the seed and no deck.{players:["a","b","c"], seed:"p3v0s123", actions:[play 1, ...], deck:[ ... any deck with length not exactly 0 or 50 ... ]}
Input: seed and partial deck, or seed and too large of deck
Result: "The deck must have 50 cards in it." Unexpected: it ignores the deck when the seed is there in any other case...
Describe the bug When loading a replay from JSON, if a deck is specified AND a seed is specified, the deck is thrown away and the seed is used to generate a new deck.
To Reproduce
/copy
and click the copy link to get the game as JSONExpected behavior When there is a conflict between the seed and the passed deck, the passed deck should be assumed correct rather than the seed. (Such as when using Hanab.live to review a game from another site/program which doesn't use the same seed/prng/shuffle algorithm as Hanab.live, but deck is still accurate)