If we seed c++11 mt19937 as the same on different machines, will we get the same sequence of random numbers

前端 未结 3 1239
清歌不尽
清歌不尽 2020-11-30 15:19

Inspired from this and the similar questions, I want to learn how does mt19937 pseudo-number generator in C++11 behaves, when in two separate machines, it is seeded with the

3条回答
  •  粉色の甜心
    2020-11-30 15:36

    Any pseudo RNG which takes a seed will give you the same sequence for the same seed every time, on every machine. This happens since the generator is just a (complex) mathematical function, and has nothing actually random about it. Most times when you want to randomize, you take the seed from the system clock, which constantly changes so each run will be different. It is useful to have the same sequence in computer games for example when you have a randomly generated world and want to generate the exact same one, or to avoid people cheating using save games in a game with random chances.

提交回复
热议问题