From 220d8dba10f1e34e75e8f30848212429b59e551e Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 22:47:50 -0400 Subject: [PATCH] isActive function --- src/model/Board.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/model/Board.java b/src/model/Board.java index ecc7c2d..06b1820 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -421,8 +421,47 @@ public class Board { return num; } + public boolean isActive(Piece piece) { + ArrayList jumpFrontier = this.generateJumpMovesForPiece(piece); + if (piece == null) return false; + return jumpFrontier.size() != 0; + } + + /** + * "The parameter is debited with 1 if there are no kings + * on the board, if either square 7 or 26 is occupied by + * an active man, and if neither of these squares is + * occupied by a passive man. + * @param color + * @return + */ public int apexHeuristic(Color color) { + boolean noKings = false, + eitherSquaresOccupiedByActiveMan = false, + neitherSquaresOccupiedByPassiveMan = true; + Location square7 = this.samuelMapping(7); + Location square26 = this.samuelMapping(26); + Piece piece7 = this.getPiece(square7); + Piece piece26 = this.getPiece(square26); + + boolean active7 = isActive(piece7); + boolean active26 = isActive(piece26); + + noKings = (color == Color.BLACK && this.blackKings == 0) || + (color == Color.WHITE && this.whiteKings == 0); + if (piece7.getColor() == color) { + eitherSquaresOccupiedByActiveMan |= active7; + } + if (piece26.getColor() == color) { + eitherSquaresOccupiedByActiveMan |= active26; + } + + if (piece7.getColor() == color && piece26.getColor() == color) { + if () + } + if (noKings && eitherSquaresOccupiedByActiveMan && neitherSquaresOccupiedByPassiveMan) + return -1; return 0; }