81 lines
1.3 KiB
C++
81 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "Board.h"
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
|
|
cout<<"\n----------------------------"<<endl;
|
|
cout<<"Welcome to Breakthrough\n"<<endl;
|
|
cout<<"-----------------------------\n\n"<<endl;
|
|
|
|
cout<<"1. Play agains AI?"<<endl;
|
|
cout<<"2. Play against a human?"<<endl;
|
|
cout<<"Enter choice: "<<endl;
|
|
|
|
int choice;
|
|
cin>>choice;
|
|
|
|
if (choice == 1) cout<<"playing with AI..."<<endl;
|
|
else cout<<"playing with human..."<<endl;
|
|
|
|
Board b;
|
|
|
|
string move;
|
|
|
|
bool gameOver = false;
|
|
|
|
snapshot(record,b);
|
|
|
|
while (gameOver != true)
|
|
{
|
|
gameOver = b.isGameOver();
|
|
|
|
while(b.getTurn() == 'O' )
|
|
{
|
|
b.displayBoard();
|
|
cout<<"\nEnter command: ";
|
|
cin>>move;
|
|
interpret(move,b);
|
|
}
|
|
|
|
|
|
vector<moves> possibleMoves = b.viewPossibleMoves();
|
|
//displayPossibleMoves(possibleMoves); for debugging purposes - AI
|
|
|
|
if (choice == 1)
|
|
{
|
|
b.easyAI();
|
|
}
|
|
|
|
else
|
|
{
|
|
while(b.getTurn() == 'X' )
|
|
{
|
|
b.displayBoard();
|
|
cout<<"\nEnter command: ";
|
|
cin>>move;
|
|
interpret(move,b);
|
|
}
|
|
}
|
|
|
|
//b.snapshot();
|
|
gameOver = b.isGameOver();
|
|
|
|
snapshot(record,b);
|
|
}
|
|
|
|
//for debugging purposes
|
|
cout<<"Record:"<<endl;
|
|
|
|
|
|
cout<<record.size();
|
|
for (int i = 0; i < record.size(); ++i)
|
|
{
|
|
record[i].displayBoard();
|
|
}
|
|
}
|