LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Controlling Number Randomization

Root / FAQs / [.]

ahavasandwichCreated:
I've come across a problem I can't figure out. I need to be able to get both 3ds systems to use the same random number sets from RND(). It's been a quite few months since I've worked on this problem, so I can't remember everything I tried. Here is a simple tile tapping game I was working on a months ago: K3P5X4D. It's setup so that the tile patterns are random for each player. Both players are supposed to see the other players progress in clearing the tiles, but it doesn't work right because the random numbers are not the same for both systems. The game does work. It can tell who finished first or second... just the visuals don't work as intended. Solving this problem will help the other multiplayer games I'm making. Ideas?

RANDOMIZE 0,seed

RANDOMIZE 0,seed
Could you give a brief explanation of that command? I'm not sure how to use it.

The seed is a number that leads to the same sequence of random numbers to output. So, if you had a seed of 1, you'd get the same sequence of random numbers as another 3ds with a seed of 1.

...hmm. Thanks. I'll tinker with this tonight.

Because I have the Japanese version of Smilebasic and I don't read Japanese, I didn't know how to use randomize() properly and thought it didn't work, so I ported a simple RNG - the Mersenne Twister - to SB: http://smilebasicsource.com/page?pid=95 It works well, but is a lot slower than the built-in rnd() function.

I thought of trying something like that (more like a really vague idea in my head), but it seemed like a lot of work. Really cool idea though. I didn't really know about this algorithm until now or how widespread the use of the Mersenne Twister is. I did end up getting RANDOMIZE to work with two systems. I just set it to: RANDOMIZE 1,1. It did the trick just fine.