X Tutup
Skip to content

Fix intro screen ship randomness#5896

Merged
sturnclaw merged 1 commit intopioneerspacesim:masterfrom
zonkmachine:shipshuffle
Aug 21, 2024
Merged

Fix intro screen ship randomness#5896
sturnclaw merged 1 commit intopioneerspacesim:masterfrom
zonkmachine:shipshuffle

Conversation

@zonkmachine
Copy link
Member

Fix PiRngWrapper to use the full range of the random object. std::shuffle expects the range provided by max().
See explanation here.

Fixes #5659

@impaktor
Copy link
Member

Makes me nervous to see the fix is to remove the maxValue variable, but if it works, ¯\_(ツ)_/¯. I'll give this a try in a bit.

@impaktor
Copy link
Member

Yep, I confirm, this fixes the issue.

@sturnclaw
Copy link
Member

PiRngWrapper in this file provides what the standard calls a UniformRandomBitGenerator - i.e. std::shuffle just wants a random integer in the inclusive range [ PiRngWrapper::min(), PiRngWrapper::max() ] and will take that integer and generate a random index into the shuffled range itself. This is the computationally simplest method of addressing the bug and removes a superfluous modulo operation.

@sturnclaw sturnclaw merged commit 732f553 into pioneerspacesim:master Aug 21, 2024
@zonkmachine zonkmachine deleted the shipshuffle branch August 21, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ship spinner always starts on same ship

3 participants

X Tutup