MOHAWK: RIVEN: Generate dome code as in original game #5470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates the code that randomizes the combination for the domes, so that the generated combinations correspond to those in the original game.
In the original game, the dome combination is not completely random; only the first number is one that can be learned in the school (range 2–10), the next two numbers are chosen from the range 11–15, and the last two numbers are chosen from the range 16–24. Presumably, this was done so that the code has approximately equal difficulty for every game.
Until now, ScummVM has generated completely random codes, which results in some games having very easy codes (when most of the numbers are below 10). Also, there's a 20% chance that the last number is 25, which never occurs in the original game's dome combinations.
Graphical summary of possible values for each position in the combination:
Research
To find the original game's dome combinations, I played the game from an old Riven executable (version 1.02). I made a script with AutoHotkey that creates a new game and saves it, and does this 2000 times. I then extracted the dome combination from each saved game. I analyzed the list of the 2000 combinations to find the possible numbers for each position, as well as how often these occur. The code in this pull request generates numbers with the same probability distribution as in the original game.
Distributions of the five digits in the 2000 combinations generated in the original game
Further confirmation can be found in old let's play videos or old websites where people posted their dome codes (from when the scummvm implementation did not yet exist). They correspond to the allowed possibilities mentioned above.