|
-
Apr 29th, 2001, 08:14 PM
#1
Thread Starter
New Member
Random
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
-
Apr 29th, 2001, 08:29 PM
#2
New Member
type 'RANDOMIZE TIMER' before the RND function line.
-
Apr 29th, 2001, 10:29 PM
#3
Good Ol' Platypus
Or even better, Randomize GetTickCount
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Apr 29th, 2001, 10:32 PM
#4
Good Ol' Platypus
Actually, just came about this code in one of my projects:
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
This code will ensure you random every time (maybe a bit over-exessive, but it works...)
Edited stuff:
Vars A, B, C used to be integers, found out that if you actually have GetTickCount declared (doh ) then you have to have the vars as longs to prevent overflows.
Last edited by Sastraxi; Apr 29th, 2001 at 10:37 PM.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Apr 29th, 2001, 11:23 PM
#5
Fanatic Member
just use this simple code:
Code:
dim A%
randomize timer
A = int((UBound-LBound)*rnd+LBound)
-
Apr 30th, 2001, 05:30 AM
#6
transcendental analytic
or just
Randomize
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 30th, 2001, 08:04 AM
#7
Place Randomize as the very first line of your code, for quality and freshness =).
Z.
-
May 2nd, 2001, 10:40 PM
#8
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|