11#include <jaffarCommon/json.hpp>
48 if (c->evaluate() ==
false)
return false;
A labelled collection of conditions with associated reward, actions and outcome flags.
bool _isCheckpointRule
Whether this rule marks a checkpoint.
label_t getLabel() const
Returns the rule's identifying label.
std::unordered_set< std::unique_ptr< Condition > > _conditions
Conditions that must all hold for the rule to be satisfied.
size_t _checkPointTolerance
Checkpoint tolerance value.
std::vector< Rule * > _satisfyRules
Pointers to rules also satisfied when this one is.
const std::string & getSaveSolutionPath() const
Returns the path where the solution is saved.
bool isCheckpointRule() const
Returns whether this rule is a checkpoint rule.
void addAction(const std::function< void()> &function)
Appends a game-specific action to run for this rule.
std::vector< std::function< void()> > _actions
Storage for game-specific actions run for this rule.
void setWinRule(const bool isWinRule)
Sets whether this rule is a win rule.
size_t getCheckpointTolerance() const
Returns the rule's checkpoint tolerance.
void setFailRule(const bool isFailRule)
Sets whether this rule is a fail rule.
size_t getIndex() const
Returns the rule's internal sequential index.
Rule(const size_t index, const label_t label)
Constructs a rule with its sequential index and identifying label.
bool _isWinRule
Whether this rule marks a win.
void addSatisfyRuleLabel(const label_t satisfyRuleLabel)
Adds the label of another rule considered satisfied alongside this one.
void addSatisfyRule(Rule *const subRule)
Adds a pointer to another rule considered satisfied alongside this one.
const std::vector< std::function< void()> > & getActions() const
Returns the rule's game-specific actions.
float getReward() const
Returns the reward granted when this rule is satisfied.
bool evaluate() const
Evaluates the rule by checking all of its conditions.
bool isWinRule() const
Returns whether this rule is a win rule.
bool _isFailRule
Whether this rule marks a fail.
std::unordered_set< label_t > _satisfyRuleLabels
Labels of rules also satisfied when this one is.
bool _isSaveSolutionRule
Whether this rule triggers saving the solution.
std::string _saveSolutionPath
Path where the solution is saved.
const std::vector< Rule * > & getSatisfyRules() const
Returns pointers to the rules satisfied alongside this one.
bool isSaveSolutionRule() const
Returns whether this rule triggers saving the solution.
void setCheckpointTolerance(const size_t checkPointTolerance)
Sets the checkpoint tolerance for this rule.
const label_t _label
Identifying label for the rule.
const size_t _index
Internal index for sequential access.
void setReward(const float reward)
Sets the reward granted when this rule is satisfied.
size_t label_t
Type used to identify a rule by label.
float _reward
Reward associated with meeting this rule.
void setSaveSolutionRule(const bool isSaveSolutionRule)
Sets whether this rule triggers saving the solution.
void addCondition(std::unique_ptr< Condition > condition)
Adds a condition that must hold for this rule to be satisfied.
bool isFailRule() const
Returns whether this rule is a fail rule.
void setCheckpointRule(const bool isCheckpointRule)
Sets whether this rule is a checkpoint rule.
const std::unordered_set< label_t > & getSatisfyRuleLabels() const
Returns the labels of rules satisfied alongside this one.
void setSaveSolutionPath(const std::string &saveSolutionPath)
Sets the path where the solution is saved.
Boolean comparisons between game properties (or immediate values) used by rules and input sets to dec...
A named, typed view into a region of game memory, with datatype and endianness handling and a templat...