Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed base case for minimax, works better now
  • Loading branch information
john committed Apr 30, 2016
1 parent ed5e750 commit 6de3165
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/controller/Game.java
Expand Up @@ -161,7 +161,7 @@ public class Game {
Color otherColor = (color == Color.BLACK ? Color.WHITE : Color.BLACK);

if (depth == 0) {
return b.getHeuristic(otherColor);
return b.getHeuristic(color);
}

if (inJumpSequence) {
Expand All @@ -178,7 +178,7 @@ public class Game {
}

/* If we have reached the maximum depth or an end state for the game */
if (depth == 0 || b.getBlackPieces() == 0 || b.getWhitePieces() == 0
if (b.getBlackPieces() == 0 || b.getWhitePieces() == 0
|| boardFrontier.size() == 0) {
return b.getHeuristic(otherColor);
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/Board.java
Expand Up @@ -391,7 +391,7 @@ public class Board {
/* Kings are weighted more, so we count for them twice */
int blackHeuristic = blackPieces + blackKings;
int whiteHeuristic = whitePieces + whiteKings;
return - (color == Color.BLACK ?
return (color == Color.BLACK ?
(blackHeuristic - whiteHeuristic) :
(whiteHeuristic - blackHeuristic));
}
Expand Down

0 comments on commit 6de3165

Please sign in to comment.