merge and restructure

This commit is contained in:
Rebecca Schofield 2015-10-19 16:45:38 -05:00
parent d3ed28a608
commit 16d014edc0
5 changed files with 56 additions and 12 deletions

View file

@ -504,6 +504,7 @@ void Board::undo(Board& tablero)
void Board::interpret(string input, Board& tablero) //determines what kind of command its input is
{
vector<Board> record;
input = myToUpper(input);
if (input == "UNDO")

View file

@ -23,6 +23,8 @@ class Board {
public:
Board();
char elementAt(int r, int k) { return boardArray[r][k]; }
void modifyAt(int r, int k, char input) { boardArray[r][k] = input; }
moves parse(string input);
char getTurn() { return turn; }
bool isGameOver();

BIN
a.out

Binary file not shown.

View file

@ -8,7 +8,6 @@ using namespace std;
int main()
{
cout<<"\n----------------------------"<<endl;
cout<<"Welcome to Breakthrough\n"<<endl;
cout<<"-----------------------------\n\n"<<endl;
@ -18,7 +17,7 @@ int main()
cout<<"Enter choice: "<<endl;
int choice;
cin>>choice;
cin >> choice;
if (choice == 1) cout<<"playing with AI..."<<endl;
else cout<<"playing with human..."<<endl;
@ -29,7 +28,9 @@ int main()
bool gameOver = false;
snapshot(record,b);
vector<Board> record;
b.snapshot(record,b);
while (gameOver != true)
{
@ -40,7 +41,7 @@ int main()
b.displayBoard();
cout<<"\nEnter command: ";
cin>>move;
interpret(move,b);
b.interpret(move,b);
}
@ -59,14 +60,14 @@ int main()
b.displayBoard();
cout<<"\nEnter command: ";
cin>>move;
interpret(move,b);
b.interpret(move,b);
}
}
//b.snapshot();
gameOver = b.isGameOver();
snapshot(record,b);
b.snapshot(record,b);
}
//for debugging purposes

View file

@ -8,8 +8,19 @@ using namespace std;
int main()
{
cout<<"\n----------------------------"<<endl;
cout<<"Welcome to Breakthrough\n"<<endl;
cout<<"playing with AI..."<<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;
@ -17,26 +28,55 @@ int main()
bool gameOver = false;
vector<Board> record;
b.snapshot(record,b);
while (gameOver != true)
{
gameOver = b.isGameOver();
while(b.getTurn() == 'O')
while(b.getTurn() == 'O' )
{
b.displayBoard();
cout<<"\nEnter move: ";
cout<<"\nEnter command: ";
cin>>move;
b.move(move);
b.interpret(move,b);
}
vector<moves> possibleMoves = b.viewPossibleMoves();
//displayPossibleMoves(possibleMoves); for debugging purposes - AI
if (choice == 1)
{
b.easyAI();
}
b.easyAI();
else
{
while(b.getTurn() == 'X' )
{
b.displayBoard();
cout<<"\nEnter command: ";
cin>>move;
b.interpret(move,b);
}
}
//b.snapshot();
gameOver = b.isGameOver();
b.snapshot(record,b);
}
//for debugging purposes
cout<<"Record:"<<endl;
cout<<record.size();
for (int i = 0; i < record.size(); ++i)
{
record[i].displayBoard();
}
}