diff --git a/Board.cpp b/Board.cpp index 0cd08d1..e765e82 100755 --- a/Board.cpp +++ b/Board.cpp @@ -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 record; input = myToUpper(input); if (input == "UNDO") diff --git a/Board.h b/Board.h index 921455b..d98c0f3 100755 --- a/Board.h +++ b/Board.h @@ -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(); diff --git a/a.out b/a.out index 02b0976..2e92635 100755 Binary files a/a.out and b/a.out differ diff --git a/main.cpp b/main.cpp index 37212b1..d4e940a 100644 --- a/main.cpp +++ b/main.cpp @@ -8,7 +8,6 @@ using namespace std; int main() { - cout<<"\n----------------------------"<>choice; + cin >> choice; if (choice == 1) cout<<"playing with AI..."< 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 diff --git a/test.cpp b/test.cpp index 4d6518a..d4e940a 100755 --- a/test.cpp +++ b/test.cpp @@ -8,8 +8,19 @@ using namespace std; int main() { + cout<<"\n----------------------------"<> choice; + + if (choice == 1) cout<<"playing with AI..."< 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 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; + b.interpret(move,b); + } + } - b.easyAI(); - + //b.snapshot(); gameOver = b.isGameOver(); + + b.snapshot(record,b); } + //for debugging purposes + cout<<"Record:"<