diff --git a/src/controller/Game.java b/src/controller/Game.java index 3fef960..be5a278 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -106,7 +106,7 @@ public class Game { public Move getMinimaxMove(int depth, boolean inJumpSequence) { ArrayList boardFrontier = null; ArrayList moveFrontier = null; - ArrayList moveScores = new ArrayList(); + ArrayList moveScores = new ArrayList(); if (inJumpSequence) { /* Generate the frontier only for the piece that just moves */ @@ -140,7 +140,7 @@ public class Game { } /* Determine the maximum minimax score and which move led to that score */ - int maxScore = Integer.MIN_VALUE; + double maxScore = Double.MIN_VALUE; Move bestMove = null; for (int i = 0; i < moveScores.size(); ++i) { @@ -150,14 +150,18 @@ public class Game { bestMove = moveFrontier.get(i); maxScore = moveScores.get(i); } + + System.out.println(moveFrontier.get(i) + " --> " + moveScores.get(i)); } + + System.out.println("Choosing: " + bestMove); return bestMove; } - public int getMinimaxScore(Color color, Board b, int depth, boolean inJumpSequence) { + public double getMinimaxScore(Color color, Board b, int depth, boolean inJumpSequence) { ArrayList boardFrontier; - ArrayList moveScores = new ArrayList(); + ArrayList moveScores = new ArrayList(); Color otherColor = (color == Color.BLACK ? Color.WHITE : Color.BLACK); if (depth == 0) { @@ -192,7 +196,7 @@ public class Game { } for (Board board : boardFrontier) { - int moveScore = getMinimaxScore(nextColor, board, depth - 1, inJumpSequence); + double moveScore = getMinimaxScore(nextColor, board, depth - 1, inJumpSequence); moveScores.add(moveScore); } diff --git a/src/model/Board.java b/src/model/Board.java index ddb0c3c..e999e89 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -387,11 +387,12 @@ public class Board { location.row == BOARD_SIZE - 1 ); } - public int getHeuristic(Color color) { + public double 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 ? + + double blackHeuristic = blackPieces + blackKings * 1.5; + double whiteHeuristic = whitePieces + whiteKings * 1.5; + return - (color == Color.BLACK ? (blackHeuristic - whiteHeuristic) : (whiteHeuristic - blackHeuristic)); }