Instead of one comparison in while() condition use two,
the first to check if the piece is exsistant and the second
to loop across pieces of that type.
This should help branch prediction in cases we have only
one piece of the same type, for instance for queens, the
first branch is always true and the second is almost always
false.
Increased speed of 0.3-0.5 % on Gcc pgo compiles.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Currently are used by evaluation itself and the
whole EvalInfo will be removed from global visibility
by next patch, so no reason to use them.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
It will be more clear when we will go to add stuff
apart from king danger itself.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
First accumulate the bonus for each pawn, then call the
not very fast apply_weight().
Should be no functional change apart from rounding issues.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Set manually to zero the few fields that are
optionally populated and that's enough.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Avoid one address lookup in a very critical time path.
Unified also outpost bonus tables for knights and bishops.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Another 100 lines of dubious and ad-hoc code.
After 7644 games on russian cluster:
Mod - Orig 1285 - 1249 - 5110 ELO +1 (+- 3.2)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
We don't need that !
We can infere from starting fen string if we are in
a Chess960 game or not. And note that this is a per-position
property, not an application wide one.
A nice trick is to use a custom manipulator (that is an
enum actually) to keep using the handy operator<<() on the
move when sending to std::cout, yes, I have indulged a
bit here ;-)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Plus a bunch of other minor optimizations.
With this power pack we have an increase
of a whopping 1.4% :-)
...and it took 3 good hours of profiling + hacking to get it out !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
One hundred lines of code should be compensated by an
important ELO increase, otherwise are candidate for removal...
...and is not the case. We are well within error margin, so
remove the code even if we lose a couple of elo points, but
semplification is huge.
After 6494 games on russian cluster
Orig vs Mod 1145 - 1107 - 4242 (-2 ELO)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
After testing on our russian cluster: +3 elo after 4200 games
So keep it becuase it allows a good semplification.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Where they belong.
Note that array PieceValueMidgame[] and PieceValueEndgame[]
are now declared extern in the header and moved in piece.cpp
so to avoid allocate the array each time the header is
included !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
To avoid nasty bugs due to silently overriding of
common operator we enable the templates on a type
by type base using partial template specialization.
No functional change, zero overhead at runtime.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Note that in value we leave two specialized functions
to allow adding an integer, we don't want to add this
as a template becasue we want to control implicit
conversions to integer of an enum.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This is tricky because there are some special
binary fnctions with SquareDelta that we should
leave as they are.
Also note that we needed to add Unary minus template
to fix a comile error in SERIALIZE_MOVES_D macro that was
triggered because now we don't allow conversion to int.
No fuctional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Doing the conversion the compiler is now able to
spot two possible ambiguity calls that now we can
easily fix.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
When depth < DEPTH_ZERO we store with the same depth all
the positions, use -OnePly instead of -1 for consistency
with depth arithmetic.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
There is no reason to use a variable for this.
Also remove unused DEPTH_ZERO and DEPTH_MAX.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Regression test found the patches to be harmless,
so revert to keep code simpler.
Test1 at 20+0.1: (2500 - 3000) +0 ELO
Test2 at 1+0: (~1000) +2 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
There is a functional change because we now skip
more moves and because do_move() / undo_move() is
well known to be not reversible we end up with a
change in node count, although there is actually
no change but a bit speed up.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
To be uniform across the sources. As a nice side effect
I quickly spotted a couple of needed renames:
captured_piece() -> captured_piece_type()
st->capture -> st->capturedType
Proposed by Ralph and done with QtCreator
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
In root_search() we can compute depth at the beginning
once and for all.
Spotted by Ralph Stoesser.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
We don't need to generate captures and non
captures in a separate step. This gives another
7% push to perft speed.
yes, I know, it is totally useless :-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>