Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::goap::WorldState Struct Reference

#include <WorldState.h>

+ Inheritance diagram for Divide::goap::WorldState:

Public Member Functions

 WorldState (const Divide::string &name="") noexcept
 
void setVariable (const int var_id, const bool value)
 
bool getVariable (const int var_id) const
 
bool meetsGoal (const WorldState &goal_state) const
 
int distanceTo (const WorldState &goal_state) const
 
bool operator== (const WorldState &other) const
 
string toString () const
 

Public Attributes

F32 priority_
 
string name_
 
hashMap< I32, bool > vars_
 

Detailed Description

Definition at line 13 of file WorldState.h.

Constructor & Destructor Documentation

◆ WorldState()

WorldState::WorldState ( const Divide::string name = "")
explicitnoexcept

Definition at line 8 of file WorldState.cpp.

Member Function Documentation

◆ distanceTo()

I32 WorldState::distanceTo ( const WorldState goal_state) const

Given the other state – and what 'matters' to the other state – how many of our state variables differ from the other?

Parameters
goal_statethe goal state to compare against
Returns
the number of state-var differences between us and them

Definition at line 44 of file WorldState.cpp.

◆ getVariable()

bool WorldState::getVariable ( const int  var_id) const

Retrieve the current value of the given variable.

Parameters
var_idthe unique ID of the state variable
Returns
the value of the variable

Definition at line 20 of file WorldState.cpp.

◆ meetsGoal()

bool WorldState::meetsGoal ( const WorldState goal_state) const

Useful if this state is a goal state. It asks, does state 'other' meet the requirements of this goal? Takes into account not only this goal's state variables, but which variables matter to this goal state.

Parameters
goal_statethe state you are testing as having met this goal state
Returns
true if it meets this goal state, false otherwise

Definition at line 29 of file WorldState.cpp.

◆ operator==()

bool WorldState::operator== ( const WorldState other) const

Equality operator

Parameters
otherthe other worldstate to compare to
Returns
true if they are equal, false if not

Definition at line 25 of file WorldState.cpp.

◆ setVariable()

void WorldState::setVariable ( const int  var_id,
const bool  value 
)

Set a world state variable, e.g. "gunLoaded" / true

Parameters
var_idthe unique ID of the state variable
valuethe boolean value of the variable

Definition at line 15 of file WorldState.cpp.

◆ toString()

string WorldState::toString ( ) const

Definition at line 58 of file WorldState.cpp.

Member Data Documentation

◆ name_

string Divide::goap::WorldState::name_

Definition at line 15 of file WorldState.h.

◆ priority_

F32 Divide::goap::WorldState::priority_

Definition at line 14 of file WorldState.h.

◆ vars_

hashMap<I32, bool> Divide::goap::WorldState::vars_

Definition at line 16 of file WorldState.h.


The documentation for this struct was generated from the following files: