From a2189bb452cf18bb0e5a46522e17fc53a5175264 Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 17:48:49 -0400 Subject: [PATCH 1/2] Changed the king heuristic so that kings are worth twice as much as normal pieces. For some reason Collections.max blows up on containers of type Double. --- src/controller/Game.java | 10 +++++----- src/model/Board.java | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controller/Game.java b/src/controller/Game.java index 64b7899..35e3b86 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -106,7 +106,7 @@ public Move getThunkMove() { 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 Move getMinimaxMove(int depth, boolean inJumpSequence) { } /* Determine the maximum minimax score and which move led to that score */ - double maxScore = Double.MIN_VALUE; + int maxScore = Integer.MIN_VALUE; Move bestMove = null; for (int i = 0; i < moveScores.size(); ++i) { @@ -159,9 +159,9 @@ public Move getMinimaxMove(int depth, boolean inJumpSequence) { return bestMove; } - public double getMinimaxScore(Color color, Board b, int depth, boolean inJumpSequence) { + public int 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) { @@ -196,7 +196,7 @@ public double getMinimaxScore(Color color, Board b, int depth, boolean inJumpSeq } for (Board board : boardFrontier) { - double moveScore = getMinimaxScore(nextColor, board, depth - 1, inJumpSequence); + int moveScore = getMinimaxScore(nextColor, board, depth - 1, inJumpSequence); moveScores.add(moveScore); } diff --git a/src/model/Board.java b/src/model/Board.java index 6aa14cb..68aeaa6 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -387,10 +387,10 @@ public boolean isPromotionLocation(Location location) { location.row == BOARD_SIZE - 1 ); } - public double getHeuristic(Color color) { + public int getHeuristic(Color color) { /* Kings are weighted more, so we count for them twice */ - double blackHeuristic = blackPieces + blackKings * 1.5; - double whiteHeuristic = whitePieces + whiteKings * 1.5; + int blackHeuristic = blackPieces + blackKings * 2; + int whiteHeuristic = whitePieces + whiteKings * 2; return - (color == Color.BLACK ? (blackHeuristic - whiteHeuristic) : (whiteHeuristic - blackHeuristic)); From 9457aa218e30ecff1b1056bdfcb08bcce8d14618 Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 17:51:13 -0400 Subject: [PATCH 2/2] Revert heuristics --- src/model/Board.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/model/Board.java b/src/model/Board.java index 68aeaa6..ba0ea40 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -389,8 +389,8 @@ public boolean isPromotionLocation(Location location) { public int getHeuristic(Color color) { /* Kings are weighted more, so we count for them twice */ - int blackHeuristic = blackPieces + blackKings * 2; - int whiteHeuristic = whitePieces + whiteKings * 2; + int blackHeuristic = blackPieces + blackKings; + int whiteHeuristic = whitePieces + whiteKings; return - (color == Color.BLACK ? (blackHeuristic - whiteHeuristic) : (whiteHeuristic - blackHeuristic));