It looks to me like the game uses the built-in JS random number generator (RNG). As this is not seedable, it requires all the random things (mainly the card deck) to be saved/passed to recreate a game. I mentioned this in #1723 but thought it should get its own topic.
Currently, you cannot (certainly not easily) play a game on one server and play the same game on a different server. This would be simple if we had a seedable RNG.
A far-fetched potential issue would be where a multi-player game is hosted by one of the players. This player could pre-deal any number of games to ensure they got at least the best starting cards. This is fixable by getting part of the seed from each player.
A seed wouldn't be enough -- you need to have uniquely-compatible code-bases. If someone changes dealing order such that cards are dealt one at a time to each individual player rather than deal all n cards at the same time, there's no guarantee of repeatability, and I would be reluctant to provide such a guarantee.
There are plenty of parts of the system that do use a seeded random number generator, by the way.
We could of course add it since that's what's happening under the hood when you start a predefined game (aside from the fact that it also sets all the game options). But as with predefined games, a change in the code can make the game different.
I wouldn't mind if we added a "Enter a game seed" input but, as @kberg said, we won't guarantee you it'll work properly between versions.
+1 for enter a game seed.
I just realized I probably need to add the Turmoil deck and colony selection. Anything else?
@SliceOfBread random first player, randomize milestone and award, shuffle board tiles.
What's the end goal of this change? It's possible that whatever is built would work in the short term, but puts a reliability burden on ongoing maintenance and change. For example, someone reading this project later on could read this code and say "Oh! Why are there three RNGs? It doesn't make sense." And then consolidate them into one. And then someone else comes along and reorders shuffling (just like I did with tile behavior, and even with the way decks are structured.)
Is this something that this project should continue to support ongoing? If so, then there should be enough comments to describe the feature it is supporting and tests to validate the use cases and support it when we organizationally refactor.
@kberg I copied your question to here as this is the appropriate place for discussion of this feature.
Main Goal: As previously stated, portability of games across servers. I will include in this the need to only have the game seed to reproduce a game if the database is corrupted somehow. As people find/report bugs, it would be MUCH easier to reproduce them if the game could be reproduced on another server with a simple seed.
As things are not currently seeded, I must surmise that all the data needed to duplicate a game is store in the db. All this can be eliminated as we have the seed (gameId) already.
It is easy enough to add comments on why this change was added.
I will note that in a quick perusing of the code that creates a randomly tiled board, a seed is used but this seed is generated using an unseeded rng. What's the point of this seed? It doesn't seem to be used in recreating duplicate games.
For such a minor change, I really don't understand the hostility to doing this nor do I have interest in dealing with that. Closing.
Wait - what? Is that because I didn't respond? Tell me, because I'm very sorry if my delay was the cause of your response.
But I'm going to assume it _was_ me, and respond.
Why do you think you saw the response as one of hostility rather than merely objection and scrutiny? If it was the delay, well, I'm not going to be doing code reviews every night. I don't know why nobody else picked up on the code review, either. Not having an interest in dealing with hostility, well, I get that, but I think that accusation is unfair. I wish, instead of closing the PR without notification you made an attempt to contact me, another developer, on this or Discord.
A final point: I don't think the change is minor. I think the change will be hard to support. But I could be wrong and will chat privately with one of the other devs to see if he feels my assessment or messaging was inappropriate.
If the goal of this issue is to allow taking a game from one server and being able to play with the same initial cards on another server it may make sense to take a step back and leave out the seedable RNG solution for a moment. The change provided was small but as per @kberg points it may not necessarily always work as we gain more cards or make refactors to the dealer. Say for example we changed the order of cards within the deck. This would inadvertently break the seeded games unbeknownst to anyone changing the ordering of the cards. I don't think there will be a straight forward way to take a game and serialize it into some small number that can then be used to regenerate those game settings.
If the goal is to be able to duplicate a game we could instead allow a user to download the initial game JSON. If that JSON were then uploaded we could attempt to reconstruct the game setup and inform the user if there were trouble. This would be similar to the cloning a game functionality but the difference would be we would allow the user to download the initial JSON. Instead of entering a seed the user would upload this file next to the create game button. Even this is going to get out of sync and an older version of the JSON may not work with some update. A crafty individual could potentially update the JSON though to work with the latest version if they had a popular game setup.
The current seed system stops working as soon as the code get changed anyway. So the proposed randomization using gameid is not promising more than the current method. It is fine if things get out of sync. Perhaps it will be useful to attach build version to the game-id to verify that seed is used on the same version.
@SliceOfBread, I am with you. This is definitely an improvement (and that certain criticisms are not constructive).
First, it has nothing to do with response time.
Second, I have previously noted, a seed is preferable for for reporting bugs, reproducing those bugs on another server and then testing that bugs are fixed. JSON is unwieldy for this purpose though I do not disagree that a seed and stable starting position are both necessary for reproducibility.
Third, adding seedable RNGs does nothing to anything that already exists without a way to enter that seed. To wit, seeds are already used in some parts of the code.
Fourth, the seedable RNG code already existing in the code (the board tile randomizer) appears to have been written by @kberg. There is no explanation of why a seedable RNG was used or any obvious reason to keep the seed. I did not see any pushback to the use of this SRNG.
Perhaps the fault lies with me and the title of this issue. Perhaps "Replace RNGs with seedable RNGs" would have coasted through and then we could have a separate issue of whether/how to use these seeds to reproduce games.
In the end, I came to work on something, not to argue about seeded RNGs. It will be better and easier for me to branch off here and work on what I originally came here for. That is why I closed the issue.
FYI, I didn't add it. I moved it outside of its original implementation to
reduce duplication, but someone else added that algorithm.
On Fri, Oct 30, 2020 at 11:21 AM SliceOfBread notifications@github.com
wrote:
First, it has nothing to do with response time.
Second, I have previously noted, a seed is preferable for for reporting
bugs, reproducing those bugs on another server and then testing that bugs
are fixed. JSON is unwieldy for this purpose though I do not disagree that
a seed and stable starting position are both necessary for reproducibility.
Third, adding seedable RNGs does nothing to anything that already exists
without a way to enter that seed. To wit, seeds are already used in some
parts of the code.
Fourth, the seedable RNG code already existing in the code (the board tile
randomizer) appears to have been written by @kberg
https://github.com/kberg. There is no explanation of why a seedable RNG
was used or any obvious reason to keep the seed. I did not see any pushback
to the use of this SRNG.Perhaps the fault lies with me and the title of this issue. Perhaps
"Replace RNGs with seedable RNGs" would have coasted through and then we
could have a separate issue of whether/how to use these seeds to reproduce
games.In the end, I came to work on something, not to argue about seeded RNGs.
It will be better and easier for me to branch off here and work on what I
originally came here for. That is why I closed the issue.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bafolts/terraforming-mars/issues/1733#issuecomment-719616933,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AADE6KOWYD4NEAWPXRCJUSLSNLKZNANCNFSM4S5CNMIQ
.
Could we keep an issue open with a more general heading like "Record exact game configuration including deck ordering, for replay"?
An entire project deck can in theory be recorded in just 430 characters of base64-encoded text.