VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::DecayingScore Class Reference

A score that loses half its weight every half-life - the building block for evidence that should fade with age rather than expire on a window edge. More...

#include <DecayingScore.hpp>

Public Member Functions

 DecayingScore ()=default
 DecayingScore (double halfLifeSec)
void SetHalfLife (double halfLifeSec)
double HalfLife () const
double Add (double now, double weight=1.0)
double Value (double now) const
void Clear ()

Detailed Description

A score that loses half its weight every half-life - the building block for evidence that should fade with age rather than expire on a window edge.

Holds one value and one timestamp, so it costs the same whether it saw one event or a thousand. Time is caller-supplied (seconds, any monotonic origin) so the class stays clock-free and testable; pass the same time source to every call.

A half-life of 0 or less never decays, which is how a score latches.

Definition at line 18 of file DecayingScore.hpp.

Constructor & Destructor Documentation

◆ DecayingScore() [1/2]

VoltMod::DecayingScore::DecayingScore ( )
default

◆ DecayingScore() [2/2]

VoltMod::DecayingScore::DecayingScore ( double halfLifeSec)
inlineexplicit

Definition at line 22 of file DecayingScore.hpp.

Member Function Documentation

◆ Add()

double VoltMod::DecayingScore::Add ( double now,
double weight = 1.0 )
inline

Ages the score to now, adds weight, and returns the result.

Definition at line 29 of file DecayingScore.hpp.

References Value().

◆ Clear()

void VoltMod::DecayingScore::Clear ( )
inline

Definition at line 48 of file DecayingScore.hpp.

◆ HalfLife()

double VoltMod::DecayingScore::HalfLife ( ) const
inline

Definition at line 26 of file DecayingScore.hpp.

◆ SetHalfLife()

void VoltMod::DecayingScore::SetHalfLife ( double halfLifeSec)
inline

Takes effect from the next Value; weight already accrued is not re-aged.

Definition at line 25 of file DecayingScore.hpp.

◆ Value()

double VoltMod::DecayingScore::Value ( double now) const
inline

The score at now, leaving the stored value and stamp alone.

Definition at line 37 of file DecayingScore.hpp.

Referenced by Add().


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