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