Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
17 user(s) are online (12 user(s) are browsing Forum)

Members: 0
Guests: 17

more...


Browsing this Thread:   1 Anonymous Users






Re: need good randomization...
#3
Just can't stay away
Just can't stay away


See User information
Thanks. Code work very good.

Posted on: 2011/4/29 6:51
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: need good randomization...
#2
Home away from home
Home away from home


See User information
@mrdark
If you want Rnd() to return different 'random' values each time your program is run, then you need to initialise it with a different seed value each time it is run. The easiest way to do this is to use the current time/date:

<pre>MODULE 'std/pTime'

PROC main()
DEF i

->initialise Rnd()
Rnd(-CurrentTime() !!VALUE)

->demonstrate it is really random
FOR i := 1 TO 10 DO Print('\d. Rnd(100)=\d\n', i, Rnd(100))
ENDPROC</pre>

Posted on: 2011/4/28 14:17

Edited by PortablE on 2011/4/28 15:31:30
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


need good randomization...
#1
Just can't stay away
Just can't stay away


See User information
I need randomize internal seed for rnd() procedure but initializing it with constant negative number is not an option for me. Just I ask about 1-2 code lines for randomizing - maybe using time (how modules I need add?)? It's no need be as good as for cryptography but should be short and working....

Posted on: 2011/4/28 10:19
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project