Re: A86: Re: Random Numbers


[Prev][Next][Index][Thread]

Re: A86: Re: Random Numbers




Exact probability? That's an oxymoron if I've ever
heard one ;).

--- David Phillips <david@acz.org> wrote:
> 
> I am using this routine in my current game, and it
> works rather well.  If
> you need truely random numbers, then this won't
> work.  But this works fine
> for making random decisions where exact probability
> doesn't matter (like AI,
> random powerups, etc.).  It's advantage is it's
> small, fast, and doesn't
> destroy the flags.  Calling the rom routines will be
> a little smaller, but
> MUCH slower.
> 
> ; a fast, yet decent random number generator
> ; returns: a = psuedo random number
> ; destroyed: flags
> ; totals: 93 t's / 17 bytes (including ret)
> RandomNumber:
>  push bc
>  ld a,r
>  ld b,a
>  ld a,($1234)
> _@RandomNumberSeed =$-2
>  ld c,a
>  ld a,(bc)
>  ld (_@RandomNumberSeed),a
>  xor b
>  sub b
>  add a,c
>  pop bc
>  ret
> 
> 
> 
> >
> > How can I get random integers?  Is there a command
> like
> > BASIC's randint?  I see randint in the token
> lists, is this the only
> > way?  I have looked for tutorials on tokens,
> 'cause I don't know
> > about them, but haven't found any.  Could someone
> help me?  Thanks
> 
> 
> 
> 

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



Follow-Ups: