Le Twitch

Math.random vs game.rnd

Recommended Posts

game.rnd is an instance of Phaser.RandomDataGenerator which as well as having a lot of nice convenience methods, is also a seeded pseudo-random number generator, meaning you can get repeatable results from it. See this example: http://examples.phaser.io/_site/view_full.html?d=misc&f=repeatable+random+numbers.js&t=repeatable%20random%20numbers (check the developer console to see the output)

Share this post


Link to post
Share on other sites

game.rnd is an instance of Phaser.RandomDataGenerator which as well as having a lot of nice convenience methods, is also a seeded pseudo-random number generator, meaning you can get repeatable results from it. See this example: http://examples.phaser.io/_site/view_full.html?d=misc&f=repeatable+random+numbers.js&t=repeatable%20random%20numbers (check the developer console to see the output)

 

interesting. that's pretty cool

Share this post


Link to post
Share on other sites

It's great if you want to create 'random' levels which always play out the same, or use 'random' events in multiplayer games and ensure the same things happen on each client. Minecraft's world generation is driven by a seeded PRNG as well, which is why the same level seed will always produce the same virtually infinite world.

Share this post


Link to post
Share on other sites

It's great if you want to create 'random' levels which always play out the same, or use 'random' events in multiplayer games and ensure the same things happen on each client. Minecraft's world generation is driven by a seeded PRNG as well, which is why the same level seed will always produce the same virtually infinite world.

 

such an awesome feature. i'm surprised no one has asked about it yet til now

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.