Skip to content

Class cse491_team8::ManualWorld

ClassList > cse491_team8 > ManualWorld

Inherits the following classes: WorldBase

Public Functions

Type Name
void AddMove (cse491::AgentBase & agent, std::string & move, char stat, double modification)
adds a move to the move set for an agent
int DoAction (cse491::AgentBase & agent, size_t action_id) override
Central function for an agent to take any action.
void DoActionAttemptItemPickup (cse491::AgentBase & agent, const cse491::GridPosition & new_position)
Attempt to pick up an item for the agent.
cse491::GridPosition DoActionFindNewPosition (cse491::AgentBase & agent, size_t action_id)
Updates agent's position and direction.
void DoActionTestNewPositionTree (cse491::AgentBase & agent, const cse491::GridPosition & new_position)
Attempt to interact with a tree If the agent can interact with the tree, prompts the user if they want to use one of their chops.
bool DoActionTestNewPositionWater (cse491::AgentBase & agent)
Attempt to float on a water tile If the agent has a boat, prompts the user if they want to use the boat once.
void DoBattle (cse491::AgentBase & other_agent, cse491::AgentBase & agent, char attack_type)
Checks the strength between two agents.
void DropItems (cse491::AgentBase & agent, cse491::AgentBase & other_agent)
Removes all items from other agent.
size_t FindItem (cse491::AgentBase & agent, const std::string & item_name)
Check if an agent owns an item.
void GenerateMoveSets ()
Generates move sets for all the agents Sets the move sets as a property for each agent.
void HealAction (cse491::AgentBase & agent)
Heals an Agent.
bool IsTraversable (const cse491::AgentBase &, cse491::GridPosition pos) override const
Determine if this tile can be walked on, defaults to every tile is walkable.
cse491::GridPosition LookAhead (cse491::AgentBase & agent)
looks one tile ahead of the agent based on facing direction
ManualWorld ()
void MoveSetAction (cse491::AgentBase & agent)
Displays the moveset for the agent.
int OtherAction (cse491::AgentBase & other_agent, cse491::AgentBase & agent)
Determines the damage of the other agent.
bool RemoveMove (cse491::AgentBase & agent, std::string & move)
removes a move from the move set for an agent
void Run () override
Runs agents, updates the world.
void RunAgents () override
Step through each agent giving them a chance to take an action.
void StatsAction (cse491::AgentBase & agent)
Displays the items and properties that the player has.
void UpdateWorld () override
Looks for adjacencies.
~ManualWorld () = default

Protected Types

Type Name
enum ActionType
enum FacingDirection

Protected Attributes

Type Name
size_t bridge_id
Easy access to bridge CellType ID.
size_t grass_id
Easy access to floor CellType ID.
size_t portal_id_a
Easy access to first portal CellType ID.
size_t portal_id_b
Easy access to second portal CellType ID.
size_t portal_id_c
Easy access to third portal CellType ID.
size_t portal_id_d
Easy access to fourth portal CellType ID.
size_t rock_id
Easy access to rock CellType ID.
size_t tree_id
Easy access to tree CellType ID.
size_t water_id
Easy access to water CellType ID.

Protected Functions

Type Name
void ConfigAgent (cse491::AgentBase & agent) override
Provide the agent with movement actions.

Public Functions Documentation

function AddMove

adds a move to the move set for an agent

inline void cse491_team8::ManualWorld::AddMove (
    cse491::AgentBase & agent,
    std::string & move,
    char stat,
    double modification
) 

Parameters:

  • agent the agent to add the move to
  • move the name of the move to add
  • stat the stat that the move affects
  • modification the modification percent of the move to that stat Adds a move to the move set map

Returns:

None

function DoAction

Central function for an agent to take any action.

inline int cse491_team8::ManualWorld::DoAction (
    cse491::AgentBase & agent,
    size_t action_id
) override

Parameters:

  • agent The specific agent taking the action
  • action The id of the action to take

Returns:

The result of this action (usually 0/1 to indicate success)

Note:

Thus function must be overridden in any derived world.

function DoActionAttemptItemPickup

Attempt to pick up an item for the agent.

inline void cse491_team8::ManualWorld::DoActionAttemptItemPickup (
    cse491::AgentBase & agent,
    const cse491::GridPosition & new_position
) 

Parameters:

  • agent The agent that is picking up the item.
  • new_position New position of the agent to check if an item is there.

Returns:

Nothing

function DoActionFindNewPosition

Updates agent's position and direction.

inline cse491::GridPosition cse491_team8::ManualWorld::DoActionFindNewPosition (
    cse491::AgentBase & agent,
    size_t action_id
) 

Parameters:

  • agent The agent that is moving its position
  • action_id A size_t representing the direction the agent moved

Returns:

The agent's new position

function DoActionTestNewPositionTree

Attempt to interact with a tree If the agent can interact with the tree, prompts the user if they want to use one of their chops.

inline void cse491_team8::ManualWorld::DoActionTestNewPositionTree (
    cse491::AgentBase & agent,
    const cse491::GridPosition & new_position
) 

Parameters:

  • agent The agent trying to interact
  • new_position The position being interacted with

Returns:

