Files
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

92 lines
2.4 KiB
C++

//===========================================================================//
// File: random.cc //
// Project: MUNGA Brick: Math Library //
// Contents: Interface specification for the random number generator //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 11/20/93 JMA Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1993-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#pragma once
#include "Stuff.hpp"
#include "Scalar.hpp"
namespace Stuff {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Random ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Random
#if defined(_ARMOR)
: public Stuff::Signature
#endif
{
public:
static void
InitializeClass();
static void
TerminateClass();
private:
static int
Numbers[250]; // the random number table
static int
Index; // the current entry within the table
static void
Init();
static int
GetRandomInt();
Random()
{Verify(Index == -1); Init();}
static Random
*Instance;
void
TestInstance() const {}
public:
//
//------------------------
// Random number functions
//------------------------
//
static int
GetInt() // returns 0 .. RAND_MAX
{return GetRandomInt();}
static Scalar
GetFraction(); // returns 0.0f <= x < 1.0f
static int // returns 0 .. Range-1
GetLessThan(int Range);
static bool
TestClass();
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Die ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Die
#if defined(_ARMOR)
: public Stuff::Signature
#endif
{
private:
int
highestRandom, // the highest random number giving a uniform dist.
dieSides; // the number of sides on the die (starting from 1)
public:
Die(int sides);
operator int(); // returns 1 .. dieSides
};
}