Games
Games copied to clipboard
Dynamically inject randomness
When a game checks for saved randomness-state, it would be useful if while playing one could inject what one would want the value to be.
Something like the following:
- Game asks replayable for randomness-state, none is found
- Randomness calls the provided lambda to get a value but does not instantly return it to the game
- Randomness calls some user interaction or something that shows the result of the provided lambda and asks for what the value should be
- User interaction may either provide a manual value or choose to "pick another" which will call the provided lambda again and return a new response
This would require that the methods in replayable
be made into suspending functions, which would cascade through all games that are currently using randomness and throughout many places in the internal codebase.
I feel like it can be interesting to keep in mind, but not worth the effort right now.
A possible way to solve this would be to add a loop like this:
- Make a move, create some randomness (e.g. cards: 'a', 'b', 'c', 'd'. dice: 4 + 6)
- Ask which randomnesses you'd like to keep. (
cards
and/ordice
with the above example) - Remove the move and replay the rest of the game, then make the same action again. You will get new randomness