Last active
August 29, 2015 13:57
-
-
Save odanado/9396433 to your computer and use it in GitHub Desktop.
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
def nextLCG(seed) | |
seed = seed * 0x5D588B656C078965 + 0x269EC3 | |
seed = seed % 0x10000000000000000 | |
return seed | |
end | |
def prevLCG(seed) | |
seed = seed *0xDEDCEDAE9638806D+0x9B1AE6E9A384E6F9 | |
seed = seed % 0x10000000000000000 | |
return seed | |
end | |
Natures = ["がんばりや", "さみしがり", "ゆうかん", "いじっぱり", "やんちゃ", "ずぶとい", "すなお", "のんき", "わんぱく", "のうてんき", "おくびょう", "せっかち","まじめ", "ようき", "むじゃき", "ひかえめ", "おっとり", "れいせい", "てれや", "うっかりや", "おだやか", "おとなしい", "なまいき", "しんちょう", "きまぐれ"] | |
def func(i,seed) | |
# http://www.smogon.com/forums/threads/past-gen-rng-research.61090/page-38#post-4303176 | |
nature = Natures.at(((seed>>32)*0x19)>>32) | |
seed = prevLCG(seed) | |
seed = prevLCG(seed) | |
seed = prevLCG(seed) | |
seed = prevLCG(seed) | |
pid = seed >> 32 | |
seed = nextLCG(seed) | |
r = seed >> 32 | |
pid = (pid & 0xFFFFFF00) | (((r*0xF6)>>32)+8) | |
pid ^= 0x10000 | |
puts "#{i} #{pid.to_s(16)} #{nature} #{pid%6}" | |
end | |
seed = 0x0 | |
puts seed.to_s(16) | |
for i in 0..100 do | |
func(i,seed) | |
seed = nextLCG(seed) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment