Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Action.h
Go to the documentation of this file.
1
9#pragma once
10
11namespace Divide {
12namespace goap {
13 struct WorldState;
14
15 class Action {
16 public:
19
20 virtual ~Action() = default;
21 Action(const Action&) = default;
22 Action& operator=(const Action&) = default;
23
24 private:
25 string name_; // The human-readable action name
26 I32 cost_; // The numeric cost of this action
27
28 // Preconditions are things that must be satisfied before this
29 // action can be taken. Only preconditions that "matter" are here.
31
32 // Effects are things that happen when this action takes place.
34
35 public:
36 Action() noexcept;
37 Action(const string& name, I32 cost);
38
44 bool eligibleFor(const goap::WorldState& ws) const;
45
52 WorldState actOn(const WorldState& ws) const;
53
59 inline void setPrecondition(const I32 key, const bool value) { preconditions_[key] = value; }
60
66 inline void setEffect(const I32 key, const bool value) { effects_[key] = value; }
67
68 inline const operations& effects() const noexcept { return effects_; }
69
70 int cost() const noexcept { return cost_; }
71
72 const string& name() const noexcept { return name_; }
73
74 virtual bool checkImplDependentCondition() const { return true; }
75 };
76} //namespace goap
77} //namespace Divide
virtual ~Action()=default
operations preconditions_
Definition: Action.h:30
operations effects_
Definition: Action.h:33
virtual bool checkImplDependentCondition() const
Definition: Action.h:74
bool eligibleFor(const goap::WorldState &ws) const
Definition: Action.cpp:21
Action & operator=(const Action &)=default
Action() noexcept
Definition: Action.cpp:9
Action(const Action &)=default
WorldState actOn(const WorldState &ws) const
Definition: Action.cpp:39
hashMap< I32, bool > operations
Definition: Action.h:17
int cost() const noexcept
Definition: Action.h:70
hashMap< I32, bool >::const_iterator operationsIterator
Definition: Action.h:18
const operations & effects() const noexcept
Definition: Action.h:68
void setPrecondition(const I32 key, const bool value)
Definition: Action.h:59
const string & name() const noexcept
Definition: Action.h:72
void setEffect(const I32 key, const bool value)
Definition: Action.h:66
A way of describing the "world" at any point in time.
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55