-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mim_Lennig_FinalProject.cpp
105 lines (89 loc) · 3.98 KB
/
Mim_Lennig_FinalProject.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Mim_Lennig_FinalProject.cpp
// COEN 432
// Assignment #1 A
//
// Created by Miriam Lennig on 2016-11-25.
// Copyright © 2018 Miriam Lennig. All rights reserved.
//
#include <iostream>
#include "Mim_Lennig_FinalProject_classes.hpp"
int main() {
enum RunMode{humanVSevolved = 0, humanVSstandard, standardVSevolved};
RunMode runmode;
int rm;
cout << "Choose a run mode by entering an integer as follows:\n";
cout << "\t0 : human player vs winner of evolution.\n";
cout << "\t1 : human player vs standard player.\n";
cout << "\t2 : standard player vs evolved player.\n";
cout << "Enter integer run mode: ";
cin >> rm;
runmode = RunMode(rm);
if(runmode == humanVSevolved){
// Human player can play against winner of evolution
Evolution e;
Strategy* AA = e.getWinner();
Game g0(AA, 0);
while(!g0.isOver()){
g0.print();
g0.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g0.getNumBricks(0) << "; Player 1 score: " << g0.getNumBricks(1) << endl;
Game g1(0, AA);
while(!g1.isOver()){
g1.print();
g1.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g1.getNumBricks(0) << "; Player 1 score: " << g1.getNumBricks(1) << endl;
}
else if(runmode == humanVSstandard){
// Human player can play against standard player
Strategy* standardPlayer = new Strategy(0);
Game g0(standardPlayer, 0);
while(!g0.isOver()){
g0.print();
g0.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g0.getNumBricks(0) << "; Player 1 score: " << g0.getNumBricks(1) << endl;
Game g1(0, standardPlayer);
while(!g1.isOver()){
g1.print();
g1.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g1.getNumBricks(0) << "; Player 1 score: " << g1.getNumBricks(1) << endl;
}
else if(runmode == standardVSevolved){
// Standard player and evolution winner play against each other
Evolution e;
Strategy* AA = e.getWinner();
Strategy* standardPlayer = new Strategy(0);
cout << "\nGame 0: Evolved moves first and standard player moves second.\n";
Game g0(AA, standardPlayer);
while(!g0.isOver()){
g0.print();
g0.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g0.getNumBricks(0) << "; Player 1 score: " << g0.getNumBricks(1) << endl;
cout << "\nGame 1: Standard player moves first and evolved moves second.\n";
Game g1(standardPlayer, AA);
while(!g1.isOver()){
g1.print();
g1.makeHalfMove();
}
cout << "Game over. Player 0 score: " << g1.getNumBricks(0) << "; Player 1 score: " << g1.getNumBricks(1) << endl << endl;
if(g0.getNumBricks(0) > g0.getNumBricks(1))
cout << "Evolved player played first and won against the standard player in the first game.\n";
else if(g0.getNumBricks(0) < g0.getNumBricks(1))
cout << "Evolved player played first and lost to the standard player in the first game.\n";
else
cout << "Evolved player played first and tied with the standard player in the first game.\n";
if(g1.getNumBricks(0) > g1.getNumBricks(1))
cout << "Standard player played first and won against the evolved player in the second game.\n";
else if(g1.getNumBricks(0) < g1.getNumBricks(1))
cout << "Standard player played first and lost against the evolved player in the second game.\n";
else
cout << "Standard player played first and tied with the evolved player in the second game.\n";
}
cout << "\nAA average CPU time per move = " << Game::getTiming() << " microseconds" << endl;
cout << "based upon " << Game::getTotAAmoves() << " moves."<< endl << endl;
}