NO

Author Topic: Better random and test routine  (Read 6003 times)

Rainbow Sally

  • Guest
Better random and test routine
« on: January 19, 2005, 10:04:08 am »
[This post is obsolete.  There's a better random in the OOPz lib which is both faster and has a better spread of numbers.  In addition, there's a subfunction to get randomized rgb values. It's in the OOPz0p04\OOPz\Utils folder. Feb 06, 2005 -RS.]

I'm not sure how significant it is, but I did notice that the ratio of repeating numbers for a series of 10,000 random numbers ends up almost exactly 1/e every time.

You can see that there's no floating point stuff in any of the Random algorithm at all, so this is probably significant.

This was very interesting to do in Asm because it wasn't until now that I realized that if a return value is a struct, its address is pushed on the stack unbeknownst to anyone but the compiler.  Neat trick, actually.

Anyway, the demo should be fun and I do think you'll like it better than srand and rand.  I sure do!!

Gerome

  • Guest
Re: Better random and test routine
« Reply #1 on: January 19, 2005, 11:47:08 am »
Hi,

Sure if it worked... i really love the Access Violation under my XP SP1 :(

Rainbow Sally

  • Guest
Re: Better random and test routine
« Reply #2 on: January 19, 2005, 07:09:24 pm »
Thanks for the bug report, Gerome.

Did you compile it with the included PPJ?  If you didn't there might be a problem in the link step.

Another possibility might be to add some fluff to pad it out to at least 4K.  Vortex posted some info that suggests that newer Win systems simply cannot survive without a bit of waste.  

If that's not it and if you are willing to risk subjecting your computer to another round of abuse :-) here's the exe as it should compile.

(See attached.)

Quote from: "Gerome"
Hi,

Sure if it worked... i really love the Access Violation under my XP SP1 :(


Let me show you what I see.  This is at the end of the test.

Code: [Select]

3397    found 2 times
3132    found 2 times
9000    found 2 times
7006    found 2 times
9366    found 2 times
3239    found 2 times
2440    found 2 times
1653    found 2 times
3290    found 2 times
2976    found 2 times
3801    found 2 times
4910    found 2 times
8470    found 2 times
3209    found 2 times
8099    found 2 times
2107    found 2 times
9817    found 2 times
9610    found 2 times
3661    found 2 times


Note: 1/e = 0.3678794412. (Compare to..)
Total number of numbers repeated is: 3652
Max number of times any number repeated is: 7
Done..


The previous run was 10,000 numbers, 3679 repeats with 7 max hits on any single number.  

There are three issues here and we can separate them if we want to.  

One is the algorithm (which I'm sure you can understand even without the tester).  Another is the test code itself.  You'd just be helping me out personally if that is where the bug is.  And the third is the direction Bill Gates is herding us.  (And I don't like it.)

Anyway...

It's not the load point.  (Should load at 0x400000)
It's not the function calls (though it could be the lib version linked).
It's not illegal instructions or you'd have noticed a lot of this in other programs too.

And it is a fun demo. :-)

.