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(){
|
Engine::Engine(){
|
||||||
Board b = new Board();
|
Board* brd = new Board();
|
||||||
|
b = brd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::startGame(){
|
void Engine::startGame(){
|
||||||
|
@ -25,45 +26,45 @@ void Engine::startGame(){
|
||||||
|
|
||||||
bool gameOver = false;
|
bool gameOver = false;
|
||||||
vector<Board> record;
|
vector<Board> record;
|
||||||
b.snapshot(record,b);
|
b->snapshot(record, *b);
|
||||||
|
|
||||||
while (gameOver != true)
|
while (gameOver != true)
|
||||||
{
|
{
|
||||||
gameOver = b.isGameOver();
|
gameOver = b->isGameOver();
|
||||||
|
|
||||||
while(b.getTurn() == 'O' )
|
while(b->getTurn() == 'O' )
|
||||||
{
|
{
|
||||||
b.displayBoard();
|
b->displayBoard();
|
||||||
cout<<"\nEnter command: ";
|
cout<<"\nEnter command: ";
|
||||||
cin>>move;
|
cin>>move;
|
||||||
b.interpret(move,b);
|
b->interpret(move, *b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<moves> possibleMoves = b.viewPossibleMoves();
|
vector<moves> possibleMoves = b->viewPossibleMoves();
|
||||||
|
|
||||||
if (choice == 1)
|
if (choice == 1)
|
||||||
{
|
{
|
||||||
cout << "a";
|
cout << "easyAI";
|
||||||
b.easyAI();
|
easyAI();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(b.getTurn() == 'X' )
|
while(b->getTurn() == 'X' )
|
||||||
{
|
{
|
||||||
b.displayBoard();
|
b->displayBoard();
|
||||||
cout<<"\nEnter command: ";
|
cout<<"\nEnter command: ";
|
||||||
cout<<"OK\n";
|
cout<<"OK\n";
|
||||||
cin>>move;
|
cin>>move;
|
||||||
b.interpret(move,b);
|
b->interpret(move, *b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//b.snapshot();
|
//b->snapshot();
|
||||||
gameOver = b.isGameOver();
|
gameOver = b->isGameOver();
|
||||||
|
|
||||||
b.snapshot(record,b);
|
b->snapshot(record, *b);
|
||||||
}
|
}
|
||||||
|
|
||||||
//for debugging purposes
|
//for debugging purposes
|
||||||
|
@ -77,11 +78,11 @@ void Engine::startGame(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::easyAI()
|
void Engine::easyAI()
|
||||||
{
|
{
|
||||||
//1) see all possible movements
|
//1) see all possible movements
|
||||||
|
|
||||||
vector<moves> listOfMoves = viewPossibleMoves();
|
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||||
|
|
||||||
//obvious moves
|
//obvious moves
|
||||||
if (false){
|
if (false){
|
||||||
|
@ -100,10 +101,10 @@ void Board::easyAI()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::AI(){
|
void Engine::AI(){
|
||||||
//do things here
|
//do things here
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::minMax(){
|
void Engine::minMax(){
|
||||||
//do more things here
|
//do more things here
|
||||||
}
|
}
|
4
Engine.h
4
Engine.h
|
@ -5,10 +5,12 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
Board b;
|
Board* b;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
void startGame();
|
void startGame();
|
||||||
void easyAI();
|
void easyAI();
|
||||||
|
void AI();
|
||||||
|
void minMax();
|
||||||
};
|
};
|
Reference in a new issue