Skip to content

Commit

Permalink
fixed minimax search and added testing to main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluemer committed Apr 20, 2017
1 parent 8ca9a64 commit ccee1bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/MinimaxSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class MinimaxSearch
{
private:
static const int maxDepth = 9;
static const int maxDepth = 7;

double minValue(const BitBoard &board, int currentDepth) const;
double maxValue(const BitBoard &board, int currentDepth) const;
Expand Down
4 changes: 2 additions & 2 deletions src/MinimaxSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
double MinimaxSearch::minValue(const BitBoard &board, int currentDepth) const
{
if (currentDepth == maxDepth) return board.utility(board.player());
double v = std::numeric_limits<double>::lowest();
double v = std::numeric_limits<double>::max();
for (Move move : board.actions()) {
v = std::min(v, maxValue(board.result(move), currentDepth + 1));
}
Expand All @@ -21,7 +21,7 @@ double MinimaxSearch::minValue(const BitBoard &board, int currentDepth) const
double MinimaxSearch::maxValue(const BitBoard &board, int currentDepth) const
{
if (currentDepth == maxDepth) return board.utility(board.player());
double v = std::numeric_limits<double>::max();
double v = std::numeric_limits<double>::lowest();
for (Move move : board.actions()) {
v = std::max(v, minValue(board.result(move), currentDepth + 1));
}
Expand Down
14 changes: 8 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#include <vector>
#include "BitBoard.h"
#include "Move.h"
#include "MinimaxSearch.h"

int main(int argc, const char * argv[]) {
BitBoard board(16384, 2097280, 16384);
std::vector<Move> moves = board.generateImmediateJumps(16384);
for (Move move : moves) {
for (int x : move.getMoves()) {
std::cout << x << std::endl;
}
BitBoard board;
MinimaxSearch search;
for (int i = 0; i < 20; i++) {
board.printState();
Move next = search.minimaxDecision(board);
board = board.result(next);
std::cout << "==============================" << std::endl;
}
return 0;
}

0 comments on commit ccee1bc

Please sign in to comment.