Results 1 to 8 of 8

Thread: Random

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    10

    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

  2. #2
    New Member
    Join Date
    Apr 2001
    Posts
    11
    type 'RANDOMIZE TIMER' before the RND function line.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    just use this simple code:

    Code:
    dim A%
    randomize timer
    A =  int((UBound-LBound)*rnd+LBound)

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  7. #7
    Zaei
    Guest
    Place Randomize as the very first line of your code, for quality and freshness =).

    Z.

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    10
    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
  •  



Click Here to Expand Forum to Full Width