-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e10e4a6
commit b9091c2
Showing
3 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
| ||
namespace PokemonPRNG.Xoroshiro128p.BDSP | ||
{ | ||
public static class BDSPExtension | ||
{ | ||
public static (ulong S0, ulong S1) Initialize(this uint seed) | ||
=> (seed.Temper(0x9E3779B97F4A7C15), seed.Temper(0x3C6EF372FE94F82A)); | ||
private static ulong Temper(this uint seed, ulong state) | ||
{ | ||
var value = seed + state; | ||
value = 0xBF58476D1CE4E5B9 * (value ^ (value >> 30)); | ||
value = 0x94D049BB133111EB * (value ^ (value >> 27)); | ||
return value ^ (value >> 31); | ||
} | ||
|
||
// maxなのにmod取ってるの馬鹿です。 | ||
public static uint GetRand(ref this (ulong S0, ulong S1) state, uint max = 0xFFFFFFFF) | ||
=> (uint)(Xoroshiro128p.GetRand(ref state) >> 32) % max; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters