//Rand.h #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef Randh #define Randh /* This is the standard c++ srand(int) and rand() algorithm made into a class. This allows you to iterate the Pseudo Random sequence in several variables at once. CRand RandA; CRand RandB; int A=++RandA; int B=++RandB; CRand Rand(0); int i=Rand[10]; */ class CRand { unsigned long LastRand; public: CRand() : LastRand(1) {} CRand(unsigned int Seed) : LastRand((unsigned long)Seed) {} void Seed(unsigned int Seed) {LastRand=(unsigned long)Seed;} void Randomise() {LastRand=GetTickCount();} int Rand() {return ((LastRand=LastRand*214013L+2531011L)>>16) & 0x7FFF;} operator int() {return LastRand;} int operator++() {return Rand();} int operator[](WORD Index) {for(register WORD i=Index; i--; Rand()); return Rand();} }; #endif // Randh