|
Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
3 #ifndef GRAIL_STEP_FUNCTION_H
4 #define GRAIL_STEP_FUNCTION_H
31 template <
typename ContextType>
45 const std::vector<StepData>& data)
46 :
Curve<ContextType>{childEvaluator}, data{data}
49 assert(data.size() >= 1);
50 float previousX = data[0].startPoint;
51 for(
size_t i = 1; i < data.size(); ++i)
53 assert(previousX < data[i].startPoint);
54 previousX = data[i].startPoint;
59 virtual float Sample(
float argument)
const override final
61 for(std::size_t i = data.size() - 1; i > 0; --i)
63 if(argument > data[i].startPoint || (argument == data[i].startPoint && data[i].inclusiveStartPoint))
75 std::vector<StepData>&
GetData() {
return data; }
80 const std::vector<StepData>&
GetData()
const {
return data; }
82 virtual data::EvaluatorType GetEvaluatorType() const override final {
return data::EvaluatorType::CURVE_STAIRCASE; }
85 std::vector<StepData> data{};
89 #endif // GRAIL_STEP_FUNCTION_H
virtual float Sample(float argument) const override final
Sample - Transforms argument into output value depending on the type of Curve.
Definition: StaircaseFunction.hh:59
The StepData struct - Helper structure describing discrete values used in Staircase function.
Definition: StaircaseFunction.hh:15
std::vector< StepData > & GetData()
GetData.
Definition: StaircaseFunction.hh:75
float startPoint
startPoint - Start point of half-line extending to the right and having constant given value.
Definition: StaircaseFunction.hh:24
The Evaluator class - base class being able to evaluate given context and output the result.
Definition: Evaluator.hh:25
const std::vector< StepData > & GetData() const
GetData.
Definition: StaircaseFunction.hh:80
float value
value - Y-axis value.
Definition: StaircaseFunction.hh:20
The StaircaseFunction class - Function consisting of multiple discrete values.
Definition: StaircaseFunction.hh:36
StaircaseFunction(std::shared_ptr< Evaluator< ContextType >> childEvaluator, const std::vector< StepData > &data)
StaircaseFunction - Constructor.
Definition: StaircaseFunction.hh:44
bool inclusiveStartPoint
inclusiveStartPoint - Determines whether exact start point also has given value. If not,...
Definition: StaircaseFunction.hh:28
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:21