/// <summary> /// Purpose: To calculate a heuristic value for the given board state /// </summary> /// <param name="boardState"></param> /// <param name="color"></param> /// <returns>integer representing the heuristic</returns> public static int GetHeuristicValue(byte[] boardState, ChessColor color) { bool white = color == ChessColor.White; int pH = GetPieceValueHeuristic(boardState, color); int pS = FEN.GetPieceHazard(boardState, white); return(pH + pS); }
/// <summary> /// Purpose: Lower the Heuristic value if our queen is put in danger /// </summary> /// <param name="boardState"></param> /// <param name="color"></param> /// <returns></returns> private static int PieceSafety(byte[] boardState, ChessColor color) { int hazardPenalty = 0; bool white = color == ChessColor.White; hazardPenalty = FEN.GetPieceHazard(boardState, white); /* * hazardPenalty += FEN.PieceNotSafe(boardState, FEN.GetPiecePos(boardState, white, FEN.q), white) ? -400 : 0; * //hazardPenalty += FEN.PieceNotSafe(boardState, FEN.GetPiecePos(boardState, white, FEN.r), white) ? -200 : 0; * //hazardPenalty += FEN.PieceNotSafe(boardState, FEN.GetPiecePos(boardState, white, FEN.n), white) ? -150 : 0; * //hazardPenalty += FEN.PieceNotSafe(boardState, FEN.GetPiecePos(boardState, white, FEN.b), white) ? -155 : 0; * //hazardPenalty += FEN.PieceNotSafe(boardState, FEN.GetPiecePos(boardState, white, FEN.p), white) ? -40 : 0;*/ return(hazardPenalty); }