#7184 - Lupin - Wed Jun 11, 2003 6:42 pm
What's the best way to do this on the GBA?
#7191 - Touchstone - Wed Jun 11, 2003 9:33 pm
http://forum.gbadev.org/viewtopic.php?t=873
http://forum.gbadev.org/viewtopic.php?t=66
http://forum.gbadev.org/viewtopic.php?t=1154
http://forum.gbadev.org/viewtopic.php?t=1272 (additional)
Perhaps there should be a notice on the front page about the search functions for this forum. Not that I really mind but when a topic has been discussed atleast three times before....
_________________
You can't beat our meat
#7192 - Daikath - Wed Jun 11, 2003 9:42 pm
LOL :)
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?
#7210 - tepples - Thu Jun 12, 2003 10:11 am
Added to FAQ.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#50275 - NighTiger - Sun Aug 07, 2005 1:21 pm
I guys,
I would like to know if the numbers used are "special" number.
Why I did read moretime the number 69069 or 289301 in most of example code?
tnx
#50277 - tepples - Sun Aug 07, 2005 1:54 pm
Some numbers used in a linear congruential generator have better statistical properties than others.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#50337 - Zapf_Bandit - Mon Aug 08, 2005 8:54 am
uint16 random ( uint16 range = 0 )
{
static uint32 randSeed = 0xB0B15BAD;
randSeed *= 0x0019660D;
randSeed += 0x3C6EF35F;
return ((randSeed >> 16) % range);
}
This works really well for me... I haven't done any statistical analysis on it but I got the constants from numerical recipies so I trust them. If you can shove a random() call at the end of your main loop this will help with seeding.
#50349 - jma - Mon Aug 08, 2005 3:40 pm
While non-scientific, a decent way of testing your random number generator is to fill the screen with pixels. But do it in a very specific way. As you watch the pixels show up, try and check for patterns that emerge (diagonal lines with no pixels in them), or pixels that never get filled. Also, if a pixel is already filled, change its color to something else, which should help you in noticing numbers that are getting chosen more often than others.
Code: |
while(1) {
x = my_rand(SCREEN_WIDTH);
y = my_rand(SCREEN_HEIGHT);
p = get_pixel(x, y);
if (p == BLACK)
p = RED;
else
p = BLUE;
put_pixel(x, y, p);
} |
There are more convoluted methods of testing a random number generator, but for the type of generator we're talking about (in this thread), and for the purpose it is being used (a game), this method of testing is simple and works.
Jeff M.
_________________
massung@gmail.com
http://www.retrobyte.org
#50351 - NighTiger - Mon Aug 08, 2005 3:54 pm
this's very good because I would like to make a "tv not syntonized" effect