From 6de31656c4b2408c3a3172b97f18f45f0e144951 Mon Sep 17 00:00:00 2001 From: jwb11006 Date: Sat, 30 Apr 2016 17:47:45 -0400 Subject: [PATCH] Fixed base case for minimax, works better now --- src/controller/Game.java | 4 ++-- src/model/Board.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controller/Game.java b/src/controller/Game.java index 60b82b8..3fef960 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -161,7 +161,7 @@ public int getMinimaxScore(Color color, Board b, int depth, boolean inJumpSequen Color otherColor = (color == Color.BLACK ? Color.WHITE : Color.BLACK); if (depth == 0) { - return b.getHeuristic(otherColor); + return b.getHeuristic(color); } if (inJumpSequence) { @@ -178,7 +178,7 @@ public int getMinimaxScore(Color color, Board b, int depth, boolean inJumpSequen } /* 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); } diff --git a/src/model/Board.java b/src/model/Board.java index ba0ea40..ddb0c3c 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -391,7 +391,7 @@ public int getHeuristic(Color color) { /* 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)); }