Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <ProbabDistrib.h>
Classes | |
class | cPoint |
Public Types | |
typedef std::vector< cPoint > | cPoints |
Public Member Functions | |
cProbabDistrib (int a_MaxValue) | |
int | GetSum (void) const |
int | MapValue (int a_OrigValue) const |
Maps value in range [0, m_Sum] into the range [0, m_MaxValue] using the stored probability. More... | |
int | Random (MTRand &a_Rand) const |
Gets a random value from a_Rand, shapes it into the distribution curve and returns the value. More... | |
bool | SetDefString (const AString &a_DefString) |
Sets the distribution curve using a definition string; returns true on successful parse. More... | |
void | SetPoints (const cPoints &a_Points) |
Sets the distribution curve using an array of [value, probability] points, linearly interpolated. More... | |
Protected Attributes | |
cPoints | m_Cumulative |
Cumulative probability of the values, sorted, for fast bsearch lookup. More... | |
int | m_MaxValue |
int | m_Sum |
Sum of all the probabilities across all values in the domain; -1 if not set. More... | |
Definition at line 29 of file ProbabDistrib.h.
typedef std::vector<cPoint> cProbabDistrib::cPoints |
Definition at line 45 of file ProbabDistrib.h.
cProbabDistrib::cProbabDistrib | ( | int | a_MaxValue | ) |
Definition at line 13 of file ProbabDistrib.cpp.
|
inline |
Definition at line 62 of file ProbabDistrib.h.
int cProbabDistrib::MapValue | ( | int | a_OrigValue | ) | const |
Maps value in range [0, m_Sum] into the range [0, m_MaxValue] using the stored probability.
Definition at line 107 of file ProbabDistrib.cpp.
int cProbabDistrib::Random | ( | MTRand & | a_Rand | ) | const |
Gets a random value from a_Rand, shapes it into the distribution curve and returns the value.
Definition at line 98 of file ProbabDistrib.cpp.
bool cProbabDistrib::SetDefString | ( | const AString & | a_DefString | ) |
Sets the distribution curve using a definition string; returns true on successful parse.
Definition at line 61 of file ProbabDistrib.cpp.
void cProbabDistrib::SetPoints | ( | const cPoints & | a_Points | ) |
Sets the distribution curve using an array of [value, probability] points, linearly interpolated.
a_Points must not be empty.
Definition at line 23 of file ProbabDistrib.cpp.
|
protected |
Cumulative probability of the values, sorted, for fast bsearch lookup.
Definition at line 69 of file ProbabDistrib.h.
|
protected |
Definition at line 66 of file ProbabDistrib.h.
|
protected |
Sum of all the probabilities across all values in the domain; -1 if not set.
Definition at line 72 of file ProbabDistrib.h.