After have been calculated cache their values
so to avoid another expensive call to hidden_checks()
if pinned_pieces() or discovered_check_candidates() are
called with the same position.
Add also interface to get pinners bitboard, we already have
this value so save it instead of discard.
Now that, after the first call to pinned_pieces() the following
are very cheap we can rewrite and cleanup all the checking handling.
So this patch is a prerequisite for future work.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
They hide the underlying uniform function call with
no benefit.
A little bit more verbose but now is clear what happens.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Pass value as an argument instead or recalculating it.
Altough call is cheap this is a very hot path so with
this patch total time spent for move_is_capture() is almost
halved.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Currently fails if we test with a move that is not of
from the side to move but from the opponent.
This is the typical case of the threat from null move
search. The result is an erroneus prune of the defending
moves, see PruneDefendingMoves in ok_to_prune()
Fix the test to work also with threat moves.
Bug was always in but was unhidden by a patch of 17/12/2008
"Trigger of PawnEndgameExtension if capture is not a pawn"
Until then it was hidden by a tricky check in the prune
conditions instead of the natural move_is_capture()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use Position::compute_material_key() to do the job,
so we are sure there is not key mismatch during
endgame function lookups.
This fixes two endgames hash errors that caused two
endgames to be disabled.
This patch is also a code cleanup because removes a lot
of messy key assignments.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Also integrate scaling and evaluation in a
single base class.
Nice use of templates here :-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
In generate_piece_moves() to be more uniform with other
functions. Unfortunatly the different number of calling arguments
do not allow us to easily integrate in generate_piece_moves()
template family.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Small code tidy up and a little optimization
to avoid calling generate_piece_blocking_evasions()
when blockSquares is empty (30% of cases).
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Now that we have removed sliders checkers attacks
from evasion's set we can simplyfy legality check.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Rewrite as in generate_piece_moves() using a for
loop instead of the slower serializing of the
bitboard with pop_1st_bit()
This will allow also to merge with generate_piece_moves()
when we will drop legality constrain on generate_evasions()
Generated moves are not changed, but are generated in a
different order, this changes the number of nodes at fixed
depth test.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Discovery check candidates are normally empty, so
avoid discovery checks generation in that common case.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Find squares attacked by slider checkers, we will
remove them from king evasions set so to avoid a couple
of cycles in the slow king evasions legality check loop.
Not a biggie, but now generate_evasions() is faster then
generate_non_captures(), before was slower.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
When we generate checks one case is missing: generation
of castling moves that give check to the opponent king.
This is a very rare case but anyway it is a case
and we can do this without slowing down the common
case of no castling checks.
So this is the patch.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Go back to original direct assignment, this allows to
add an include in pawns.h to teach about memset()
This fix a compile error under Ubuntu.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>