Difference between revisions of "SIBR:Random number generator"
(Add RNG details) |
(Birds) |
||
Line 45: | Line 45: | ||
blood = floor(rand()*13), if s12 or later | blood = floor(rand()*13), if s12 or later | ||
coffee = floor(rand()*13), if s12 or later</pre> | coffee = floor(rand()*13), if s12 or later</pre> | ||
+ | |||
+ | ==Birds== | ||
+ | During [[Birds (weather)|Birds weather]], the game log will occasionally display a random bird-related message. Prior to season 7, these messages were displayed based on a series of consecutive rolls: | ||
+ | Display bird message? (rand() < 0.05) | ||
+ | Number of birds (2-9999) | ||
+ | Bird message (0-18) | ||
+ | |||
+ | The displayed message is selected from the following list: | ||
+ | |||
+ | {| class="wikitable" | ||
+ | | 0 || There's just too many birds! | ||
+ | |- | ||
+ | | 1 || Don't feed the birds | ||
+ | |- | ||
+ | | 2 || Several birds are pecking... | ||
+ | |- | ||
+ | | 3 || The birds are paralyzed! They can't move! | ||
+ | |- | ||
+ | | 4 || Where did these birds come from? | ||
+ | |- | ||
+ | | 5 || These birds hate Blaseball! | ||
+ | |- | ||
+ | | 6 || They're clearing feathers off the field... | ||
+ | |- | ||
+ | | 7 || This is too many birds. | ||
+ | |- | ||
+ | | 8 || I hardly think a few birds are going to bring about the end of the world. | ||
+ | |- | ||
+ | | 9 || The birds are after the children... | ||
+ | |- | ||
+ | | 10 || Do these birds have souls? | ||
+ | |- | ||
+ | | 11 || BIRD NOISES | ||
+ | |- | ||
+ | | 12 || The birds are very loud! | ||
+ | |- | ||
+ | | 13 || Have you ever seen this many birds? | ||
+ | |- | ||
+ | | 14 || What are we gonna do with all these birds | ||
+ | |- | ||
+ | | 15 || Oh dear Gods... | ||
+ | |- | ||
+ | | 16 || The birds continue to stare. | ||
+ | |- | ||
+ | | 17 || The birds are mad at you. You specifically. You know who you are. | ||
+ | |- | ||
+ | | 18 || [NUMBER] Birds | ||
+ | |} | ||
+ | |||
+ | Following [[Third_Strike#The_Third_Strike|the Third Strike]] at the end of season 6, birds gained the ability to peck players free from shells; research into how this changed the above algorithm is ongoing. | ||
==See also== | ==See also== |
Latest revision as of 00:45, 5 September 2021
The Blaseball backend uses a pseudorandom number generator called XorShift128+ to generate random values. These values are used for a variety of purposes, including attributes for newly-hatched players and determining event outcomes during games.
XorShift128+ is not cryptographically secure. With three known consecutive outputs, the RNG state can be fully reconstructed,[1] allowing us to determine what all subsequent values would be. Furthermore, the algorithm is fully reversible so we can determine all preceding values as well.[2] Using this technique, we can select a player whose earliest recorded stats were unchanged since generation, recover the RNG state from when that player was created, and examine the surrounding values to find stats for other players that were created at the same time.
RNG details
XorShift128+ uses two 64-bit state variables, which we call s0
and s1
. Knowing the value of these for a given output value is sufficient to recreate the RNG output both forward and backward from that point. However, the Blaseball sim uses Node.js running on the V8 Javascript engine, which introduces a complication: XorShift128+ is used to pre-generate a batch of 64 random values, which are then returned in reverse order. When correlating known values with the expected RNG output, we must determine where the boundaries are for these blocks and reverse each set of 64 values.
Therefore, we use a triple of (s0, s1, offset)
to fully describe a point in the output stream, where offset
is the index within a 64-value block. For example, (78357228809041901, 13627021481113128807, 29)
gives us the first of the series of rolls used to generate Lars Taylor prior to Season 1.
Player generation
When a new player is created, their attributes are generated by a series of consecutive rolls in the following order:
first name last name thwackability moxie divinity musclitude patheticism buoyancy baseThirst laserlikeness groundFriction continuation indulgence martyrdom tragicness shakespearianism suppression unthwackability coldness overpowerment ruthlessness omniscience tenaciousness watchfulness anticapitalism chasiness pressurization cinnamon, if player has 'cinnamon' field soul = floor(rand()*8+2) allergy = rand() < 0.5, if player has 'peanutAllergy' field fate = floor(rand()*100), if player has 'fate' field ritual (value unknown), if s12 or later blood = floor(rand()*13), if s12 or later coffee = floor(rand()*13), if s12 or later
Birds
During Birds weather, the game log will occasionally display a random bird-related message. Prior to season 7, these messages were displayed based on a series of consecutive rolls:
Display bird message? (rand() < 0.05) Number of birds (2-9999) Bird message (0-18)
The displayed message is selected from the following list:
0 | There's just too many birds! |
1 | Don't feed the birds |
2 | Several birds are pecking... |
3 | The birds are paralyzed! They can't move! |
4 | Where did these birds come from? |
5 | These birds hate Blaseball! |
6 | They're clearing feathers off the field... |
7 | This is too many birds. |
8 | I hardly think a few birds are going to bring about the end of the world. |
9 | The birds are after the children... |
10 | Do these birds have souls? |
11 | BIRD NOISES |
12 | The birds are very loud! |
13 | Have you ever seen this many birds? |
14 | What are we gonna do with all these birds |
15 | Oh dear Gods... |
16 | The birds continue to stare. |
17 | The birds are mad at you. You specifically. You know who you are. |
18 | [NUMBER] Birds |
Following the Third Strike at the end of season 6, birds gained the ability to peck players free from shells; research into how this changed the above algorithm is ongoing.