Skip to content

Class cse491::InterfaceBase

ClassList > cse491 > InterfaceBase

Inherits the following classes: cse491::AgentBase

Public Functions

Type Name
InterfaceBase (size_t id, const std::string & name)
virtual bool IsInterface () override const
Is Entity an interface for a human?
~InterfaceBase () = default

Public Functions inherited from cse491::AgentBase

See cse491::AgentBase

Type Name
virtual AgentBase & AddAction (const std::string & action_name, size_t action_id)
Provide a new action that this agent can take.
AgentBase (size_t id, const std::string & name)
Default value upon initialization.
virtual void Deserialize_impl (std::istream & is) override
Deserialize item-specific values and call Entity 's Deserialize_impl.
size_t GetActionID (const std::string & action_name) const
Return an action ID if that action exists, otherwise return zero.
int GetActionResult () const
Retrieve the result of the most recent action.
State GetAgentState ()
Get the current state of the Agent.
virtual GridPosition GetNextPosition ()
Allow derived agents to provide an arbitrary next position for the world to move the agent to.
virtual std::string GetTypeName_impl () override const
Override to allow access the derived name for this type.
bool HasAction (const std::string & action_name) const
Test if agent already has a specified action.
virtual bool Initialize ()
Run AFTER the world configures the agent, for additional tests or setup.
virtual bool IsAgent () override const
Is Entity an autonomous agent?
virtual void Notify (const std::string &, const std::string &="none")
Send a notification to this agent, typically from the world.
virtual size_t SelectAction (const WorldGrid & grid, const type_options_t & type_options, const item_map_t & item_map, const agent_map_t & agent_map)
Decide the next action for this agent to perform; should be overridden!
virtual void Serialize_impl (std::ostream & os) override const
Serialize item-specific values and call Entity 's Serialize_impl.
void SetActionResult (int result)
Update the result from the most recent action.
void TakeDamage (cse491::AgentBase & agent)
If the agent is in State::Taking_Damage, decrease the health by the damage factor once per timestep.
void UpdateAgentState (cse491::AgentBase & agent)
Updates an Agent's state depending on health.
void storeActionMap (std::string name)
~AgentBase () = default

Public Functions inherited from cse491::Entity

See cse491::Entity

Type Name
Entity & AddItem (size_t id)
Entity & AddItem (Entity & item)
virtual void Deserialize_impl (std::istream & is) override
Serialize entity-specific values.
Entity (size_t id, const std::string & name)
Entity (const Entity &) = delete
Entity (Entity &&) = default
size_t GetGridID () const
size_t GetID () const
std::vector< size_t > GetInventory () const
const std::string & GetName () const
size_t GetNumProperties () const
How many properties does this entity have?
GridPosition GetPosition () const
const T & GetProperty (const std::string & name) const
Return the current value of the specified property.
property_map_t & GetPropertyMap ()
return the property map for the entity
PropertyType GetPropertyType (const std::string & name) const
WorldBase & GetWorld () const
bool HasItem (size_t id) const
Inventory Management.
bool HasProperty (const std::string & name) const
Does this agent have a property with the specified name?
bool HasWorld () const
virtual bool IsAgent () const
Is Entity an autonomous agent?
virtual bool IsInterface () const
Is Entity an interface for a human?
virtual bool IsItem () const
Is Entity an item?
bool IsOnGrid (size_t in_grid_id) const
Entity & RemoveItem (size_t id)
Entity & RemoveItem (Entity & item)
Entity & RemoveProperty (const std::string & name)
Completely remove a property from an Entity .
virtual void Serialize_impl (std::ostream & os) override const
Serialize entity-specific values.
Entity & SetName (const std::string in_name)
Entity & SetPosition (GridPosition in_pos, size_t grid_id=0)
Entity & SetPosition (double x, double y)
Entity & SetProperties ()
Allow for setting multiple properties at once.
Entity & SetProperties (const std::string & name, VALUE_T && value, EXTRA_Ts &&... extras)
Entity & SetProperty (const std::string & name, const T & value)
Change the value of the specified property (will create if needed)
virtual Entity & SetWorld (WorldBase & in_world)
Entity & operator= (const Entity &) = delete
Entity & operator= (Entity &&) = delete
virtual ~Entity () = default

Public Functions inherited from cse491::CoreObject

See cse491::CoreObject

Type Name
void Deserialize (std::istream & is)
Restore the state of this object, extracting it from the provided stream.
bool Deserialize (std::string filename)
A version of Deserialize that accepts a filename to read this object from.
std::string GetTypeName () const
Access the derived name for this type.
void Serialize (std::ostream & os) const
Store the current state of this object for later extraction.
bool Serialize (std::string filename) const
A version of Serialize that accepts a filename for saving just this object.
auto operator<=> (const CoreObject &) const
virtual ~CoreObject ()

Protected Types inherited from cse491::Entity

See cse491::Entity

Type Name
typedef std::unordered_map< std::string, std::unique_ptr< PropertyBase > > property_map_t
Every entity can have a simple set of properties (with values) associated with it.

Protected Attributes inherited from cse491::AgentBase

See cse491::AgentBase

Type Name
int action
Action that agent is currently performing.
std::unordered_map< std::string, size_t > action_map
Map of names to action ids.
int action_result = = 0
Usually a one (success) or zero (failure).
State agent_state = = Healthy

Protected Attributes inherited from cse491::Entity

See cse491::Entity

Type Name
size_t grid_id = = 0
Which grid is this entity on?
size_t id = = 0
Unique ID for this entity (0 is used for "no ID")
std::vector< size_t > inventory
What entity ids are held by this entity?
std::string name = = ""
Name for this entity (E.g., "Player 1" or "+2 Sword")
GridPosition position
Where on the grid is this entity?
property_map_t property_map

Protected Functions inherited from cse491::Entity

See cse491::Entity

Type Name
Property< T > & AsProperty (const std::string & name) const

Protected Functions inherited from cse491::CoreObject

See cse491::CoreObject

Type Name
virtual void Deserialize_impl (std::istream &) = 0
Override to restore the state of this object from the provided stream.
bool EndDeserialize (std::istream & is)
Set up end of the deserialization for this class (does type checking)
void EndSerialize (std::ostream & os) const
Set up end of the serialization for this class (allows checking later)
virtual std::string GetTypeName_impl () const = 0
Override to allow access the derived name for this type.
virtual void Serialize_impl (std::ostream &) const = 0
Override to store the current state of this object for later extraction.
bool StartDeserialize (std::istream & is)
Set up beginning of the deserialization for this class (does type checking)
void StartSerialize (std::ostream & os) const
Set up beginning of the serialization for this class (allows checking later)

Protected Static Functions

Type Name
void exitCleanup ()

Public Functions Documentation

function InterfaceBase

inline cse491::InterfaceBase::InterfaceBase (
    size_t id,
    const std::string & name
) 

function IsInterface

inline virtual bool cse491::InterfaceBase::IsInterface () override const

Implements cse491::Entity::IsInterface

function ~InterfaceBase

cse491::InterfaceBase::~InterfaceBase () = default

Protected Static Functions Documentation

function exitCleanup

static inline void cse491::InterfaceBase::exitCleanup () 

The documentation for this class was generated from the following file source/core/InterfaceBase.hpp