Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by doublelift41 · Oct 09, 2020 at 04:48 PM · randomseed

How to reset Random.InitState(x)

   Random.InitState(42);
         noiseValues = new float[5];
         for (int i = 0; i < noiseValues.Length; i++)
         {
             noiseValues[i] = Random.value;
             Debug.Log(noiseValues[i]);
         }
     }

console log: 0.988, 0.588, 0.436 , 0.343, 0.463

As is known, it always gives the same values. Can I create a different result with the same seed?(like Random.InitState(42) ) Can I reset the random's memory? Also, I could not grasp what exactly the seed mean. I would be glad if you could explain.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Oct 09, 2020 at 05:20 PM

The point of calling Random.InitState with a seed is to reset the random number generator and to put it into one particular initial state based on the seed. When you call InitState with a particular seed, you get always the same sequence of numbers back.


Hopefully you know that you can not generate true random numbers with a computer unless you have special hardware that can generate random numbers based on some external source. All random number generators we use in software are pseudorandom number generators (PRNG). A certain PRNG always generates the same sequence / cycle of numbers. The seed essentially puts you somewhere in that sequence. Most PRNGs have huge sequances.


I'm not really sure what you're asking or what problem you want to solve. However passing the same seed to InitState will produce the same sequence, always. If you want a different sequence, use a different seed. To get seemingly random numbers the Random class is usually automatically seeded with the current date and time. Of course when you call InitState manually you reset the generator into the same one state based on your seed.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Max_Bol · Feb 13, 2021 at 05:01 PM 0
Share

While, in most cases, it's true that a software usually uses a PRNG for generating random numbers, it's not true that it requires a special hardware to generate a true random number. There RNGCryptoServiceProvider class (in .NET) allows you to generate a true random number generator, but it's not as easy to setup as common PRNG -based classes.

Here's the link toward an example of a true random generator created with Windows' .NET: Link

avatar image Bunny83 Max_Bol · Feb 13, 2021 at 08:47 PM 0
Share

No, that's not true at all. The RNGCryptoServiceProvider generates random numbers which are considered cryptographically secure. They are still just pseudo random numbers. In an ordinary .NET environment the algorithm behind that class is based on windows CryptGenRandom function. In an .NET Core environment it's based on the BCryptGenRandom function.


The reason why it is considered cryptographically secure is because it includes many different factors of the machine, the current process and the hardware to calculate a pseudo random number. This makes it much harder to know or predict the state of the generator as it's almost impossible to know or capture all those features at once at the same time. However it is still just a PRNG and has nothing to do with "true" random or to be "more" random which in itself doesn't make much sense.


I'm not sure if that class will use specialized hardware if available. If it doesn't at the moment it most likely will in the future. Though the fallback will always be a PRNG solution similar to the current one. As I said, computers can not generate random numbers or random events without an external source.


Some modern motherboards may have a crypto processor. However it's not that they can produce true random numbers but their exact implementation and internal state is hidden which provides the security through obscurity and make the actual crypto process more resilient to tampering.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

144 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I seed the random number generator myself and still get pseudorandom values? 2 Answers

Generate minecraft alike terrain 0 Answers

Random.Range affects the Random.seed 1 Answer

Mulitple spawn points with random seed. 3 Answers

How do you save a seed? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges