From 51afcd90d9d1411911977906e5c85e0fdaf2a7d2 Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 17:39:52 -0400 Subject: [PATCH 1/3] added very useful printing --- src/controller/Game.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controller/Game.java b/src/controller/Game.java index 8f03922..35e3b86 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -150,7 +150,11 @@ 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; } @@ -198,11 +202,11 @@ public class Game { if (color == GameConstants.THUNK_COLOR) { // Maximize - return Collections.min(moveScores); + return Collections.max(moveScores); } else { // Minimize - return Collections.max(moveScores); + return Collections.min(moveScores); } } From 667711b1e6082e4c064a6ac2accc0c0107cf1cff Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 17:43:36 -0400 Subject: [PATCH 2/3] Altered king heuristic to follow Samuel's paper, 2 kings equals 3 normal --- src/model/Board.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/model/Board.java b/src/model/Board.java index ba0ea40..6aa14cb 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -387,10 +387,10 @@ 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; + double blackHeuristic = blackPieces + blackKings * 1.5; + double whiteHeuristic = whitePieces + whiteKings * 1.5; return - (color == Color.BLACK ? (blackHeuristic - whiteHeuristic) : (whiteHeuristic - blackHeuristic)); From df046c5665fb4dc4c8c16c37e3eb7c630d57a88d Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 17:44:54 -0400 Subject: [PATCH 3/3] Score is now a double --- src/controller/Game.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controller/Game.java b/src/controller/Game.java index 35e3b86..64b7899 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) { @@ -159,9 +159,9 @@ public class Game { 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) { @@ -196,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); }