B.A.R.G.A.M.E.
v2.0
El Farol Bar Problem Implementation
|
Public Member Functions | |
Agent () | |
Default Agent Constructor. | |
~Agent () | |
Agent Destructor. | |
Agent (int numberOfBars, int avgAge, int dropS, Strategy *s1, Strategy *s2, Strategy *s3) | |
Agent Reborn Constructor. | |
Agent (int numberOfBars, int avgAge, int dropS) | |
Agent Constructor. | |
int | isGoingToBar (int STM) |
Computational function which decides which Bar to visit. | |
Strategy ** | tellWins (int winners[], int STM) |
Agent attribute Updater. | |
bool | isDead (pass_graph *stuff) |
Determines if an Agent has expired. | |
Protected Attributes | |
Strategy ** | strats |
Strategy Container. | |
int | numberOfBars |
Number Of Bars. | |
int | age |
An Agent's current age. | |
int | death |
An Agents predetermined expiration date. | |
int | bar |
Attended Bar. | |
int | drop |
Alpha Value. |
Agent Class.
This is the Agent class which contains the Agent member functions. The constructor intializes an individual Agent Object while the other member functions
take from a pool of 20 best stragies at random
Agent::Agent | ( | ) |
Default Agent Constructor.
Default constructor NOT utilized within code.
Agent::~Agent | ( | ) |
Agent Destructor.
Destructor deletes an Agents Strategies when destructing the Angent object.
Agent::Agent | ( | int | numberOfBars, |
int | avgAge, | ||
int | dropS, | ||
Strategy * | s1, | ||
Strategy * | s2, | ||
Strategy * | s3 | ||
) |
Agent Reborn Constructor.
Description: Initializes an Agents Strategy.
numberOfBars | indicates how many bars will be in the simulation. Initializes an Agents STM |
avgAge | Indicates the Average Age at which an Agent will expire. |
dropS | Indicates the threshold at which the given Agent will replace the poorly performing Strategy |
s1 | One of the 20 best performing Strategy's that this Agent will have in their STM |
s2 | One of the 20 best performing Strategy's that this Agent will have in their STM |
s3 | One of the 20 best performing Strategy's that this Agent will have in their STM |
Agent::Agent | ( | int | numberOfBars, |
int | avgAge, | ||
int | dropS | ||
) |
Agent Constructor.
Description: Initializes an Agents Strategy.
numberOfBars | indicates how many bars will be in the simulation. Initializes an Agents STM |
avgAge | Indicates the Average Age at which an Agent will expire. |
dropS | Indicates the threshold at which the given Agent will replace the poorly performing Strategy |
bool Agent::isDead | ( | pass_graph * | stuff | ) |
Determines if an Agent has expired.
Description: This function references an Agents protected variable, "age" and compares this value to an Agents predetermined age to die named "death". The function returns the outcome of this comparision.
stuff | Pointer holding data for graphs. |
int Agent::isGoingToBar | ( | int | STM | ) |
Computational function which decides which Bar to visit.
Description: This function, using a random number generator, picks a strategy (i.e. Strategy 0 to 2) to utilize where the Agent is going to bar for the current turn.
STM | Integer pointer that refers to the STM structure. |
Strategy** Agent::tellWins | ( | int | winners[], |
int | STM | ||
) |
Agent attribute Updater.
Description: This function takes in an array of currents turn bar winners and the current STM, it then uses this information to update Strategy scores and if score drops below predefined threshold the strategy is replaced with another. It then returns needed variables. to the GUI.
winners[] | holds 1 if bar won 0 if bar lost |
STM | Short Term Memory |
int Agent::age [protected] |
int Agent::bar [protected] |
int Agent::death [protected] |
An Agents predetermined expiration date.
Indicates the number of rounds an Agent will participate in before expiring and no longer particapting for the rest of the duration of the simulation.
int Agent::drop [protected] |
Alpha Value.
Indicates the threshold for which a strategy will be dropped when an agent is in a group.
int Agent::numberOfBars [protected] |
Number Of Bars.
Indicates the number of Bar Objects in the simulation.
Strategy** Agent::strats [protected] |