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 | Protected Member Functions | Protected Attributes
BARGAME::Form2 Class Reference

List of all members.

Public Member Functions

 Form2 (double numagents, int numbars1, int barcap[], bool ispercentcap, int *loading)
 Form2 Constructor.
 ~Form2 ()
 Form2 Destructor.

Protected Member Functions

delegate void SetTextDelegate (String^ text)
 Delegate for thread safety.
void runner (double *data)
 Chart Method.
void winningbars (double data[], int size, int leftorright)
 Winning Bars Method.
void winners (double data[], int size, int leftorright)
 Winners Method.
void avgstratscores (double data[], int size, int leftorright)
 Average Strategy Scores Method.
void beststrat (double data[], int size, int leftorright)
 Best Strategy Method.
void bardist (double data[], int size, int leftorright)
 Bar Distribution Method.
void numdeaths (double data[], int size, int leftorright)
 Number of Deaths Method.
void agedist (double data[], int size, int leftorright)
 Age Distribution Method.
System::Void button2_Click (System::Object^ sender, System::EventArgs^ e)
 Start/Resume Simulation Button.
void ThreadProcSafe ()
 Backend Method.
void SetText (String^ text)
 Round Number Method.
void MarshalString (String^ s, string &os)
 Marshal String Method.
void ComboBox1_SelectedIndexChanged (Object^ sender, System::EventArgs^ e)
 Left Drop-down Event.
void ComboBox2_SelectedIndexChanged (Object^ sender, System::EventArgs^ e)
 Right Drop-down Event.
System::Void Form2_FormClosed (System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)
 Form2 Close Event.

Protected Attributes

String^ filename
 String that holds output file name.
int numbars
 Integer which holds number of bars.
int sleepytime
 Integer which holds speed of round.
int selectedindex1
 Integer which represents left side of displayed chart.
int selectedindex2
 Integer which represents right side of displayed chart.
int stop
 Integer that tells the thread to stop.
int turn
 Integer which holds current round number.
Towntown
 Town pointer used for backend.
double * ultimategraph
 Array which holds all data needed for all charts. Offsets are used to give specific data to chart methods.
graphPtr t
 graphPtr object used for backend.
Thread^ backendthread
 Thread which backend is run on.

Constructor & Destructor Documentation

BARGAME::Form2::Form2 ( double  numagents,
int  numbars1,
int  barcap[],
bool  ispercentcap,
int *  loading 
)

Form2 Constructor.

Description: Initializes the components of Form2 and private variables with default values, and calls Town's constructor with input data from Simulation Button.

Parameters:
numagentsNumber of agents
numbars1Number of bars
barcap[]Array holding bar capacities
ispercentcapBool representing if capacity is of type percent
*loadingInteger used for progress bar that gives a percent of completion

Form2 Destructor.

Description: Deletes components of Form2.


Member Function Documentation

void BARGAME::Form2::agedist ( double  data[],
int  size,
int  leftorright 
) [protected]

Age Distribution Method.

Description: This method uses the ChartDirector API to create the graph for "Age Distribution" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
void BARGAME::Form2::avgstratscores ( double  data[],
int  size,
int  leftorright 
) [protected]

Average Strategy Scores Method.

Description: This method uses the ChartDirector API to create the graph for "Average Score of All Strategies" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
void BARGAME::Form2::bardist ( double  data[],
int  size,
int  leftorright 
) [protected]

Bar Distribution Method.

Description: This method uses the ChartDirector API to create the graph for "Wins per Bar" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
void BARGAME::Form2::beststrat ( double  data[],
int  size,
int  leftorright 
) [protected]

Best Strategy Method.

Description: This method uses the ChartDirector API to create the graph for "Best Strategy's Scores" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
System::Void BARGAME::Form2::button2_Click ( System::Object^  sender,
System::EventArgs^  e 
) [protected]

Start/Resume Simulation Button.

Description: Button that retrieves speed and selected dropdown options and starts thread to run backend. Also acts as a pause button which stops and starts backend thread.

