-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
82 lines (68 loc) · 2.12 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
79
80
81
82
#include <iostream>
#include <vector>
#include "Board.h"
#include "Human.h"
#include "BotMinMax.h"
#include "BotType1.h"
#include "BotType2.h"
#include "BotType3.h"
#include "BotHillClimb.h"
using namespace std;
void playQuixo()
{
int playerTypes[2];
cout<<"Player 1 should be: 0 for human, 1 for type1, 2 for type2, 3 for type3, 4 for hillclimb: ";
cin>>playerTypes[0];
cout<<"Player 2 should be: 0 for human, 1 for type1, 2 for type2, 3 for type3, 4 for hillclimb: ";
cin>>playerTypes[1];
Board playingBoard;
playingBoard.print();
char currentStatus;
int turn = 0;
while((currentStatus = playingBoard.terminalTest()) == 'N')
{
int playerIdx = turn%2;
int playerType = playerTypes[playerIdx];
char currentPlayerSymbol = playerIdx == 0 ? 'X' : 'O';
char otherPlayerSymbol = playerIdx == 0 ? 'O' : 'X';
cout<<"--------------------------------"<<endl;
cout<<"PLAYER "<< playerIdx+1 <<" TURN!"<<endl;
cout<<"--------------------------------"<<endl;
Player* currentPlayer;
switch(playerType)
{
case 0:
currentPlayer = new Human(playingBoard, currentPlayerSymbol, otherPlayerSymbol);
break;
case 1:
currentPlayer = new BotType1(playingBoard, currentPlayerSymbol, otherPlayerSymbol);
break;
case 2:
currentPlayer = new BotType2(playingBoard, currentPlayerSymbol, otherPlayerSymbol);
break;
case 3:
currentPlayer = new BotType3(playingBoard, currentPlayerSymbol, otherPlayerSymbol);
break;
case 4:
currentPlayer = new BotHillClimb(playingBoard, currentPlayerSymbol, otherPlayerSymbol);
break;
}
playingBoard = currentPlayer->playMove();
playingBoard.print();
turn++;
}
if(currentStatus == 'X')
{
cout<<"X WINS!!"<<endl;
cout<<"Played for "<<turn<<" turns.";
}
else if(currentStatus == 'O')
{
cout<<"O WINS!!"<<endl;
cout<<"Played for "<<turn<<" turns.";
}
}
int main()
{
playQuixo();
}