I know the random input of rnd but for some reason i seem to always get the same random of 533 out of 1000, here is the line of code, i'm using it to input AI into my game, just ain't working
intbatle = 1000 * Rnd
thanx
Gorf
Printable View
I know the random input of rnd but for some reason i seem to always get the same random of 533 out of 1000, here is the line of code, i'm using it to input AI into my game, just ain't working
intbatle = 1000 * Rnd
thanx
Gorf
type 'RANDOMIZE TIMER' before the RND function line.
Or even better, Randomize GetTickCount
Actually, just came about this code in one of my projects:
This code will ensure you random every time (maybe a bit over-exessive, but it works...)Code:Function TrueRandom as Single
Dim A as Long: Dim B as Long: Dim C as Long
Randomize Timer
A = Int(Rnd * 1000) + 1
Randomize Int(GetTickCount / A)
B = Int(Rnd * Int(GetTickcount / (A / Timer)))
Randomize B * GetTickCount
C = 0 - Int(Rnd * A * B / Timer)
C = -C
Randomize C
TrueRandom = Rnd
End Function
Edited stuff:
Vars A, B, C used to be integers, found out that if you actually have GetTickCount declared (doh :rolleyes: ) then you have to have the vars as longs to prevent overflows.
just use this simple code:
Code:dim A%
randomize timer
A = int((UBound-LBound)*rnd+LBound)
or just
Randomize
:rolleyes:
Place Randomize as the very first line of your code, for quality and freshness =).
Z.
That ended up being my problem, i had like 400 lines of code and i forgot to put randomize in. I slapped myself for the foolish mistake, thanks for the reminder guys. As well anyone know a simple way to explain blitbitting i tried DX but its way too advanced for me at this state, anything that doesn't involve 10,000 variables that arn't explained worth crap will not help me one bit i promise that.
image is image1 and it rotates to a different image depends on left, right, up or down on the keyboard, but it always is image1
Gorf