Player12
An open source football management simulator
Loading...
Searching...
No Matches
world_rng.h File Reference
#include <array>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <span>
#include <utility>
#include "model/gamedate.h"

Go to the source code of this file.

Classes

class  WorldRng
 Deterministic, portable pseudo random generator (xoshiro256**). More...
 

Namespaces

namespace  PortableMath
 
namespace  PortableRandom
 

Concepts

concept  PortableRandom::FullRangeEngine
 

Enumerations

enum class  RngDomain : std::uint64_t {
  Generation = 1 , Migration , TrainingInjury , MatchInjury ,
  MatchRating , Development , YouthIntake , Retirement ,
  Transfers , Scouting , Staff , Training ,
  Interactions , Stories , Managers
}
 Independent random streams of the world simulation. More...
 

Functions

double PortableMath::log (double x)
 
double PortableMath::exp (double x)
 
double PortableMath::cosTwoPi (double turns)
 
template<FullRangeEngine Engine>
std::uint32_t PortableRandom::bits32 (Engine &engine)
 
template<FullRangeEngine Engine>
std::uint64_t PortableRandom::bits64 (Engine &engine)
 
float PortableRandom::unitFloat (std::uint32_t bits)
 
double PortableRandom::unitDouble (std::uint64_t bits)
 
float PortableRandom::lerp (float lo, float hi, float unit)
 
double PortableRandom::lerp (double lo, double hi, double unit)
 
double PortableRandom::affine (double offset, double scale, double value)
 
double PortableRandom::standardNormal (double u1, double u2)
 
int PortableRandom::poissonFromUnit (double unit, double mean)
 
template<FullRangeEngine Engine>
float PortableRandom::uniformReal (Engine &engine, float lo, float hi)
 
template<FullRangeEngine Engine>
double PortableRandom::uniformReal (Engine &engine, double lo, double hi)
 
template<FullRangeEngine Engine>
std::uint64_t PortableRandom::below (Engine &engine, std::uint64_t count)
 
template<FullRangeEngine Engine>
int PortableRandom::uniformInt (Engine &engine, int lo, int hi)
 
template<FullRangeEngine Engine>
double PortableRandom::normal (Engine &engine, double mean, double stddev)
 
template<FullRangeEngine Engine>
int PortableRandom::poisson (Engine &engine, double mean)
 
std::uint64_t mixHash (std::uint64_t a, std::uint64_t b)
 
std::int32_t dayOrdinal (const GameDateValue &date)
 
std::int32_t dateToInt (const GameDateValue &date)
 
GameDateValue dateFromInt (std::int32_t value)
 

Enumeration Type Documentation

◆ RngDomain

enum class RngDomain : std::uint64_t
strong

Independent random streams of the world simulation.

Every stream is derived from the save's world seed plus a domain tag and stable keys (day, player id, team id). Consuming numbers in one domain never perturbs another, and results do not depend on container iteration order, so a reloaded save continues exactly like an uninterrupted one.

Enumerator
Generation 
Migration 
TrainingInjury 
MatchInjury 
MatchRating 
Development 
YouthIntake 
Retirement 
Transfers 
Scouting 
Staff 
Training 
Interactions 
Stories 
Managers 

Function Documentation

◆ dateFromInt()

GameDateValue dateFromInt ( std::int32_t  value)

Converts the compact integer form YYYYMMDD back to a date.

◆ dateToInt()

std::int32_t dateToInt ( const GameDateValue &  date)

Converts a date to the compact integer form YYYYMMDD.

◆ dayOrdinal()

std::int32_t dayOrdinal ( const GameDateValue &  date)

Days since 1970-01-01 for a proleptic Gregorian date.

◆ mixHash()

std::uint64_t mixHash ( std::uint64_t  a,
std::uint64_t  b 
)

Mixes two 64-bit values into a well distributed hash (splitmix64).