101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
//
|
|
// Created by pranshav on 11/6/24.
|
|
//
|
|
#include "gameplay.h"
|
|
using namespace std;
|
|
|
|
void createPlayer(string s){
|
|
if (s=="Random"){
|
|
RandomPlayer player1 = RandomPlayer();
|
|
} else {
|
|
StrategicPlayer player1 = StrategicPlayer();
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
//Input rows and cols
|
|
int rows, cols;
|
|
cin>>rows>>cols;
|
|
char c1,c2;
|
|
string p1,p2;
|
|
Scores *scoreList = new Scores();
|
|
|
|
//Input player 1
|
|
cin>>c1>>p1;
|
|
scoreList->addScore(c1);
|
|
|
|
//Input player 2
|
|
cin>>c2>>p2;
|
|
scoreList->addScore(c2);
|
|
|
|
Points *temp = new Points(2*rows-1, 2*cols-1);
|
|
Points *stepList = new Points();
|
|
RandomPlayer
|
|
if (p1=="Random"){
|
|
RandomPlayer player1 = RandomPlayer();
|
|
} else {
|
|
StrategicPlayer player1 = StrategicPlayer();
|
|
}
|
|
|
|
if (p2=="Random"){
|
|
RandomPlayer player2 = RandomPlayer();
|
|
} else {
|
|
StrategicPlayer player2 = StrategicPlayer();
|
|
}
|
|
|
|
|
|
Board *board = new Board(rows, cols);
|
|
// board->printBoard();
|
|
|
|
Gameplay gameplay = Gameplay();
|
|
|
|
while(true) {
|
|
if (temp->getSize()==0) {
|
|
cout<<"END"<<endl;
|
|
break;
|
|
} else {
|
|
if (p1=="Random" && p2=="Random") {
|
|
|
|
} else if (p1=="Random" && p2=="Strategic") {
|
|
j2:
|
|
RandomPlayer player1 = RandomPlayer();
|
|
point move = player1.randomMove(*temp);
|
|
move.player = c1;
|
|
cout<<move.player<<" "<<move.x<<" "<<move.y<<endl;
|
|
stepList->push(move);
|
|
board->updateBoard(move.player, move.x, move.y);
|
|
bool newTurn = board->evenRowBoxComplete(move, *scoreList, 2*rows-1, 2*cols-1) || board->oddRowBoxComplete(move, *scoreList, 2*rows-1, 2*cols-1);
|
|
if(newTurn) {
|
|
goto j2;
|
|
}
|
|
|
|
if (temp->getSize()==0) {
|
|
cout<<"END"<<endl;
|
|
break;
|
|
} else {
|
|
point move = player2.strategicMove(*board, *temp);
|
|
move.player = c2;
|
|
cout<<move.player<<" "<<move.x<<" "<<move.y<<endl;
|
|
stepList->push(move);
|
|
board->updateBoard(move.player, move.x, move.y);
|
|
newTurn = board->evenRowBoxComplete(move, *scoreList, 2*rows-1, 2*cols-1) || board->oddRowBoxComplete(move, *scoreList, 2*rows-1, 2*cols-1);
|
|
if (newTurn) {
|
|
|
|
}
|
|
}
|
|
} else if (p1=="Strategic" && p2=="Random") {
|
|
gameplay.randomFirst(c1, c2, rows, cols, player1, player2, board, stepList, scoreList, temp);
|
|
} else if (p1=="Strategic" && p2=="Strategic") {
|
|
|
|
}
|
|
}
|
|
}
|
|
// temp->printArray();
|
|
board->printBoard();
|
|
scoreList->printResults();
|
|
delete board;
|
|
delete scoreList;
|
|
delete temp;
|
|
delete stepList;
|
|
return 0;
|
|
} |