public static int[] MakeList(Position pos, ref int material) { var list = new int[6]; int nlist = 0; for (Square sq = Square.SQ_09; sq <= Square.SQ_23; ++sq) { int piece = pos.SquareIs(sq); if (piece == Piece.Empty || piece == Piece.Wall) { continue; } material += PieceValue[piece]; if (Piece.Abs(piece) == Piece.BK) { continue; } list[nlist++] = EvalIndex.IndexArray[piece] + EvalIndex.SquareToIndex(sq); } for (int p = Piece.BP; p < Piece.BK; ++p) { for (int i = 1; i <= pos.Stand(Color.BLACK, p); ++i) { material += PieceValue[p]; list[nlist++] = EvalIndex.IndexStandArray[p] + i; } for (int i = 1; i <= pos.Stand(Color.WHITE, p); ++i) { material -= PieceValue[p]; list[nlist++] = EvalIndex.IndexStandArray[p + 8] + i; } } Debug.Assert(nlist == 6); return(list); }
static void IncParam(Position pos, double dinc, Color turn) { if (turn == Color.WHITE) { dinc = -1 * dinc; } int dummy = 0; int bk = EvalIndex.SquareToIndex(pos.KingPos(Color.BLACK)); int wk = EvalIndex.SquareToIndex(pos.KingPos(Color.WHITE)); var list = MakeList(pos, ref dummy); for (int i = 0; i < EvalIndex.ListSize; ++i) { int k = list[i]; for (int j = 0; j < i; ++j) { int l = list[j]; pData[bk, wk, k, l] += dinc; } } }
public static int Evaluate_kkpp(Position pos) { int material = 0; int value_kkpp = 0; int bk = EvalIndex.SquareToIndex(pos.KingPos(Color.BLACK)); int wk = EvalIndex.SquareToIndex(pos.KingPos(Color.WHITE)); var list = MakeList(pos, ref material); for (int i = 0; i < EvalIndex.ListSize; ++i) { int k = list[i]; for (int j = 0; j < i; ++j) { int l = list[j]; value_kkpp += KKPP[bk, wk, k, l]; } } int value = value_kkpp / FVScale + material; return(pos.SideToMove() == Color.BLACK ? +value : -value); }