Re: SDL-News: random number gen


Subject: Re: SDL-News: random number gen
From: Martin von Loewis (loewis#informatik.hu-berlin.de)
Date: Wed Nov 25 1998 - 17:51:24 GMT


The originator of this message is responsible for its content.
-----From Martin von Loewis <loewis#informatik.hu-berlin.de> to sdlnews -----

> I would like to be able to generate random integers in SDL. I seem to
> remember seeing something doing this by making use of Timers and real time.

To generate an arbitrary integer, use the expression

   any(integer)

To generate an integer from an interval, subtype integer first.
If you want to use it with timer, you probably want random durations
instead, which you can write as

   any(duration)

If you want this to specify action in a state after an unspecified
amount of time (as in

   set (now + any(duration), T);
   nextstate waiting;
   state waiting;
   input T;
    ...

), you can also use spontaneous transitions:

   nextstate waiting;
   state waiting;
    input none;
     ...

Hope this helps,
Martin

-----End text from Martin von Loewis <loewis#informatik.hu-berlin.de> to sdlnews -----
For help, email "majordomo#sdl-forum.org" with the body of your email as:
    help
or (iff this does not answer your question) email: owner-sdlnews#sdl-forum.org



This archive was generated by hypermail 2a23 : Sun Jun 16 2013 - 10:41:40 GMT