PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Quick question 'bout Rand

Hi!

ecd->math->Rand(-1,1)

always gives the same number. How to randomise it for smart devices? srand() or something else?
Hi Ryumaster,

Have you tried SetRandSeed? Find more info here: http://www.edgelib.com/index.php?node=c ... etrandseed

Regards,
Oh! Thank you, I've missed it somehow.
If I use Rand() now, it is OK, but when I set min and max value, I'm always getting minimum values no matter what. Frr example below it is "-2". What I did wrong?


Code:

main_struct->ecd->math->SetRandSeed(ClassERTimer::Count());
npc6.x =npc6.x + main_struct->ecd->math->Rand(-2,2);
Hi Ryumaster,

Unfortunately, it's not possible to generate negative random numbers yet. That's why the function is returning the wrong values. A quick workaround is to generate a positive number, and subtract a value from it to make it negative.

Generating negative numbers will be possible in the upcoming EDGELIB version which is to be released very soon.