B.A.R.G.A.M.E. v2.0 El Farol Bar Problem Implementation

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Defines
Public Member Functions | Protected Attributes
Agent Class Reference

Agent Class. More...

List of all members.

## 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.

## Detailed Description

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

## Constructor & Destructor Documentation

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.

Parameters:

  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

Precondition:
  0 < numberofBars < 256, 0 < avgAge < 100, 0 < dropS < 100, The Simulation has begun.

Postcondition:
  An Agents Strategies has been initialized to random values .

Agent::Agent | ( | int | numberOfBars,
|  | int | avgAge,
|  | int | dropS
| ) |  |

Agent Constructor.

Description: Initializes an Agents Strategy.

Parameters:

  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

Precondition:
  0 < numberofBars < 256, 0 < avgAge < 100, 0 < dropS < 100, The Simulation has begun.

Postcondition:
  An Agent Object has been created as well as its Strategies has been initialized to random values.

## Member Function Documentation

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.

Precondition:
  An Agent object has been fully initialized.

Parameters:

  stuff | Pointer holding data for graphs.

Postcondition:
  None.

Returns:
  Boolean of either True or False.

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.

Parameters:

  STM | Integer pointer that refers to the STM structure.

See also:
  Town::STM, Town

Precondition:
  A turn has just begun.

Postcondition:
  The Agent successfully decided where they are going for the current turn.

Returns:
  Integer indicating which Bar Object the Agent has decided to visit for the current round.

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.

Parameters:

  winners[] | holds 1 if bar won 0 if bar lost
  STM | Short Term Memory

Precondition:
  Bars have decided if they won the current round.

Postcondition:
  Strategies score of agent has been updated appropriately and strategies have been replaced of necessary.

Returns:
  Double pointer referencing maxScore and avgScore

## Member Data Documentation

int Agent::age`[protected]`

An Agent's current age.

Indicates how old an Agent is.

int Agent::bar`[protected]`

Attended Bar.

Indicates the Bar number that the Agent has attended for a current round.

Note:
  NOT modifiable. For score keeping purposes only.

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.

Note:
  Set to -1 if death option is NOT selected.

int Agent::drop`[protected]`

Alpha Value.

Indicates the threshold for which a strategy will be dropped when an agent is in a group.

Note:
  NOT modifiable. For score keeping purposes only.

int Agent::numberOfBars`[protected]`

Number Of Bars.

Indicates the number of Bar Objects in the simulation.

Strategy** Agent::strats`[protected]`

Strategy Container.

Contains the three Strategy options available to an Agent.

The documentation for this class was generated from the following file:

- Doxygen Specific Source Code/Agent.h