-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (52 loc) · 1.63 KB
/
main.cpp
File metadata and controls
59 lines (52 loc) · 1.63 KB
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
#include <iostream>
#include "game.h"
static const string HOME = "/Users/heliou/Documents/these/theorie_jeux/Hedge2P2S/";
void fill_payoff(double** payoff1, double** payoff2){
double test1 = payoff1[0][0] - payoff1[0][1] + payoff2[1][0];
double test2 = payoff1[1][0] - payoff1[1][1] + payoff2[0][0] - payoff2[0][1];
payoff2[1][1] = test1 - test2;
}
void random_payoff(double** payoff1, double** payoff2){
for (int i=0;i<2;i++){
for (int j =0;j<2;j++){
payoff1[i][j] = (rand() % 10)/10.0;
payoff2[i][j] = (rand() % 10)/10.0;
}
}
fill_payoff(payoff1,payoff2);
}
void print_payoffs(double** payoff1, double** payoff2){
std::cout<<"Payoff1 against 1 :"<<payoff1[0][0]<<" "<<payoff1[0][1]<<std::endl;
std::cout<<"Payoff1 against 2 :"<<payoff1[1][0]<<" "<<payoff1[1][1]<<std::endl;
std::cout<<"Payoff2 against 1 :"<<payoff2[0][0]<<" "<<payoff2[0][1]<<std::endl;
std::cout<<"Payoff2 against 2 :"<<payoff2[1][0]<<" "<<payoff2[1][1]<<std::endl;
}
int main() {
double** payoff1 = new double* [2];
double** payoff2 = new double* [2];
for( int i=0;i<2;i++){
payoff1[i]=new double[2];
payoff2[i]=new double[2];
}
//random_payoff(payoff1,payoff2);
srand(0);
payoff1[1][1]=100/110.0;
payoff1[1][0]=1;
payoff1[0][1]=100/110.0;
payoff1[0][0]=0;
payoff2[1][1]=100/110.0;
payoff2[1][0]=1;
payoff2[0][1]=100/110.0;
fill_payoff(payoff1,payoff2);
print_payoffs(payoff1,payoff2);
int seeds[20];
for (int i=0;i<20;i++){
seeds[i]=rand();
}
for (int seed : seeds){
srand(seed);
Game* G=new Game(payoff1, payoff2, 1000);
G->play(HOME+"out-s"+to_string(seed)+".dat");
}
return 0;
}