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