Nothing, the tree gets chopped if possible but the agent doesn't move

function DoActionTestNewPositionWater

Attempt to float on a water tile If the agent has a boat, prompts the user if they want to use the boat once.

inline bool cse491_team8::ManualWorld::DoActionTestNewPositionWater (
    cse491::AgentBase & agent
) 

Parameters:

  • agent The agent trying to interact

Returns:

True if the agent is able to (and chooses) to move to the new spot, else false

function DoBattle

Checks the strength between two agents.

inline void cse491_team8::ManualWorld::DoBattle (
    cse491::AgentBase & other_agent,
    cse491::AgentBase & agent,
    char attack_type
) 

Parameters:

  • other_agent The autonomous agent to compare
  • agent The interface (player) agent to compare
  • attack_type The attack that is being used by the player Prints the stronger agent and removes the weaker

See also: RemoveAgent

Returns:

None

function DropItems

Removes all items from other agent.

inline void cse491_team8::ManualWorld::DropItems (
    cse491::AgentBase & agent,
    cse491::AgentBase & other_agent
) 

Parameters:

  • agent Agent that won the battle
  • other_agent Agent that is dropping items

function FindItem

Check if an agent owns an item.

inline size_t cse491_team8::ManualWorld::FindItem (
    cse491::AgentBase & agent,
    const std::string & item_name
) 

Parameters:

  • agent The agent to see if is an owner
  • item_name Name of the item

Returns:

item_id

function GenerateMoveSets

Generates move sets for all the agents Sets the move sets as a property for each agent.

inline void cse491_team8::ManualWorld::GenerateMoveSets () 

Returns:

None

function HealAction

Heals an Agent.

inline void cse491_team8::ManualWorld::HealAction (
    cse491::AgentBase & agent
) 

Parameters:

  • agent The Agent getting healed Calculates the healing of the agent

Returns:

None

function IsTraversable

Determine if this tile can be walked on, defaults to every tile is walkable.

inline bool cse491_team8::ManualWorld::IsTraversable (
    const cse491::AgentBase &,
    cse491::GridPosition pos
) override const

Parameters:

  • pos The grid position we are checking

Returns:

If an agent should be allowed on this square

function LookAhead

looks one tile ahead of the agent based on facing direction

inline cse491::GridPosition cse491_team8::ManualWorld::LookAhead (
    cse491::AgentBase & agent
) 

Parameters:

  • agent Agent that is looking ahead

Returns:

the grid position

function ManualWorld

inline cse491_team8::ManualWorld::ManualWorld () 

function MoveSetAction

Displays the moveset for the agent.

inline void cse491_team8::ManualWorld::MoveSetAction (
    cse491::AgentBase & agent
) 

Parameters:

  • agent Agent moveset being displayed.

function OtherAction

Determines the damage of the other agent.

inline int cse491_team8::ManualWorld::OtherAction (
    cse491::AgentBase & other_agent,
    cse491::AgentBase & agent
) 

Parameters:

  • other_agent The NPC agent
  • agent The player agent Gets the damage of the NPC agent

Returns:

The damage of the NPC

function RemoveMove

removes a move from the move set for an agent

inline bool cse491_team8::ManualWorld::RemoveMove (
    cse491::AgentBase & agent,
    std::string & move
) 

Parameters:

  • agent the agent to remove a move from
  • move the name of the move to remove Removes a move from the move set map

Returns:

true for success, false for failure

function Run

inline void cse491_team8::ManualWorld::Run () override

function RunAgents

inline void cse491_team8::ManualWorld::RunAgents () override

function StatsAction

Displays the items and properties that the player has.

inline void cse491_team8::ManualWorld::StatsAction (
    cse491::AgentBase & agent
) 

Parameters:

  • agent Agent stats being showed.

function UpdateWorld

inline void cse491_team8::ManualWorld::UpdateWorld () override

function ~ManualWorld

cse491_team8::ManualWorld::~ManualWorld () = default

Protected Types Documentation

enum ActionType

enum cse491_team8::ManualWorld::ActionType {
    REMAIN_STILL =0,
    MOVE_UP,
    MOVE_DOWN,
    MOVE_LEFT,
    MOVE_RIGHT,
    USE_AXE,
    USE_BOAT,
    STATS,
    HEAL,
    RUN,
    ATTACK,
    SPECIAL,
    BUFF,
    HELP
};

enum FacingDirection

enum cse491_team8::ManualWorld::FacingDirection {
    UP =0,
    RIGHT,
    DOWN,
    LEFT
};

Protected Attributes Documentation

variable bridge_id

size_t bridge_id;

variable grass_id

size_t grass_id;

variable portal_id_a

size_t portal_id_a;

variable portal_id_b

size_t portal_id_b;

variable portal_id_c

size_t portal_id_c;

variable portal_id_d

size_t portal_id_d;

variable rock_id

size_t rock_id;

variable tree_id

size_t tree_id;

variable water_id

size_t water_id;

Protected Functions Documentation

function ConfigAgent

inline void cse491_team8::ManualWorld::ConfigAgent (
    cse491::AgentBase & agent
) override

The documentation for this class was generated from the following file source/Worlds/ManualWorld.hpp