-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
79 lines (65 loc) · 1.58 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* =====================================================================================
*
* Filename: main.cpp
*
* Description: Main file for the simulation of a Nash's environment
*
* Version: 0.1
* Created: 01/11/2010 13:23:03
* Revision: none
* Compiler: gcc
*
* Author: BlackLight (http://0x00.ath.cx), <blacklight@autistici.org>
* Licence: GNU GPL v.3
* Company: DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
*
* =====================================================================================
*/
#include <iostream>
#include <cstdlib>
#include "nash.h"
using std::cout;
using std::cerr;
using std::endl;
/**
* \brief Main function for the program
*/
int
main ( int argc, char *argv[] )
{
NashEnvironment *nash = NULL;
if ( argc < 6 )
{
cerr << "Usage: " << argv[0] << " <environment_file> <coop_coop_gain> <coop_comp_gain> <comp_coop_gain> <comp_comp_gain>" << endl;
return 1;
}
nash = new NashEnvironment ( argv[1] );
nash->init_costs (
strtod ( argv[2], NULL ),
strtod ( argv[3], NULL ),
strtod ( argv[4], NULL ),
strtod ( argv[5], NULL )
);
nash->print();
try
{
while ( nash->refresh_strategies() )
{
cout << endl;
for ( int i=0; i < nash->getCols(); i++ )
cout << "==";
cout << endl;
nash->print();
}
}
catch ( NashException e )
{
cerr << endl << e.what() << endl;
delete nash;
return 1;
}
cout << endl << "Nash's equilibrium configuration found" << endl;
delete nash;
return 0;
} /* ---------- end of function main ---------- */