Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
cProbabDistrib Class Reference

#include <ProbabDistrib.h>

Classes

class  cPoint
 

Public Types

typedef std::vector< cPointcPoints
 

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...
 

Detailed Description

Definition at line 29 of file ProbabDistrib.h.

Member Typedef Documentation

◆ cPoints

typedef std::vector<cPoint> cProbabDistrib::cPoints

Definition at line 45 of file ProbabDistrib.h.

Constructor & Destructor Documentation

◆ cProbabDistrib()

cProbabDistrib::cProbabDistrib ( int  a_MaxValue)

Definition at line 13 of file ProbabDistrib.cpp.

Member Function Documentation

◆ GetSum()

int cProbabDistrib::GetSum ( void  ) const
inline

Definition at line 62 of file ProbabDistrib.h.

◆ MapValue()

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.

◆ Random()

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.

◆ SetDefString()

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.

◆ SetPoints()

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.

Member Data Documentation

◆ m_Cumulative

cPoints cProbabDistrib::m_Cumulative
protected

Cumulative probability of the values, sorted, for fast bsearch lookup.

Definition at line 69 of file ProbabDistrib.h.

◆ m_MaxValue

int cProbabDistrib::m_MaxValue
protected

Definition at line 66 of file ProbabDistrib.h.

◆ m_Sum

int cProbabDistrib::m_Sum
protected

Sum of all the probabilities across all values in the domain; -1 if not set.

Definition at line 72 of file ProbabDistrib.h.


The documentation for this class was generated from the following files: