8 Commits

Author SHA1 Message Date
Alex King
f0c041e8b3
[Code] EQ::Random Global to Singleton Cleanup (#4936) 2025-06-22 14:13:58 -04:00
Michael Cook (mackal)
ddb14187b0 Add some knobs to our RNG class
Also included is an additive lagged fibonacci generator that should is
very similar to EQ's. Also added BIASED_INT_DIST in case someone wants
to use "bad" int distribution to more closely match EQ as well.

An option to set a custom engine (just in case people would like to play
with other std engines) is available.

There is also support for GCC's SIMD accelerated extension to std random
engines.

All these options are hidden behind advanced options in CMake since
they're rather advanced knobs.
2021-07-16 21:50:46 -04:00
KimLS
2fbd5aaccc Rename namespace EQEmu to namespace EQ (so we don't have two similar but different namespaces anymore) 2020-05-17 18:36:06 -07:00
Michael Cook (mackal)
1d19bd11d0 Add Random::Roll0
This has the same interval ((0,N]) that the client function does
The devs have referenced this in a few posts talking about
mechanics.
2016-12-25 21:06:02 -05:00
Michael Cook (mackal)
62181ff08c Add Random::Shuffle
This is just a wrapper to std::shuffle since it requires a random
engine and ours lives in a class

Must pass random access iterators (array, vector, deque, etc)

ex:

std::vector<int> v;
/* init ... */
random.Shuffle(v.begin(), v.end());
2014-12-15 02:53:58 -05:00
Michael Cook (mackal)
026d5e71fa Adjust common/random.h based on N3551 2014-12-14 19:38:23 -05:00
Michael Cook (mackal)
6f867ebca3 Add license info 2014-12-01 19:50:05 -05:00
Michael Cook (mackal)
395be050a3 Switch random function to std::mt19937
Added class EQEmu::Random
Functions:
EQEmu::Random::Int(int low, int high)
EQEmu::Random::Real(double low, double high)
EQEmu::Random::Roll(int required)
EQEmu::Random::Roll(double required)
EQEmu::Random::Reseed()

For zone, you will access the random object through the zone object
ex.
	zone->random.Int(0, 100);

Int returns a random int between low and high
Real returns a random double between low and high
Roll(int) returns true if Int(0, 99) < required is true
Roll(double) returns true if Real(0.0, 1.0) <= required is true
2014-12-01 18:13:12 -05:00