ろいしんぶろぐ

乱数調整とか

XYのあれ

今更ながらXYの乱数について

英語部分はSmogonのXY RNG ResearchスレッドのBond697氏の投稿から。

 

I have a few things I've figured out that I thought might be worth putting up in here.
いくつか気付いたことでここに書く意味があるかもしれないと思ったものがある。


First of all, the RNG is the same as last gen. It's still seed = seed * 0x5d588b656c078965 + 0x0000000000269ec3. There's also still a Mersenne Twister, though it's an official one now too. It seems to be a little bit different than the one that GF has always used, but that's not a big deal. 

まず、乱数生成器は前作と変わっていない。まだseed * 0x5d588b656c078965 + 0x0000000000269ec3のまま。メルセンヌツイスタも公式のものが使われてる。ゲームフリークが使ってたものとほんの少し違うように見えるけど、あまり大きな問題じゃない。


What has changed is that there's not a function to build an array of entropy data anymore. So the initial seed is built in a different way. I'm not sure exactly how, but odds are it uses the AES generator built into the 3DS. There are functions on the DSi and 3DS for generating random numbers from the on-board AES hardware. In fact, on the DSi they have specific instructions to use the AES library's random numbers as a starting point for the main mathlib RNG. I don't know 100% for sure that that's the same case on the 3DS, but there's no reason for it to change at all considering that the 3DS is pretty secure in general. Certainly moreso than previous "DS" handhelds.

変わったことといえば、エントロピーデータの配列を作成するための機能がない。だから、初期seedは別の方法で作られてる。正確な方法はわからないけど、3DSに入ってるAES生成器を使ってる可能性が高い。DSi3DSにはAESハードウェアから乱数を生成する仕組みがあるし、実際DSiにはAESライブラリの乱数をメインmathlib乱数生成器の始点として使うための特定の命令がある。3DSでも100%同じかどうかはわからないけど3DSのセキュリティの高さを考えると仕組みを変える理由がない。


Anyway, what that means is that we may not be able to ever RNG the way we're used to ever again. There's certainly a chance I'm wrong about that last bit, and I hope I am. Obviously I'm not 100% sure, but if what I was saying wasn't pretty solid, to me at least, I wouldn't mention it at all until I know more. 

いずれにせよ、これが意味することは、以前までやっていたような乱数調整の方法ができないかもしれないということ。最後のほんの少しを私が誤解している可能性も確かにあるし、それを望んでいる。明らかに私は100%正解ではないけど、セキュリティの堅さが少なくとも私にとって堅いものでないなら、もっと知るまでこれについて言及しないだろう。

 

 

Well, I just confirmed that the Mersenne Twister is initialized by default by generating random bytes via the AES engine. I think we're out of luck.

あぁ、メルセンヌツイスタがAESで作られたランダムバイトで初期化されてることを確認してしまった。あきらめよう。

------------------------------------------------------------------------------------------------------

 

初期seed決定にエントロピーデータが使われていないので、みんなの悪者Timer0さんの出番は今回はないです。1000個とかまだ信じてる人いるのかな

 

2015/01/04

Bond697氏の書き込みで初期seedの決定に現在のナノ秒が使われていることが判明しました。

だいたいフレームの1000万倍のスピードですね。