Jump to content

I do not know what is happening

Featured Replies

Ok, so I was making a simple python program that mimics simple evolutionary processes. When I run it multiple times I keep getting different results and I have no idea what is happening. Please help.

 

 

 

BasicEvolutionProgram.txt

Edited by ALine

Like we can read in Python documentation:

https://docs.python.org/3/library/random.html

random.seed( value ) initializes random number generator. But if it's not present in code, current time is used, but time is changing all the time.. ;) Different seed, different results from random.randInt()..

So, if you want to have each time the same results, use random.seed( 0 ); at the beginning of script.

It's reverse from C/C++ implementation of random number generator, in which you must execute srand( time() ); manually if you don't want to have exactly the same results.

 

Edited by Sensei

  • Author

Yep, you right. I get the same results each time now. Thank's Senpai. :D

On 25.07.2018 at 6:53 PM, ALine said:

Yep, you right. I get the same results each time now. Thank's Senpai. :D

I am glad to help you.

 

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.