DEFINITION MODULE RandCard;

        (********************************************************)
        (*                                                      *)
        (*              Random number generator                 *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Last edited:        24 March 2010                   *)
        (*  Status:             OK                              *)
        (*                                                      *)
        (********************************************************)

CONST modulus = 2147483647;     (*  2^31 - 1  *)

VAR seed: CARDINAL;     (*   visible in case you want to re-randomize   *)

PROCEDURE Randomize;

    (* Changes the random number seed to a new value.           *)

PROCEDURE RandCardinal (): CARDINAL;

    (* Returns a random number in the range [1..modulus-1], with a      *)
    (* uniform distribution over that range.                            *)

PROCEDURE RandInt (min, max: INTEGER): INTEGER;

    (* Returns a random number in the range [min..max]          *)
    (* (inclusive), with an approximately uniform distribution  *)
    (* over that range.  (In this version I'm not being fussy   *)
    (* about the precise distribution.)                         *)

END RandCard.

