Marco Costalba [Mon, 30 Mar 2009 10:07:45 +0000 (12:07 +0200)]
Silence idiotic warning on two's complement of an unsigned
MSVC gives:
warning C4146: unary minus operator applied to unsigned type,
result still unsigned
When finds -b where b is an unsigned integer. So rewrite the two's
complement in a way to avoid the warning. Theoretically the new
version is slower, but in practice changes nothing.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 31 Mar 2009 12:57:44 +0000 (14:57 +0200)]
Revert setting a flag when TT value equals static evaluation
Strangely enough it seems that optimization doesn't work.
After 760 games at 1+0: +155 -184 =421 -13 ELO
Probably the overhead, although small, for setting the flag
is not compensated by the saved evaluation call.
This could be due to the fact that after a TT value is stored,
if and when we hit the position again the stored TT value is
actually used as a cut-off so that we don't need to go on
with another search and evaluation is avoided in any case.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 30 Mar 2009 08:09:27 +0000 (09:09 +0100)]
An VALUE_TYPE_EVAL score cannot overwrite an entry
If we want to store a value of type VALUE_TYPE_EVAL for
a given position and we found an already exsisting entry
for the same position then we skip.
We don't want to overwrite a more valuable score with a
lesser one. Note that also in case the exsisting entry is
of VALUE_TYPE_EVAL type the overwrite is unuseful because
we would store the same score again.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 30 Mar 2009 07:54:09 +0000 (08:54 +0100)]
Remember when TT value equals static evaluation value
When the stored TT value equals the static value set a
proper flag so to not call evaluation() if we hit the
same position again but use the stored TT value instead.
This is another trick to avoid calling costly evaluation()
in qsearch.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Mar 2009 16:22:10 +0000 (17:22 +0100)]
A move needs 17 bits not 19
Fix a bug in the way a move is stored and read in a TT entry.
We use a mask of 19 bits insteaad of 17 so that the last
two bits in the TT entry end up to be random data.
This bug will bite us when we will use these two until now
unused bits.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 23 Mar 2009 14:30:20 +0000 (15:30 +0100)]
Fix a bug in insert_pv() where minimum depth is zero
We implicitly considered the minimum depth stored in TT
to be Depth(0), but because we store values in TT also in
qsearch() where depth is < 0, we need to use a negative
number as minimum depth.
Bug spotted by Joona Kiiski.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 23 Mar 2009 11:02:15 +0000 (12:02 +0100)]
Revert odd depths razoring
I have just made a new rule that no modification
that increases pruning is allowed if after 1000 games
ELO is not increased by at least 10 point (was +5 in this case)
Marco Costalba [Sun, 15 Mar 2009 17:06:40 +0000 (18:06 +0100)]
Fix an overflow bug in pawns stormValue
These fields are defined as int8_t but values bigger
then 127 are stored there so that we silently overflow.
Fix bringing up all the fields to a sane int type. This
will increase memory usage, but apart from being safe, it is
not clear if code is slower or faster. Test is needed.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 28 Feb 2009 08:18:29 +0000 (09:18 +0100)]
Compute pinned and friends incrementally
In do_move() use previous pinned bitboards values to compute
the new one after the move. In particulary we end up with the
same bitboards in most cases. So detect these cases and just
keep the old values.
This should speedup a lot this slow computation in a very hot
path so that we can use this important info everywhere in the
code at very cheap cost.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 23 Feb 2009 14:19:51 +0000 (15:19 +0100)]
Teach SEE about pinned pieces
Remove pinned pieces from attacks when calculating
SEE value.
Algorithm is not perfect, there should be no false
positives, but can happen that we miss to remove a
pinned piece. Currently we don't cach 100% of cases,
but is a tradeoff between speed and accuracy. In any
case we stay on the safe side, so we remove an attacker
when we are sure it is pinned.
About only 0,5% of cases are affected by this patch, not
a lot given the hard work: this is a difficult patch!
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Feb 2009 19:16:21 +0000 (20:16 +0100)]
Introduce StateInfo instead of UndoInfo
We don't backup anymore but use the renamed StateInfo
argument passed in do_move() to store the new position
state when doing a move.
Backup is now just revert to previous StateInfo that we know
because we store a pointer to it.
Note that now backing store is up to the caller, Position is
stateless in that regard, state is accessed through a pointer.
This patch will let us remove all the backup/restore copying,
just a pointer switch is now necessary.
Note that do_null_move() still uses StateInfo as backup.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Feb 2009 16:49:52 +0000 (17:49 +0100)]
Passing UndoInfo is not needed anymore when undoing the move
We store it now in the same UndoInfo struct as 'previous'
field, so when doing a move we also know where to get
the previous info when undoing the back the move.
This is needed for future patches and is a nice cleanup anyway.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 19 Feb 2009 15:28:35 +0000 (16:28 +0100)]
Cache pinned and discovery check bitboards
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>
Marco Costalba [Fri, 13 Feb 2009 19:21:05 +0000 (20:21 +0100)]
Avoid a call to move_is_capture() in extension()
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>
Marco Costalba [Fri, 13 Feb 2009 13:17:39 +0000 (14:17 +0100)]
Fix a subtle bug in Position::move_is_capture()
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>
Marco Costalba [Thu, 12 Feb 2009 08:28:18 +0000 (09:28 +0100)]
Rename generate_piece_blocking_evasions()
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>