Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
ExponentialFunction.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_EXPONENTIAL_FUNCTION_H
4 #define GRAIL_EXPONENTIAL_FUNCTION_H
5 
6 #include <cmath>
7 #include "Curve.hh"
8 
9 namespace grail
10 {
11 namespace evaluator
12 {
13  template <typename ContextType>
18  class ExponentialFunction final : public Curve<ContextType>
19  {
20  public:
26  ExponentialFunction(std::shared_ptr<Evaluator<ContextType>> childEvaluator, float base)
27  : Curve<ContextType>{childEvaluator}, base{base}
28  {
29  }
30 
31  virtual float Sample(float argument) const override final
32  {
33  return std::pow(base, argument);
34  }
35 
40  float GetBase() const { return base; }
41  virtual data::EvaluatorType GetEvaluatorType() const override final { return data::EvaluatorType::CURVE_EXPONENTIAL; }
42 
43  private:
44  float base = 0.0f;
45  };
46 }
47 }
48 
49 #endif // GRAIL_EXPONENTIAL_FUNCTION_H
grail::evaluator::ExponentialFunction::Sample
virtual float Sample(float argument) const override final
Sample - Transforms argument into output value depending on the type of Curve.
Definition: ExponentialFunction.hh:31
grail::evaluator::Evaluator
The Evaluator class - base class being able to evaluate given context and output the result.
Definition: Evaluator.hh:22
grail::evaluator::ExponentialFunction::GetBase
float GetBase() const
GetBase.
Definition: ExponentialFunction.hh:40
grail::evaluator::ExponentialFunction::ExponentialFunction
ExponentialFunction(std::shared_ptr< Evaluator< ContextType >> childEvaluator, float base)
ExponentialFunction - Construct.
Definition: ExponentialFunction.hh:26
grail::evaluator::ExponentialFunction
The ExponentialFunction class - Exponential function.
Definition: ExponentialFunction.hh:18
grail::evaluator::Curve
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:21