Precondition:
Speed is set and charts are chosen from dropdown.
Postcondition:
Chart is displayed and updated in realtime in GUI.
void BARGAME::Form2::ComboBox1_SelectedIndexChanged ( Object^  sender,
System::EventArgs^  e 
) [protected]

Left Drop-down Event.

Description: Event that changes displayed chart type when new chart is selected.

Precondition:
Form2 is created.
Postcondition:
Selected chart is displayed.
void BARGAME::Form2::ComboBox2_SelectedIndexChanged ( Object^  sender,
System::EventArgs^  e 
) [protected]

Right Drop-down Event.

Description: Event that changes displayed chart type when new chart is selected.

Precondition:
Form2 is created.
Postcondition:
Selected chart is displayed.
System::Void BARGAME::Form2::Form2_FormClosed ( System::Object^  sender,
System::Windows::Forms::FormClosedEventArgs^  e 
) [protected]

Form2 Close Event.

Description: Event that stops backend thread and deletes dynamically allocated memory.

Precondition:
Form2 is created.
Postcondition:
Form2 exits.
void BARGAME::Form2::MarshalString ( String^  s,
string &  os 
) [protected]

Marshal String Method.

Description: Method that converts System::String^ variable to string varib=able.

Parameters:
textString containing current round number.
Precondition:
None.
Postcondition:
System::String^ has been converted to string.
void BARGAME::Form2::numdeaths ( double  data[],
int  size,
int  leftorright 
) [protected]

Number of Deaths Method.

Description: This method uses the ChartDirector API to create the graph for "Number of Deaths" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
void BARGAME::Form2::runner ( double *  data) [protected]

Chart Method.

Description: This method calls corresponding methods to create charts based on what is selected from dropdowns.

Parameters:
*dataArray which holds data for charts.
Precondition:
Chart data exists.
Postcondition:
Chart is displayed in GUI.
void BARGAME::Form2::SetText ( String^  text) [protected]

Round Number Method.

Description: Method that updates current round number in real time.

Parameters:
textString containing current round number.
Precondition:
Backend thread started.
Postcondition:
Current round number displayed.
delegate void BARGAME::Form2::SetTextDelegate ( String^  text) [protected]

Delegate for thread safety.

void BARGAME::Form2::ThreadProcSafe ( ) [protected]

Backend Method.

Description: Method passed to thread that runs backend, updates speed if changed, creates data for graphs, calls runner method, and dumps graph data to output file.

Precondition:
Backend succesfully intialized from Form2 constructor.
Postcondition:
Chart data is created and sent to runner(), output file is created and populated.
void BARGAME::Form2::winners ( double  data[],
int  size,
int  leftorright 
) [protected]

Winners Method.

Description: This method uses the ChartDirector API to create the graph for "Number of Winners" option.

Parameters:
dataArray which holds data for charts.
sizeNumber of elements to be passed to ChartDirector API.
leftorrightInteger which tells the method to display graph on either right or left side of GUI.
Precondition:
Chart data exists.
Postcondition:
Chart is created.
void BARGAME::Form2::winningbars ( double  data[],
int  size,
int  leftorright 
) [protected]

Winning Bars Method.

Description: This method uses the ChartDirector API to create the graph for "Number of Bars that Won" option.

Parameters:
dataArray which holds data for charts.
Precondition:
Chart data exists.
Postcondition:
Chart is created.

Member Data Documentation

Thread ^ BARGAME::Form2::backendthread [protected]

Thread which backend is run on.

String ^ BARGAME::Form2::filename [protected]

String that holds output file name.

int BARGAME::Form2::numbars [protected]

Integer which holds number of bars.

Integer which represents left side of displayed chart.

Integer which represents right side of displayed chart.

int BARGAME::Form2::sleepytime [protected]

Integer which holds speed of round.

int BARGAME::Form2::stop [protected]

Integer that tells the thread to stop.

graphPtr object used for backend.

Town* BARGAME::Form2::town [protected]

Town pointer used for backend.

int BARGAME::Form2::turn [protected]

Integer which holds current round number.

double* BARGAME::Form2::ultimategraph [protected]

Array which holds all data needed for all charts. Offsets are used to give specific data to chart methods.


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