01-30-2005, 10:01 PM
While planning to develop a game in QB, how do we re-seed the random number generator if a player wishes to play again with the same sequence? The code below reveals the second sequence is differed from the first.
Is this a Microsoft way to generate a different sequence in spite of trying to re-seed the RNG?
I know several solutions such as writing your own RNG or putting sequence in an array. It is not a good practice, tho'.
Code:
DIM seed AS LONG
CLS
seed = TIMER
RANDOMIZE seed
FOR i = 1 TO 3
PRINT INT(RND * 9999) + 1
NEXT
PRINT
'Re-seed
RANDOMIZE seed
FOR i = 1 TO 3
PRINT INT(RND * 9999) + 1
NEXT
I know several solutions such as writing your own RNG or putting sequence in an array. It is not a good practice, tho'.