#pragma once #include "scalar.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Random ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class RandomGenerator SIGNATURED { private: static int Numbers[250]; // the random number table static int Index; // the current entry within the table static void Init(); static int GetRandomInt(); public: RandomGenerator() { if (Index == -1) Init(); } // //------------------------ // Random number functions //------------------------ // int GetInt() // returns 0 .. RAND_MAX { return GetRandomInt(); } operator Scalar(); // returns 0.0f <= x < 1.0f int operator ()(int Range); // returns 0 .. Range-1 static Logical TestClass(); }; extern RandomGenerator Random; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Die ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Die SIGNATURED { private: int highestRandom; // the highest random number giving a uniform dist. int dieSides; // the number of sides on the die (starting from 1) public: Die(int sides); operator int(); // returns 1 .. dieSides };