Class walle::TrackingAgent
ClassList > walle > TrackingAgent
#include <TrackingAgent.hpp>
Inherits the following classes: AgentBase
Public Functions
Type | Name |
---|---|
void | AddToAlerter (std::shared_ptr< Alerter > alerter) |
void | CallAlerter (size_t agent_id) Tells the alerter to notify all other tracking agents in network. |
std::shared_ptr< Alerter > | GetAlerter () const |
cse491::GridPosition | GetNextPosition () override |
std::vector< cse491::GridPosition > const & | GetPath () const |
TrackingState | GetState () |
cse491::Entity const * | GetTarget () const |
double | GetTrackingDistance () const |
bool | Initialize () override |
void | MakeAlerter () Creates an alerter network and adds this tracking agent to it. |
void | RemoveFromAlerter () |
size_t | SelectAction (cse491::WorldGrid const & grid, cse491::type_options_t const & type, cse491::item_map_t const & item_set, cse491::agent_map_t const & agent_set) override Updates the internal state of the TrackingAgent and calls the internal agent's select action method. |
size_t | SelectInnerAction (PathAgent & agent, cse491::WorldGrid const & grid, cse491::type_options_t const & type, cse491::item_map_t const & item_set, cse491::agent_map_t const & agent_set) Select action for PathAgent inner type. |
size_t | SelectInnerAction (AStarAgent & agent, cse491::WorldGrid const & grid, cse491::type_options_t const & type, cse491::item_map_t const & item_set, cse491::agent_map_t const & agent_set) Select action for AStarAgent inner type. |
TrackingAgent & | SetPath (std::vector< cse491::GridPosition > offsets) |
TrackingAgent & | SetPath (std::string_view offsets) |
TrackingAgent & | SetStartPosition (cse491::GridPosition pos) |
TrackingAgent & | SetStartPosition (double x, double y) |
TrackingAgent & | SetTarget (Entity * agent) |
TrackingAgent & | SetTrackingDistance (double dist) |
TrackingAgent & | SetWorld (cse491::WorldBase & in_world) override |
TrackingAgent () = delete |
|
TrackingAgent (size_t id, std::string const & name) |
|
TrackingAgent (size_t id, std::string const & name, std::vector< cse491::GridPosition > && offsets, std::shared_ptr< Alerter > && alerter=nullptr) |
|
TrackingAgent (size_t id, std::string const & name, std::string_view commands, std::shared_ptr< Alerter > && alerter=nullptr) |
|
void | UpdateState (bool alerting=true) |
~TrackingAgent () override |
Detailed Description
Agent that switches between user-defined custom movement pattern and tracking a given agent
Public Functions Documentation
function AddToAlerter
inline void walle::TrackingAgent::AddToAlerter (
std::shared_ptr< Alerter > alerter
)
Adds this tracking agent to an already-existing alerter network
Parameters:
alerter
alerter that this agent should be associated with
Note:
alerter must not be null
function CallAlerter
inline void walle::TrackingAgent::CallAlerter (
size_t agent_id
)
function GetAlerter
inline std::shared_ptr< Alerter > walle::TrackingAgent::GetAlerter () const
Used to expand the alerter network by adding other tracking agents to it
Returns:
a copy of this tracking agent's alerter
Note:
it's expected that this function is used when calling AddToAlerter on a different tracking agent
Note:
may be null
function GetNextPosition
inline cse491::GridPosition walle::TrackingAgent::GetNextPosition () override
Overrides the AgentBase getter to retrieve the next calculated position
Returns:
inner PathAgent's next position
function GetPath
inline std::vector< cse491::GridPosition > const & walle::TrackingAgent::GetPath () const
Returns an immutable reference to this agent's current path
Returns:
sequence of offsets
function GetState
inline TrackingState walle::TrackingAgent::GetState ()
Retrieves the current internal state of the Tracking Agent
Returns:
current state
function GetTarget
inline cse491::Entity const * walle::TrackingAgent::GetTarget () const
Returns an immutable pointer to this agent's target
Returns:
ptr to entity
function GetTrackingDistance
inline double walle::TrackingAgent::GetTrackingDistance () const
Get the distance around this tracker that it surveys
Returns:
tracking distance
function Initialize
inline bool walle::TrackingAgent::Initialize () override
Ensure that the TrackingAgent's internal PathAgent is correctly initialized Verifies that it can currently index into a valid offset
Returns:
true if so; false otherwise
function MakeAlerter
inline void walle::TrackingAgent::MakeAlerter ()
function RemoveFromAlerter
inline void walle::TrackingAgent::RemoveFromAlerter ()
Removes this tracking agent from it's own tracking network
Note:
called from the TrackingAgent destructor
function SelectAction
inline size_t walle::TrackingAgent::SelectAction (
cse491::WorldGrid const & grid,
cse491::type_options_t const & type,
cse491::item_map_t const & item_set,
cse491::agent_map_t const & agent_set
) override
function SelectInnerAction [1/2]
inline size_t walle::TrackingAgent::SelectInnerAction (
PathAgent & agent,
cse491::WorldGrid const & grid,
cse491::type_options_t const & type,
cse491::item_map_t const & item_set,
cse491::agent_map_t const & agent_set
)
function SelectInnerAction [2/2]
inline size_t walle::TrackingAgent::SelectInnerAction (
AStarAgent & agent,
cse491::WorldGrid const & grid,
cse491::type_options_t const & type,
cse491::item_map_t const & item_set,
cse491::agent_map_t const & agent_set
)
function SetPath [1/2]
inline TrackingAgent & walle::TrackingAgent::SetPath (
std::vector< cse491::GridPosition > offsets
)
Sets the patrolling path of the TrackingAgent
Parameters:
offsets
grid position offsets creating the path
Returns:
function SetPath [2/2]
inline TrackingAgent & walle::TrackingAgent::SetPath (
std::string_view offsets
)
Sets the patrolling path of the TrackingAgent
Parameters:
offsets
grid position offsets creating the path
Returns:
function SetStartPosition [1/2]
inline TrackingAgent & walle::TrackingAgent::SetStartPosition (
cse491::GridPosition pos
)
Set where this agent "patrol area" starts
Parameters:
gp
grid position of position
Returns:
self
function SetStartPosition [2/2]
inline TrackingAgent & walle::TrackingAgent::SetStartPosition (
double x,
double y
)
Set where this agent "patrol area" starts
Parameters:
x
x-coordinate of start posy
y-coordinate of start pos
Returns:
self
function SetTarget
inline TrackingAgent & walle::TrackingAgent::SetTarget (
Entity * agent
)
Set which agent we are following
Parameters:
agent
we want to track
Returns:
self
function SetTrackingDistance
inline TrackingAgent & walle::TrackingAgent::SetTrackingDistance (
double dist
)
Set how close goal_pos has to be to start tracking
Parameters:
dist
to start tracking at
Returns:
calling object
function SetWorld
inline TrackingAgent & walle::TrackingAgent::SetWorld (
cse491::WorldBase & in_world
) override
Set both the world for the current agent and the agents it is a part of
Parameters:
in_world
new world to associate the agent with
Returns:
calling agent
function TrackingAgent [1/4]
walle::TrackingAgent::TrackingAgent () = delete
Delete default constructor
function TrackingAgent [2/4]
inline walle::TrackingAgent::TrackingAgent (
size_t id,
std::string const & name
)
Constructor (default)
Parameters:
id
unique agent idname
name of path agent
function TrackingAgent [3/4]
inline walle::TrackingAgent::TrackingAgent (
size_t id,
std::string const & name,
std::vector< cse491::GridPosition > && offsets,
std::shared_ptr< Alerter > && alerter=nullptr
)
Constructor (vector)
Parameters:
id
unique agent idname
name of path agentoffsets
collection of offsets to move the agentalerter
alerter network to add agent to
Attention:
The sequence of offsets must not be empty
Attention:
alerter should be a nullptr if this tracker is not part of any group of tracking agents
function TrackingAgent [4/4]
inline walle::TrackingAgent::TrackingAgent (
size_t id,
std::string const & name,
std::string_view commands,
std::shared_ptr< Alerter > && alerter=nullptr
)
Constructor (string view)
Parameters:
id
unique agent idname
name of path agentcommands
sequence of commands to be interpreted as offsetsalerter
alerter network to add agent to
Attention:
The sequence of offsets must not be empty
Attention:
alerter should be a nullptr if this tracker is not part of any group of tracking agents
function UpdateState
inline void walle::TrackingAgent::UpdateState (
bool alerting=true
)
Handles focusing the agent onto a goal_pos, returning it to its original location, and patrolling
Parameters:
alerting
determines whether this agent should alert all other TrackingAgents in its network when its goal_pos comes into range
Note:
the inner variant type will be AStarAgent when tracking OR returning to a location, but PathAgent when patrolling
function ~TrackingAgent
inline walle::TrackingAgent::~TrackingAgent () override
Destructor
The documentation for this class was generated from the following file source/Agents/TrackingAgent.hpp