int evaluator::eval_dark_king(int sq) { int r; int i; r = king_pcsq[flip[sq]]; if (COL(sq) < 3) { r += eval_dkp(1); r += eval_dkp(2); r += eval_dkp(3) / 2; } else if (COL(sq) > 4) { r += eval_dkp(8); r += eval_dkp(7); r += eval_dkp(6) / 2; } else { for (i = COL(sq); i <= COL(sq) + 2; ++i) if ((pawn_rank[LIGHT][i] == 0) && (pawn_rank[DARK][i] == 7)) r -= 10; } r *= piece_mat[LIGHT]; r /= 3100; return r; }
int eval_black_king(int sq) { int r; int i; // Evaluates safety of king if castled r = king_pcsq[flip[sq]]; if (COL(sq) < 3) { r += eval_dkp(1); r += eval_dkp(2); r += eval_dkp(3) / 2; } else if (COL(sq) > 4) { r += eval_dkp(8); r += eval_dkp(7); r += eval_dkp(6) / 2; } // Penalty added if open files around king else { for (i = COL(sq); i <= COL(sq) + 2; ++i) if ((pawn_rank[WHITE][i] == 0) && (pawn_rank[BLACK][i] == 7)) r -= 10; } // Scale score based on number of opposing pieces r *= piece_mat[WHITE]; r /= 3100; return r; }