Skip to content

Class cowboys::GPAgentBase

ClassList > cowboys > GPAgentBase

Inherits the following classes: AgentBase

Inherited by the following classes: cowboys::CGPAgent, cowboys::LGPAgent

Public Functions

Type Name
virtual void Copy (const GPAgentBase & other) = 0
Copy the behavior of another agent into this agent.
virtual std::string Export ()
GPAgentBase (size_t id, const std::string & name)
virtual size_t GetAction (const cse491::WorldGrid & grid, const cse491::type_options_t & type_options, const cse491::item_map_t & item_set, const cse491::agent_map_t & agent_set) = 0
const std::unordered_map< std::string, double > GetExtraState () const
Get a map of extra state information.
double GetRandom ()
Return a uniform random value between 0.0 and 1.0.
double GetRandom (double max)
Return a uniform random value between 0.0 and max.
double GetRandom (double min, double max)
Return a uniform random value between min and max.
double GetRandomNormal ()
Return a gaussian random value with mean 0.0 and sd 1.0.
double GetRandomNormal (double mean, double sd=1.0)
Return a gaussian random value with provided mean and sd.
size_t GetRandomULL (size_t max)
Return a uniform random unsigned long long between 0 (inclusive) and max (exclusive)
unsigned int GetSeed () const
Get the seed used to initialize this RNG.
virtual void Import (const std::string & genotype) = 0
bool Initialize () override
Setup graph.
virtual void MutateAgent (double mutation_rate=0.8) = 0
Mutate this agent.
virtual void PrintAgent ()
virtual void Reset (bool=false)
size_t SelectAction (const cse491::WorldGrid & grid, const cse491::type_options_t & type_options, const cse491::item_map_t & item_set, const cse491::agent_map_t & agent_set) override
Choose the action to take a step in the appropriate direction.
virtual void SerializeGP (tinyxml2::XMLDocument & doc, tinyxml2::XMLElement * parentElem, double fitness=-1) = 0
void SetSeed (unsigned int seed)
Set the seed used to initialize this RNG.
~GPAgentBase () = default

Protected Attributes

Type Name
std::unordered_map< std::string, double > extra_state
A map of extra state information.
std::normal_distribution< double > norm_dist
Normal distribution.
std::mt19937 rng = {seed}
Random number generator.
unsigned int seed = = 0
Seed for the random number generator.
std::uniform_real_distribution< double > uni_dist
Uniform distribution.

Public Functions Documentation

function Copy

Copy the behavior of another agent into this agent.

virtual void cowboys::GPAgentBase::Copy (
    const GPAgentBase & other
) = 0

Parameters:

  • other The agent to copy. Should be the same type.

function Export

inline virtual std::string cowboys::GPAgentBase::Export () 

function GPAgentBase

inline cowboys::GPAgentBase::GPAgentBase (
    size_t id,
    const std::string & name
) 

function GetAction

virtual size_t cowboys::GPAgentBase::GetAction (
    const cse491::WorldGrid & grid,
    const cse491::type_options_t & type_options,
    const cse491::item_map_t & item_set,
    const cse491::agent_map_t & agent_set
) = 0

function GetExtraState

Get a map of extra state information.

inline const std::unordered_map< std::string, double > cowboys::GPAgentBase::GetExtraState () const

Returns:

Map of extra state information

function GetRandom [1/3]

inline double cowboys::GPAgentBase::GetRandom () 

function GetRandom [2/3]

inline double cowboys::GPAgentBase::GetRandom (
    double max
) 

function GetRandom [3/3]

inline double cowboys::GPAgentBase::GetRandom (
    double min,
    double max
) 

function GetRandomNormal [1/2]

inline double cowboys::GPAgentBase::GetRandomNormal () 

function GetRandomNormal [2/2]

inline double cowboys::GPAgentBase::GetRandomNormal (
    double mean,
    double sd=1.0
) 

function GetRandomULL

inline size_t cowboys::GPAgentBase::GetRandomULL (
    size_t max
) 

function GetSeed

inline unsigned int cowboys::GPAgentBase::GetSeed () const

function Import

virtual void cowboys::GPAgentBase::Import (
    const std::string & genotype
) = 0

function Initialize

Setup graph.

inline bool cowboys::GPAgentBase::Initialize () override

Returns:

Success.

function MutateAgent

Mutate this agent.

virtual void cowboys::GPAgentBase::MutateAgent (
    double mutation_rate=0.8
) = 0

Parameters:

  • mutation_rate The mutation rate. Between 0 and 1.

function PrintAgent

inline virtual void cowboys::GPAgentBase::PrintAgent () 

function Reset

inline virtual void cowboys::GPAgentBase::Reset (
    bool=false
) 

function SelectAction

inline size_t cowboys::GPAgentBase::SelectAction (
    const cse491::WorldGrid & grid,
    const cse491::type_options_t & type_options,
    const cse491::item_map_t & item_set,
    const cse491::agent_map_t & agent_set
) override

function SerializeGP

virtual void cowboys::GPAgentBase::SerializeGP (
    tinyxml2::XMLDocument & doc,
    tinyxml2::XMLElement * parentElem,
    double fitness=-1
) = 0

function SetSeed

inline void cowboys::GPAgentBase::SetSeed (
    unsigned int seed
) 

function ~GPAgentBase

cowboys::GPAgentBase::~GPAgentBase () = default

Protected Attributes Documentation

variable extra_state

std::unordered_map<std::string, double> extra_state;

variable norm_dist

std::normal_distribution<double> norm_dist;

variable rng

std::mt19937 rng;

variable seed

unsigned int seed;

variable uni_dist

std::uniform_real_distribution<double> uni_dist;

The documentation for this class was generated from the following file source/Agents/GP/GPAgentBase.hpp