Pushing to be able to update branch.
This commit is contained in:
parent
5ce0163f77
commit
d13b1661ee
3 changed files with 22 additions and 17 deletions
|
@ -28,7 +28,8 @@ Board::Board(const Board& b) {
|
|||
vector<Piece*> xp = b.getXPieces();
|
||||
vector<Piece*> op = b.getOPieces();
|
||||
Piece* temp;
|
||||
bool valid = false;
|
||||
//bool valid = false;
|
||||
//char tempturn = b.getTurn();
|
||||
|
||||
for (int i = 0; i < xp.size(); ++i) {
|
||||
temp = new Piece(xp[i]->getX(), xp[i]->getY(), 'X');
|
||||
|
|
34
Engine.cpp
34
Engine.cpp
|
@ -69,7 +69,7 @@ void Engine::easyAI()
|
|||
srand(time(NULL));
|
||||
int randomChoice = rand() % (listOfMoves.size()-1) - 0;
|
||||
|
||||
int temp = randomChoice;
|
||||
//int temp = randomChoice;
|
||||
cout << "easy AI move: " << listOfMoves[randomChoice].row << listOfMoves[randomChoice].column << listOfMoves[randomChoice].moveType << "\n";
|
||||
b->move(listOfMoves[randomChoice]);
|
||||
b->changeTurns();
|
||||
|
@ -78,7 +78,7 @@ void Engine::easyAI()
|
|||
void Engine::AI(){
|
||||
cout << "----------------------BEGIN AI FUNCTION----------------------\n";
|
||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||
//Board* b = new Board(*b);
|
||||
Board* temp = new Board(*b);
|
||||
|
||||
//probably not needed, check later
|
||||
/*
|
||||
|
@ -92,7 +92,7 @@ void Engine::AI(){
|
|||
minMax(b, listOfMoves[i]);
|
||||
}*/
|
||||
|
||||
b->move(minMax(listOfMoves[0], 0));
|
||||
b->move(minMax(temp, listOfMoves[0], 0));
|
||||
b->changeTurns();
|
||||
|
||||
//verification of correct turn
|
||||
|
@ -105,37 +105,41 @@ void Engine::AI(){
|
|||
cout << "----------------------END AI FUNCTION----------------------\n";
|
||||
}
|
||||
|
||||
moves Engine::minMax(moves m, int c){
|
||||
moves Engine::minMax(Board* temp, moves m, int c){
|
||||
//testing purposes only, c = finite depth
|
||||
/*
|
||||
|
||||
cout << "c: " << c << "\n\n";
|
||||
cout << "current turn: " << temp->getTurn() << "\n";
|
||||
vector<moves> listOfMoves = temp->viewPossibleMoves();
|
||||
if (c > 5){
|
||||
return m;
|
||||
}
|
||||
|
||||
if (b->isGameOver() == true){
|
||||
if (temp->isGameOver() == true){
|
||||
cout << "END OF PATH REACHED\n";
|
||||
return m;
|
||||
}
|
||||
|
||||
else {
|
||||
if(b->isThisMovePossible(8 - m.row, b->charToIntColumn(m.column), m.moveType)){
|
||||
if(temp->isThisMovePossible(m.row, m.column, m.moveType) && temp->getPiece(m.row, m.column)->getType() == temp->getTurn()){
|
||||
cout << "piece has been moved in minMax\n";
|
||||
b->move(m);
|
||||
b->changeTurns();
|
||||
temp->move(m);
|
||||
temp->changeTurns();
|
||||
temp->displayBoard();
|
||||
}
|
||||
else {
|
||||
m = minMax(temp, listOfMoves[c+1], c+1);
|
||||
}
|
||||
cout << "c: " << c << "\n\n";
|
||||
cout << "current turn: " << b->getTurn() << "\n";
|
||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||
|
||||
for (int i = 0; i < listOfMoves.size(); ++i){
|
||||
//return minMax(b, listOfMoves[i]);
|
||||
}
|
||||
|
||||
b->displayBoard();
|
||||
temp->displayBoard();
|
||||
//limited recursion
|
||||
return minMax(b, listOfMoves[0], ++c);
|
||||
minMax(temp, listOfMoves[c], ++c);
|
||||
|
||||
//testing
|
||||
return m;
|
||||
}*/
|
||||
}
|
||||
}
|
2
Engine.h
2
Engine.h
|
@ -12,5 +12,5 @@ public:
|
|||
void startGame();
|
||||
void easyAI();
|
||||
void AI();
|
||||
moves minMax(moves m, int c);
|
||||
moves minMax(Board* temp, moves m, int c);
|
||||
};
|
Reference in a new issue