finished engine
This commit is contained in:
parent
bb46cd670f
commit
dc544a609b
2 changed files with 23 additions and 20 deletions
39
Engine.cpp
39
Engine.cpp
|
@ -6,7 +6,8 @@
|
|||
|
||||
|
||||
Engine::Engine(){
|
||||
Board b = new Board();
|
||||
Board* brd = new Board();
|
||||
b = brd;
|
||||
}
|
||||
|
||||
void Engine::startGame(){
|
||||
|
@ -25,45 +26,45 @@ void Engine::startGame(){
|
|||
|
||||
bool gameOver = false;
|
||||
vector<Board> record;
|
||||
b.snapshot(record,b);
|
||||
b->snapshot(record, *b);
|
||||
|
||||
while (gameOver != true)
|
||||
{
|
||||
gameOver = b.isGameOver();
|
||||
gameOver = b->isGameOver();
|
||||
|
||||
while(b.getTurn() == 'O' )
|
||||
while(b->getTurn() == 'O' )
|
||||
{
|
||||
b.displayBoard();
|
||||
b->displayBoard();
|
||||
cout<<"\nEnter command: ";
|
||||
cin>>move;
|
||||
b.interpret(move,b);
|
||||
b->interpret(move, *b);
|
||||
}
|
||||
|
||||
|
||||
vector<moves> possibleMoves = b.viewPossibleMoves();
|
||||
vector<moves> possibleMoves = b->viewPossibleMoves();
|
||||
|
||||
if (choice == 1)
|
||||
{
|
||||
cout << "a";
|
||||
b.easyAI();
|
||||
cout << "easyAI";
|
||||
easyAI();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
while(b.getTurn() == 'X' )
|
||||
while(b->getTurn() == 'X' )
|
||||
{
|
||||
b.displayBoard();
|
||||
b->displayBoard();
|
||||
cout<<"\nEnter command: ";
|
||||
cout<<"OK\n";
|
||||
cin>>move;
|
||||
b.interpret(move,b);
|
||||
b->interpret(move, *b);
|
||||
}
|
||||
}
|
||||
|
||||
//b.snapshot();
|
||||
gameOver = b.isGameOver();
|
||||
//b->snapshot();
|
||||
gameOver = b->isGameOver();
|
||||
|
||||
b.snapshot(record,b);
|
||||
b->snapshot(record, *b);
|
||||
}
|
||||
|
||||
//for debugging purposes
|
||||
|
@ -77,11 +78,11 @@ void Engine::startGame(){
|
|||
}
|
||||
}
|
||||
|
||||
void Board::easyAI()
|
||||
void Engine::easyAI()
|
||||
{
|
||||
//1) see all possible movements
|
||||
|
||||
vector<moves> listOfMoves = viewPossibleMoves();
|
||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||
|
||||
//obvious moves
|
||||
if (false){
|
||||
|
@ -100,10 +101,10 @@ void Board::easyAI()
|
|||
}
|
||||
}
|
||||
|
||||
void Board::AI(){
|
||||
void Engine::AI(){
|
||||
//do things here
|
||||
}
|
||||
|
||||
void Board::minMax(){
|
||||
void Engine::minMax(){
|
||||
//do more things here
|
||||
}
|
4
Engine.h
4
Engine.h
|
@ -5,10 +5,12 @@
|
|||
using namespace std;
|
||||
|
||||
class Engine {
|
||||
Board b;
|
||||
Board* b;
|
||||
|
||||
public:
|
||||
Engine();
|
||||
void startGame();
|
||||
void easyAI();
|
||||
void AI();
|
||||
void minMax();
|
||||
};
|
Reference in a new issue