Closed isaacl closed 7 years ago
Good observation & I'll try that instead. (Also there's probably a more efficient way to check if the king attacks any not-friendly-occupied squares which are not attacked!)
Also I could probably define GenType FLIGHTS
for the most readable possible solution:
#ifdef CRAZYHOUSE
template<>
ExtMove* generate<FLIGHTS>(const Position& pos, ExtMove* moveList) {
Color us = pos.side_to_move();
Square ksq = pos.square<KING>(us);
// Generate flights for king
ExtMove* cur = moveList;
Bitboard b = pos.attacks_from<KING>(ksq) & ~pos.pieces(us);
while (b)
*moveList++ = make_move(ksq, pop_lsb(&b));
if (!pos.checkers() && pos.can_castle(us))
{
if (us == WHITE)
{
moveList = generate_castling<MakeCastling<WHITE, KING_SIDE>::right, false, false>(pos, moveList, WHITE);
moveList = generate_castling<MakeCastling<WHITE, QUEEN_SIDE>::right, false, false>(pos, moveList, WHITE);
}
else
{
moveList = generate_castling<MakeCastling<BLACK, KING_SIDE>::right, false, false>(pos, moveList, BLACK);
moveList = generate_castling<MakeCastling<BLACK, QUEEN_SIDE>::right, false, false>(pos, moveList, BLACK);
}
}
while (cur != moveList)
if (!pos.legal(*cur))
*cur = (--moveList)->move;
else
++cur;
return moveList;
}
#endif
In case this (admittedly delayed on my part as I resolve other issues) test fails, plan B is based on a @Vinvin20 suggestion:
May be do null moves only when there's less than 3 pieces in (sum of both) hands. May be add a condition to be sure kings are safe.
I think it would be more appropriate to check if the opponent has ~less than 3~ ~less than 2~ no pieces in hand, since the purpose of a null move verification heuristic is to efficiently prove that a null move does not sharply change the evaluation.
Preliminary tests show that the change ~doesn't excel at bullet~ performs OK once pieceCountInHand[WHITE][ALL_PIECES]
and pieceCountInHand[BLACK][ALL_PIECES]
are set.
Nice to see there's progress here ! SF will be even stronger in the opening with null-moves !
Well... with #189 merged, this seems less necessary. I'm going to try changing the rule from "no pieces in hand" to "under (depth - 4) * 8 pieces in hand" (EDIT: that didn't work well).
Bullet preliminary results (more testing required) of "no pieces in hand":
Finished game 250 (Stockfish 311216 64 BMI2 vs PATCH): 1/2-1/2 {Draw by 3-fold repetition}
Score of PATCH vs Stockfish 311216 64 BMI2: 130 - 112 - 8 [0.536] 250
At low depths and move times it evals the position as completely lost with f7b3, at higher depth it finds an
#8
with Bxh4.