This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
breakthroughpine64backup/main.cpp

82 lines
1.3 KiB
C++
Raw Normal View History

2015-10-17 17:34:19 -05:00
#include <iostream>
#include <vector>
#include <stdlib.h>
2015-10-17 19:18:47 -05:00
#include <stdio.h>
2015-10-19 16:37:20 -05:00
#include "Board.h"
2015-10-17 17:34:19 -05:00
using namespace std;
int main()
{
2015-10-19 15:51:48 -05:00
cout<<"\n----------------------------"<<endl;
2015-10-17 17:34:19 -05:00
cout<<"Welcome to Breakthrough\n"<<endl;
2015-10-19 15:51:48 -05:00
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;
2015-10-17 17:34:19 -05:00
Board b;
string move;
bool gameOver = false;
2015-10-19 15:51:48 -05:00
snapshot(record,b);
2015-10-17 17:34:19 -05:00
while (gameOver != true)
{
gameOver = b.isGameOver();
2015-10-19 15:51:48 -05:00
while(b.getTurn() == 'O' )
2015-10-17 17:34:19 -05:00
{
b.displayBoard();
2015-10-19 15:51:48 -05:00
cout<<"\nEnter command: ";
2015-10-17 17:34:19 -05:00
cin>>move;
2015-10-19 15:51:48 -05:00
interpret(move,b);
2015-10-17 17:34:19 -05:00
}
vector<moves> possibleMoves = b.viewPossibleMoves();
2015-10-17 19:18:47 -05:00
//displayPossibleMoves(possibleMoves); for debugging purposes - AI
2015-10-17 17:34:19 -05:00
2015-10-19 15:51:48 -05:00
if (choice == 1)
{
b.easyAI();
}
else
{
while(b.getTurn() == 'X' )
{
b.displayBoard();
cout<<"\nEnter command: ";
cin>>move;
interpret(move,b);
}
}
2015-10-17 17:34:19 -05:00
2015-10-19 15:51:48 -05:00
//b.snapshot();
2015-10-17 17:34:19 -05:00
gameOver = b.isGameOver();
2015-10-19 15:51:48 -05:00
snapshot(record,b);
2015-10-17 17:34:19 -05:00
}
2015-10-19 15:51:48 -05:00
//for debugging purposes
cout<<"Record:"<<endl;
cout<<record.size();
for (int i = 0; i < record.size(); ++i)
{
record[i].displayBoard();
2015-10-17 17:34:19 -05:00
}
}