No, I'm actually gonna disagree with you matsp xP no algorithm calculates randomness right.. It's impossible, so if you toss a coin in real life, you get the real randomness, if you do rand() in code, you get some algorithm of predictable numbers

That is true of all pseudorandom number generators, but what is your point? Using a PRNG multiple times does not suddenly turn it into a "real" random number generator. The reason I suggested that you just go for the straightforward implementation is because that way you can see more clearly why your more complicated implementation is actually bogus.

Well... yes, the loop either does not run or runs infinitely since inAir is never changed in the loop.

01-26-2009

Akkernight

Yeah well... It'll turn false once the ball is off the screen, but I also deleted everything from move(), and it still crashes the application o.O could it be the enum?
or... I didn't delete the loop xP lemme check that
EDIT: And it was the loop xP but how can I then make it move using AI o.O? Hmm...

01-26-2009

laserlight

Well... maybe you would use an algorithm along the lines of:

Code:

while the ball is not at its destination
move the ball towards the destination
draw the ball in its current position

You might need to add a slight delay so that the user can actually see the ball moving.

and matsp, try using srand() and ctime(), and post on here, I got told that made it more random xP
If you've got the time that is!

01-26-2009

matsp

Quote:

Originally Posted by Akkernight

and matsp, try using srand() and ctime(), and post on here, I got told that made it more random xP
If you've got the time that is!

I intentionally used THE SAME srand() seed so that it can be reproducable [ok, so we're calling rand a differnet number of times, but the point is that any value you pass into srand() simply gives you a starting point. Eventually you get back the same sequence anyways - it's just a matter of time. So starting from the same place is a good thing in this case.

Note that other random number generators will give different results. But I think it's clear that repeating rand is not better...

--
Mats

01-26-2009

laserlight

Quote:

Originally Posted by Akkernight

and matsp, try using srand() and ctime(), and post on here, I got told that made it more random xP
If you've got the time that is!

I think you mean std::time() from <ctime>, which is a common way to seed with srand(). It would not make the PRNG "more random". What it would do is provide a convenient way to generate a seed at random.

Quote:

Originally Posted by matsp

I intentionally used THE SAME srand() seed so that it can be reproducable [ok, so we're calling rand a differnet number of times, but the point is that any value you pass into srand() simply gives you a starting point. Eventually you get back the same sequence anyways - it's just a matter of time. So starting from the same place is a good thing in this case.

Of course, just because you generate a seed at random does not mean you cannot reuse it by saving it into a variable :)

01-26-2009

matsp

Quote:

Originally Posted by laserlight

Of course, just because you generate a seed at random does not mean you cannot reuse it by saving it into a variable :)

Of course not. I meant that if someone else wants to try the same thing, it will (assuming the same C library) give the same result - not just my machined doing what it does. I doubt it makes much difference - it is fairly clear in the results I got that rand isn't terribly bad at "tossing a coin" type stuff.