B.A.R.G.A.M.E.  v2.0
El Farol Bar Problem Implementation
 All Classes Namespaces Files Functions Variables Typedefs Defines
Public Member Functions | Public Attributes
Strategy Class Reference

Strategy Class. More...

List of all members.

Public Member Functions

 Strategy ()
 Default Strategy Constructor.
 ~Strategy ()
 Strategy Destructor.
 Strategy (int numbars)
 Strategy Constructor.
 Strategy (Strategy *s)
 Strategy Copy Constructor.
double getScore ()
 Returns a Strategy's current score.
int getBar (long sti)
double updateScore (int i)
 Updates a given STM strategy i.
int getStrat (int shortterm)
 returns the strategy to be used by Agent for a given turn.
int hash (int shortterm)
 Randomizes keys.

Public Attributes

int st [2048]
 Short Term Structure.
double score
 A strategies Score.

Detailed Description

Strategy Class.

This class is the computaional unit of the Strategies utilized by the Agent Objects. It has simple get functions but also functions which updates and chooses stategies based on their respective score where their score respresents a strategies performance throughout the simulation


Constructor & Destructor Documentation

Default Strategy Constructor.

Default constructor NOT utilized within code.

Strategy Destructor.

Destructor

Strategy::Strategy ( int  numbars)

Strategy Constructor.

Description: Strategy Constructor that is utilized by the Agent class.

Parameters:
numbarsindicates how many bars are present for the given simulation profile.
Precondition:
0 < numbars < 256
Postcondition:
Integer array st that holds Strategies has been initialized with a random values

Strategy Copy Constructor.

Description: Strategy Constructor that is utilized by the Agent class to copy a set of Strategy's

Parameters:
sis a reference pointer to another Strategy object (usually contained within an Agent)
Precondition:
0 < numbars < 256
Postcondition:
Integer array st that holds Strategies has been initialized with a random values

Member Function Documentation

int Strategy::getBar ( long  sti)

Description: Returns which bar number the Agent will go to for a given round. This is our hashing function.

Parameters:
stishort term index
Precondition:
None.
Postcondition:
None.
double Strategy::getScore ( )

Returns a Strategy's current score.

Description: Returns a Double which represents a Strategy's current score.

Precondition:
None.
Postcondition:
None.
int Strategy::getStrat ( int  shortterm)

returns the strategy to be used by Agent for a given turn.

Description: Gets either strategy 0, 1, or, 2 because each Agent has 3 strategies to choose from.

Precondition:
0 < shortterm < 254^4 - 1
Postcondition:
Returns which strategy number(0,1,2) the Agent is going to utilize for the upcomming turn.
int Strategy::hash ( int  shortterm)

Randomizes keys.

Description: Randomizes keys that are greater than 2048 in order to attempt to minimize memory usage. Is an explicit Hash function.

Parameters:
shorttermthe value that is greater than 2048 (2^11)
Precondition:
shortterm > 2048
Postcondition:
new number maps to smaller number than 2048
double Strategy::updateScore ( int  i)

Updates a given STM strategy i.

Description: A strategies previous score is updated for a given turn.

Parameters:
iOne of the STM stragtegies stored in strats[]
Note:
In this case our application only keeps track of the last 3 strategies.
Precondition:
None.
Postcondition:
Private variable "score" is updated.

Member Data Documentation

A strategies Score.

Contains the score of a strategy

Note:
scaled on values from 0 (worst) to 10 (best)
int Strategy::st[2048]

Short Term Structure.

The structure used to store all possible STM combinations


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