Marco Costalba [Sun, 16 Aug 2009 13:07:34 +0000 (14:07 +0100)]
Unify do_ep_move()
Integrate do_ep_move in do_move() this reduces line count
and code readibility.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 15 Aug 2009 14:18:17 +0000 (15:18 +0100)]
L1/L2 friendly PhaseTable[]
In Movepicker c'tor we access during initialization one of
MainSearchPhaseIndex..QsearchWithoutChecksPhaseIndex globals.
Postpone definition of PhaseTable[] just after them so that
when PhaseTable[] will be accessed later in get_next_move()
it will be already present in L1/L2.
It works like an implicit prefetching of PhaseTable[].
Also shrink PhaseTable[] to fit an L1 cache line of 16 bytes
using uint8_t instead of int.
This apparentely innocuous patch gives an astonish speed
up of 1.6% under MSVC 2010 beta, pgo optimized !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 14 Aug 2009 11:47:49 +0000 (12:47 +0100)]
Use optimized pop_1st_bit() under Windows 64 with icc
Intel compiler can handle this code even under Windows.
So lift the costrain.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 13 Aug 2009 10:45:35 +0000 (12:45 +0200)]
Better naming and document some endgame functions
In particular the generic scaling functions.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 12 Aug 2009 07:40:03 +0000 (09:40 +0200)]
Finally fix prefetch on Linux
It was due to a missing -msse compiler option !
Without this option the CPU silently discards
prefetcht2 instructions during execution.
Also added a (gcc documented) hack to prevent Intel
compiler to optimize away the prefetches.
Special thanks to Heinz for testing and suggesting
improvments. And for Jim for testing icc on Windows.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 11 Aug 2009 07:30:19 +0000 (08:30 +0100)]
Reuse 5 slots instead of 4
But this time with the guarantee of an always aligned
access so that prefetching is not adversely impacted.
On Joona PC
1+0, 64Mb hash:
Orig - Mod: 174 - 237 - 359
Instead after 1000 games at 1+0 with 128MB hash size
we are at + 1 ELO (just 4 games of difference).
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 10 Aug 2009 13:23:19 +0000 (14:23 +0100)]
Double prefetch on Windows
After fixing the cpu frequency with RightMark tool I was
able to test speed all the different prefetch combinations.
Here the results:
OS Windows Vista 32bit, MSVC compile
CPU Intecl Core 2 Duo T5220 1.55 GHz
bench on depth 12, 1 thread,
26552844 nodes searched
results in nodes/sec
no-prefetch
402486, 402005, 402767, 401439, 403060
single prefetch (aligned 64)
410145, 409159, 408078, 410443, 409652
double prefetch (aligned 64) 0+32
414739, 411238, 413937, 414641, 413834
double prefetch (aligned 64) 0+64
413537, 414337, 413537, 414842, 414240
And now also some crazy stuff:
single prefetch (aligned 128)
410145, 407395, 406230, 410050, 409949
double prefetch (aligned 64) 0+0
409753, 410044, 409456
single prefetch (aligned 64) +32
408379, 408272, 406809
single prefetch (aligned 64) +64
408279, 409059, 407395
So it seems the best is a double prefetch at the addres + 32 or +64,
I will choose the second one because it seems more natural to me.
It is still a mystery why it doesn't work under Linux :-(
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 10 Aug 2009 10:59:07 +0000 (12:59 +0200)]
Avoid Intel compiler optimizes away prefetching
Without this hack Intel compiler happily optimizes
away the gcc builtin call.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 10 Aug 2009 07:35:46 +0000 (09:35 +0200)]
Use aligned prefetch address
Prefetch always form a chache line boundary. It seems
that if prefetch address is not cache line aligned then
performance is adversely impacted.
Hopefully we will resuse that 32 bits of padding for something
useful in the future.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 10 Aug 2009 06:43:39 +0000 (08:43 +0200)]
Remove old BishopPairBonus constants
Now that we have poly imbalance these ones
are no more used.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 9 Aug 2009 23:20:54 +0000 (01:20 +0200)]
Enable prefetch also for gcc
This fix a compile error under Linux with gcc when
there aren't the intel dev libraries.
Also simplify the previous patch moving TT definition
from search.cpp to tt.cpp so to avoid using passing a
pointer to TT to the current position.
Finally simplify do_move(), now we miss a prefetch in the
rare case of setting an en-passant square but code is
much cleaner and performance penalty is almost zero.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 9 Aug 2009 14:53:51 +0000 (15:53 +0100)]
Try to prefetch as soon as position key is ready
Move prefetching code inside do_move() so to allow a
very early prefetching and to put as many instructions
as possible between prefetching and following retrieve().
With this patch retrieve() times are cutted of another 25%
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 9 Aug 2009 12:44:55 +0000 (13:44 +0100)]
Add TT prefetching support
TT.retrieve() is the most time consuming function
because almost always involves a very slow RAM access.
TT table is so big that is never cached. This patch
prefetches TT data just after a move is done, so that
subsequent TT.retrieve will be very fast.
Profiling with VTune shows that TT:retrieve() times are
almost cutted in half !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 9 Aug 2009 03:35:46 +0000 (04:35 +0100)]
Use 5 TTEntry slots instead of 4
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 9 Aug 2009 03:19:32 +0000 (04:19 +0100)]
Use 32 bit key in TT
Shrink key to 32 bits instead of 64. To still avoid
collisions use the high 32 bits of position key as the
TT key and the low 32 bits to retrieve the correct
cluster index in the table.
With this patch size og TTentry shrinks to 96 bits instead
of 128 and the cluster of 4 TTEntry sums to 48 bytes instead
of 64.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 16:37:13 +0000 (17:37 +0100)]
Makefile: added 'make strip' target
Binaries are always built with symbol table in to easy
debugging and profiling.
It is now possible to run:
make strip
To remove symbol table from the compiled binary. This
could be useful to prepare the release version.
Patch by Heinz van Saanen.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 16:04:01 +0000 (17:04 +0100)]
Let LMR at root be independent of MultiPV value
Current formula enable LMR when
i + MultiPV >= LMRPVMoves
It means that, for instance, if MultiPV == 1 then LMR
will be started to be considered at move i = LMRPVMoves - 1,
while if MultiPV == 3 then it will start before,
at move i = LMRPVMoves - 3.
With this patch the formula becomes
i >= MultiPV + LMRPVMoves - 2
So that LMR will always start after LMRPVMoves - 1 moves
from the last PV move.
No functional change when MultiPV == 1
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 12:06:50 +0000 (13:06 +0100)]
Speed up polynomial material imbalance loop
Access pos.piece_count() only once and avoid some
branches in the inner loop.
Profiling with VTune shows a 20% speed improvement in
get_material_info(), and it is also a bit more cleaned
up this way ;-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 11:28:03 +0000 (12:28 +0100)]
There is no need to special case KNNK ending
It is always draw, so use the corresponding proper
evaluation function.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 27 Jul 2009 09:28:29 +0000 (11:28 +0200)]
Move halfOpenFiles[] calculation out of a loop
And put it in an already existing one so to
optimze a bit.
Also additional cleanups and code shuffles
all around the place.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 07:12:31 +0000 (09:12 +0200)]
Compile without DEBUG flag by default
And build also symbol table. It can easily stripped
after .exe is done and it is necessary for profiling.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 02:46:43 +0000 (03:46 +0100)]
Revert material balance values after 100000 games
After Joona's direct testing with ~2000 games it seems
values after 100.000 games does not give any advantage,
so revert for now.
Score of Stockfish_0 vs Stockfish_15: 491 - 392 - 1102
Score of Stockfish_0 vs Stockfish_40: 461 - 439 - 1076
Score of Stockfish_0 vs Stockfish_65: 442 - 518 - 1018 (13 elo)
Score of Stockfish_0 vs Stockfish_100: 504 - 502 - 984
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Joona Kiiski [Fri, 24 Jul 2009 14:34:41 +0000 (17:34 +0300)]
Do not adjust Minimum Split Depth automatically
Currently minimum split depth is set automatically to 6
when number of CPUs is more than 4. I believe this is a bad
idea since for example my quad (4CPU with hyperthreading) is
detected as 8CPU computer. I've manually lowered down the number
of Threads, but so far I have played all games with Minimum
Split Depth set to 6!
Since 4CPU computers with hyperthreading are quite common and
8 CPU computers extremely rear (I expect we can get a direct
jump to 16 or 32 cores), this automatic adjusting is likely
to do more harm than good. Add a note in Readme.txt, so that
those rear 8CPU owners can manually tweak the "Minimum Split
Depth" parameter
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 8 Aug 2009 02:30:27 +0000 (03:30 +0100)]
Polished Makefile for *nix
Greately improved Makefile from Heinz van Saanen
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tord Romstad [Fri, 7 Aug 2009 14:26:24 +0000 (16:26 +0200)]
Supply the "upperbound" and "lowerbound" parameters in UCI search
output when the score is outside the root window.
Tord Romstad [Thu, 6 Aug 2009 16:07:32 +0000 (18:07 +0200)]
Fixed a bug in PV extraction from the transposition table: The
previous used move_is_legal to verify that the move from the TT
was legal, and the old version of move_is_legal only works when
the side to move is not in check. Fixed this by adding a separate,
slower version of move_is_legal which works even when the side to
move is in check.
Tord Romstad [Thu, 6 Aug 2009 12:02:53 +0000 (14:02 +0200)]
Moved the code for extracting the PV from the TT to tt.cpp, where
it belongs.
Tord Romstad [Thu, 6 Aug 2009 11:27:49 +0000 (13:27 +0200)]
Added a new function build_pv(), which extends a PV by walking
down the transposition table.
When the search was stopped before a fail high at the root was
resolved, Stockfish would often print a very short PV, sometimes
consisting of just a single move. This was not only a little
user-unfriendly, but also harmed the strength a little in
ponder-on games: Single-move PVs mean that there is no ponder
move to search.
It is perhaps worth considering to remove the pv[][] array
entirely, and always build the entire PV from the transposition
table. This would simplify the source code somewhat and probably
make the program infinitesimally faster, at the expense of
sometimes getting shorter PVs or PVs with rubbish moves near
the end.
Tord Romstad [Tue, 4 Aug 2009 09:31:25 +0000 (11:31 +0200)]
Initial work towards adjustable playing strength.
Added the UCI_LimitStrength and the UCI_Elo options, with an Elo
range of 2100-2900. When UCI_LimitStrength is enabled, the number
of threads is set to 1, and the search speed is slowed down according
to the chosen Elo level.
Todo:
1. Implement Elo levels below 2100 by blundering on purpose and/or
crippling the evaluation.
2. Automatically calibrate the maximum Elo by measuring the CPU speed
during program initialization, perhaps by doing some bitboard
computations and measuring the time taken.
No functional change when UCI_LimitStrength is false (the default).
Tord Romstad [Mon, 3 Aug 2009 07:08:59 +0000 (09:08 +0200)]
Added LMR at the root.
After 2000 games at 1+0
Mod vs Orig +534 =1033 -433 52.525% 1050.5/2000 +18 ELO
Joona Kiiski [Mon, 20 Jul 2009 12:47:05 +0000 (15:47 +0300)]
Remove useless mate value special handling in null search
After 1200 games (1CPU), time control 1+0:
Mod vs Orig: +331 =564 -277 +16 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Jul 2009 16:42:48 +0000 (17:42 +0100)]
Yet another small touch to endgame functions handling
It is like a never finished painting. Everyday a little touch
more.
But this time it is very little ;-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Jul 2009 15:04:19 +0000 (16:04 +0100)]
Remove unused members in Application class
Also rearrange a bit the remining methods.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Jul 2009 08:07:42 +0000 (09:07 +0100)]
Fix a spurious extra space
This morning it seems there is nothing better to do...
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 25 Jul 2009 15:16:28 +0000 (16:16 +0100)]
Micro optimize extension() in search.cpp
Small micro-optimization in this very
time critical function.
Use bitwise 'or' instead of logic 'or' to avoid branches
in the assembly and use the result to skip an handful of checks.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 24 Jul 2009 13:26:49 +0000 (14:26 +0100)]
Polynomial material balance after 100.000 games
Verified it is equivalent to the tuning branch results
with parameter values sampled after 100.000 games.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 24 Jul 2009 13:18:03 +0000 (14:18 +0100)]
Revert Makefile changes
Some unwanted changes to Makefile slept in in patch
"Introduced the UCI_AnalyseMode option".
Revert them. No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 24 Jul 2009 10:16:18 +0000 (12:16 +0200)]
Simplify king shelter cache handling
This is more similar to how get_material_info() and
get_pawn_info() work and also removes some clutter from
evaluate_king().
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 23 Jul 2009 06:13:06 +0000 (07:13 +0100)]
Delay costly SEE call during captures ordering in MovePicker
When ordering moves we push all captures with negative SEE values
to badCaptures[] array during the scoring phase.
This patch delays the costly SEE call up to when the move has been
picked up in pick_move_from_list(), this way we save some SEE calls
in case we get a cutoff.
It seems we have a speed gain of about 1-1.5 % in terms of nodes/sec
and profiling seems to confirm the small but real speed increase.
Idea from Pablo Vazquez on talkchess.com
http://www.talkchess.com/forum/viewtopic.php?t=29018&start=20
It would be a no functional change but actually it is not because
now sorting set is different and so std::sort(), that is not a
stable sort, does not guarantees the order of same scored moves to
remain the same as before.
After 952 games at 1+0 we are below error bar, almost equal just
6 games of difference (+2 ELO)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 23 Jul 2009 17:30:56 +0000 (18:30 +0100)]
Microptimization in do_evaluate()
Do not call count_1s_max_15() if not necessary, as is
not in the common case (>95%).
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 23 Jul 2009 09:29:13 +0000 (10:29 +0100)]
Use do_move_bb() helpers when doing a castle
Small cleanup.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Jul 2009 08:56:21 +0000 (09:56 +0100)]
Add Tord's polynomial material balance
Use a polynomial weighted evaluation to calculate
material value.
This is far more flexible and elegant then applying
a series of single euristic rules as before.
Also correct a design issue in which we returned two
values, one for middle game and one for endgame, while
instead, because game phase is a function of board
material itself, only one value should be calculated and
used both for mid and end game.
Verified it is equivalent to the tuning branch results with
parameter values sampled after 40.000 games.
After 999 games at 1+0
Mod vs Orig +277 =482 -240 51.85% 518.0/999 +13 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Jul 2009 09:50:18 +0000 (10:50 +0100)]
Rename int32 in int32_t
To use the same naming rule of the other types and
to be compatible with inttypes.h, used under Linux.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 18 Jul 2009 10:28:09 +0000 (11:28 +0100)]
Correctly set mateThreat in search()
We do not accept null search returned mate values,
but we always do a full search in those cases.
So the variable mateThreat that is set only if null move
search returns a mate value is always false.
Restore the functionality of mateThreat moving the
assignement where it can be triggered.
After 999 games at 1+0
Mod vs Orig +253 =517 -229 51.20% +8 ELO
Bug reported by xiaozhi
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 17 Jul 2009 16:07:45 +0000 (17:07 +0100)]
Use increased LMR horizont also in PV search
Tord says that using a lower horizon at PV nodes
looks strange and inconsistent with the general
philosophy of our search (i.e. always being more
conservative at PV nodes). So set LMR at 3 also
on search_pv().
Test result after 601 games seems to confirm this.
Mod vs Orig +156 =318 -127 52.41% 315.0/601 +17 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 16 Jul 2009 06:05:54 +0000 (07:05 +0100)]
Reintroduce null move dynamic reduction
Test extension of LMR horizon to 3 plies alone, without
touching null move search. To keep the patch minimal we still
don't change LMR horizon in PV search. This will be the object
of the next patch.
Result seems good after 998 games:
Mod vs Orig +252/=518/-228 51.20% 511.0/998 +8 ELO
So dynamic null move reduction seems a bit stronger then
fixed reduction even with LMR horizon set to 3.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 15 Jul 2009 07:43:09 +0000 (08:43 +0100)]
Use increased LMR horizont only after a null move
Revert to LMR horizont of 2 plies. Only if parent move
is a null move increase to 3 so to avoid the bad combination
of null move reduction + LMR reduction. This is a more
aggressive patch then previous one, but it seems we are
going in the wromg direction.
After 531 games result is not good:
Mod vs Orig +123/=265/-143 48.12% 255.5/531 -13 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 13 Jul 2009 12:35:29 +0000 (13:35 +0100)]
Combine increased LMR horizont and fixed null move reduction
Set null move reduction to R=4, but increase the LMR horizon
to 3 plies. The two tweaks are related and should compensate
the combined effect of null move + LMR reduction at shallow
depths.
Idea from Tord.
After 999 games at 1+0
Mod vs Orig +251 =522 -225 51.30% + 9 ELO
On Tord iMac Core 2 Duo 2.8 GHz, one thread,
Mac OS X 10.6, at 1+0 time control we have:
Mod vs Orig 994-1006 -1.4 ELO
But Orig version is pgo compiled and Mod is not.
The PGO compiled version is about 8% faster, which
corresponds to about 7 Elo points. This means that
results are reasonably consistent.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tord Romstad [Fri, 17 Jul 2009 20:26:01 +0000 (22:26 +0200)]
Introduced the UCI_AnalyseMode option, and made the evaluation function
symmetrical in analyse mode.
No functional change when playing games.
Marco Costalba [Fri, 17 Jul 2009 17:16:20 +0000 (19:16 +0200)]
Fix two compile errors in new endgame code
Code that compiles cleanly under MSVC triggers one
compile error (correct) under Intel C++ and two(!)
under gcc.
The first is the same complained by Intel, but the second
is an interesting corner case of C++ standard (there are many)
that is correctly spotted only by gcc.
Both MSVC and Intel pass this silently, probably to avoid
breaking people code.
Now we are fully C++ compliant ;-)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 17 Jul 2009 15:18:33 +0000 (16:18 +0100)]
Move constant bitboard arrays from header to cpp file
This avoid to duplicate storage allocation for every file
where they are used.
Note that simple numeric constant can remain in header because
are automatically folded by the compiler.
Patch suggested by Tord.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 17 Jul 2009 12:32:27 +0000 (14:32 +0200)]
Remove even more redundancy in endgame functions handling
Push on the templatization even more to chip out some code
and take the opportunity to show some neat template trick ;-)
Ok. I would say we can stop here now....it is quickly becoming
a style exercise but we are not boost developers so give it a stop.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tord Romstad [Fri, 17 Jul 2009 07:12:59 +0000 (09:12 +0200)]
Removed an incorrect assert() statement in search.cpp, which asserted that
a static eval cached in the transposition table would always equal the static
eval of the current position. This is in general not true, because the cached
value could be from a previous search with different evaluation parameter
settings, or from a search from the opposite side (Stockfish's evaluation
function is assymmetric by default).
Marco Costalba [Thu, 16 Jul 2009 12:31:32 +0000 (14:31 +0200)]
Simplify endgame functions handling
We really don't need to have global endgame functions. We can
allocate them on the heap at initialization time and store the
corresponding pointer directly in the functions maps. To avoid
leaks we just need to remember to deallocate them in map d'tor.
These functions are always created in couple, one for each color,
so remove a lot of redundant hard coded info and just use the minimum
required: the type and the corresponding named string.
This greatly simplifies the code and also it is less error prone,
now is much simpler to add a new endgame specialized function: just
add the corresponding enum in endgame.h and the obvious add_xx()
call in EndgameFunctions c'tor, and of course, the most important part,
the EvaluationFunction<xxx>::apply() specialization in endgame.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tord Romstad [Wed, 15 Jul 2009 09:01:49 +0000 (11:01 +0200)]
Renamed the variable 'looseOnTime' to 'loseOnTime', because I'm a pedant.
No functional change.
Marco Costalba [Mon, 13 Jul 2009 10:44:33 +0000 (11:44 +0100)]
Remove "Last seconds noise" filtering UCI option
This feature makes sense during development, but
It doesn't seem to make sense for normal users.
Also fix a possible race where the GUI adjudicates
the game a fraction of second before the engine sets
looseOnTime flag so that it will bogusly waits until
it ran out of time at the beginning of the next new game.
The fix is to always reset looseOnTime at the beginning
of a new game.
Race condition spotted by Tord.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 14 Jul 2009 08:07:30 +0000 (10:07 +0200)]
Introduce SERIALIZE_MOVES_D() macro and use it for pawn moves
This is another moves serialization macro but this time
focused on pawn moves where the 'from' square is given as
a delta from the 'to' square.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 14 Jul 2009 06:53:22 +0000 (08:53 +0200)]
Micro optimize pawn moves generation
It is very rare we have pawns on 7(2) rank, so we
can skip the promotion handling stuff in most cases.
With this patch pawn moves generation is almost 20% faster.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 11 Jul 2009 08:54:30 +0000 (09:54 +0100)]
Introduce see_sign() and use it to shortcut full see()
Mostly of times we are interested only in the sign of SEE,
namely if a capture is negative or not.
If the capturing piece is smaller then the captured one we
already know SEE cannot be negative and this information
is enough most of the times. And of course it is much
faster to detect then a full SEE.
Note that in case see_sign() is negative then the returned
value is exactly the see() value, this is very important,
especially for ordering capturing moves.
With this patch the calls to the costly see() are reduced
of almost 30%.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 11 Jul 2009 07:02:31 +0000 (08:02 +0100)]
Move some global variables to local scope in search.cpp
Some variables were global due to some old and now removed code,
but now can be moved in local scope.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 10 Jul 2009 20:41:23 +0000 (21:41 +0100)]
Joona tweaks of Weights and limits
Verification test give unusless result
After 999 games at 1+0
Mod vs Orig +250 =503 -246 50.20% +1 ELO
So we are well below our radar level. Neverthless
there are 100.000 games on Joona QUAD that we could
take in account and that shows that this tweak perhaps
has something good in it, altough very little.
Verification tests shows should not be a regression, at
least not a big one even in the worst case, so apply the
change anyway and keep the finger crossed ;-)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 10 Jul 2009 17:50:43 +0000 (18:50 +0100)]
Small tidy up of previous patch
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tord Romstad [Fri, 10 Jul 2009 16:34:56 +0000 (18:34 +0200)]
Strip whitespace from beginning of string sent to set_option_value().
It turned out that the input sent to set_option_value() when it is called by
set_option() in uci.cpp always started with at least one whitespace. In most
cases, this is not a problem, because the majority of UCI options have numeric
values. It did, however, cause a problem for UCI options with non-numerical
values, like options of type CHECK and COMBO. In particular, changing the
value of an option of type CHECK didn't work, because the comparisons with
"true" and "false" would always return false. This means that the "Ponder"
and "UCI_Chess960" options haven't been working for a while.
Marco Costalba [Thu, 9 Jul 2009 12:36:08 +0000 (14:36 +0200)]
Revert last tweaks
Tests show no improvment, so revert for now.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 6 Jul 2009 09:55:55 +0000 (10:55 +0100)]
Joona tweaks of tempos and misc parameters
Unfortunatly this tweak does not give good results.
After 894 games at 1+0 we have:
Mod vs Orig +205/-236/=453 48.27% -12 ELO !!
Perhaps we should test again, but in the mean time
we are going to revert this.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 6 Jul 2009 10:20:05 +0000 (11:20 +0100)]
Restore development versioning and LSN filtering
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 6 Jul 2009 08:40:50 +0000 (09:40 +0100)]
Fix generation of check blocking promotion
A promotion move is not considered a possible evasion as it could be.
Bug introduced by patch
Convert also generate_pawn_blocking_evasions() to new API (7/5/2009)
Bug spotted by Kenny Dail.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 17:16:22 +0000 (18:16 +0100)]
Stockfish 1.4
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 20:56:04 +0000 (21:56 +0100)]
Small Makefile tweaks
Set gcc as default compiler on Linux, also compile
with symbols stripped to shrink binary file.
Original patch by Heinz van Saanen.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 17:10:39 +0000 (18:10 +0100)]
Fix bitcount.h compile warnings under Intel compiler
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 17:03:49 +0000 (18:03 +0100)]
Check Intel compiler before MSVC in bitcount.h
Predefined macro __INTEL_COMPILER is defined only for Intel,
while _MSC_VER is defined for both Intel C++ and MSVC.
So rearrange ifdefs to take in account this and test __INTEL_COMPILER
first and only if not defined check _MSC_VER for MSVC.
Patch suggested by Joona.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 09:32:51 +0000 (10:32 +0100)]
Add support for saving timing file during benchmark
Add a new argument to bench to specify the name of the
file where timing information will be saved for each
benchmark session.
This argument is optional, if not specified file will
not be created.
Original patch by Heinz van Saanen
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 4 Jul 2009 08:07:45 +0000 (09:07 +0100)]
Disable POPCNT support per default
This is mainly intended to allow 64 bit compiles on any
system and avoid to crash when the binary, compiled on a
box where POPCNT is not supported, is run on a Core i7
system or similar CPU.
What could happen is that when compiled in a standard 64 bit
system, because the correct headers for the POPCNT intrinsic
are not found, the compiler creates dummy bit count functions
instead, these are never called at runtime on the machine where
Stockfish has been compiled. But if we run the same binary on a
Core i7 system, because POPCNT is detected at run time, the dummy
bitcount functions will be called giving false results that will
crash the application.
Note that would be possible to fallback on software bit count in
these cases, but this is even more subtle because POPCNT path is not
optimized so that we have an application working but at sub-optimal
speed, so better to crash, at least user is loudly warned that there
is something wrong.
If, instead, Stockfish is compiled on a Core i7 system with POPCNT
enabled, then if the PGO compile has been done properly, the same binary
will run at optimal speed _both_ on the Core i7 machine and on any other
64 bit standard machine. This is the ideal mode for binary distribution.
Finally this patch disables bsfq support under Windows, because it seems
inline assembly is not supported both by MSVC and by Intel Windows version.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Jul 2009 12:18:59 +0000 (13:18 +0100)]
Do not compile POPCNT if NO_POPCNT is defined
Also rename DISABLE_POPCNT_SUPPORT in NO_POPCNT and simplify a bit
the macro logic.
Always define a __popcnt64()or _mm_popcnt_u64() template, if the proper
function with the same name is defined in the intrinsics header, then it
will be choosen as first otherwise we fall back on the dummy template
that is never called at runtime anyway because cpu_has_popcnt() returns
false.
This fixes the compile error reported by Jim.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Jul 2009 10:28:11 +0000 (12:28 +0200)]
Microptimize pawns info access
Avoid indirect calling of piece_of_color_and_type(c, PAWN) and its
alias pawns(c) in the pawn evaluation loop, but use the pawns
bitboards accessed only once before entering the loop.
Also explicitly mark functions as static to better self-document.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Jul 2009 07:40:41 +0000 (08:40 +0100)]
Restore correct 64 bit version of pop_1st_bit()
Was erroneusly changed with the 32bit in recent
patch "Retire USE_COMPACT_ROOK_ATTACKS...".
Also another clean up of define magics. Move compiler
specific definitions in types.h and remove redundant cruft.
Now this macro ugly mess seems more reasonable.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Jul 2009 07:28:13 +0000 (08:28 +0100)]
Use bsfq asm instruction to count bits
On 64 bit systems we can use bsfq instruction to count
set bits in a bitboard.
This is a patch for GCC and Intel compilers to take advantage
of that and get a 2% speed up.
Original patch from Heinz van Saanen, adapted to current tree
by me.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 2 Jul 2009 14:49:41 +0000 (16:49 +0200)]
Retire USE_COMPACT_ROOK_ATTACKS and USE_FOLDED_BITSCAN defines
This greatly simplifies bitboard.cpp that now has only two setups,
respectively for 32 and 64 bits CPU according to IS_64BIT define
that is automatically set but can be tweaked manually in
bitboard.h
No functional change both in 32 and in 64 bits.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 2 Jul 2009 00:54:17 +0000 (01:54 +0100)]
Revert per-thread history tables
Testing on Joona QUAD failed to give any
advantage. Actually we had a little loss:
Mod - Orig: 342.0 - 374.0
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 28 Jun 2009 23:50:36 +0000 (01:50 +0200)]
Joona tweaks of piece values
This is the backport of tuned piece values.
We needed to change also the psqt tables so that their
values, that are relative to piece values, remain the same.
Amost no change after 999 games:
Mod vs Orig 594-495 + 2 ELO points so well within error bar
It was expected somehow given the very little change of the
parameters values.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 28 Jun 2009 03:56:58 +0000 (05:56 +0200)]
Explicitly use delta psqt values when possible
Instead of add and subtract pqst values corrisponding to
the move starting and destination squares, do it in one
go with the helper function pst_delta<>()
This simplifies the code and also better documents that what
we need is a delta value, not an absolute one.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 22 Jun 2009 06:16:43 +0000 (08:16 +0200)]
Joona tweaks of pawns parameters
Test result after 999 games at 1+0
Mod vs Orig +278 =493 -228 52,50% +17 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Jun 2009 18:18:00 +0000 (19:18 +0100)]
Fix compile errors in debug mode
Fall out of move_promotion() rename
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Jun 2009 12:21:15 +0000 (14:21 +0200)]
Use POPCNT in evaluate_space() when available
This was forgotten by the POCNT patches.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Jun 2009 11:56:31 +0000 (13:56 +0200)]
Fix a couple of warnings under Intel compiler
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Jun 2009 07:31:39 +0000 (08:31 +0100)]
Micro optimize and rename move_promotion()
Rename to move_is_promotion() to be more clear, also add
a new function move_promotion_piece() to get the
promotion piece type in the few places where is needed.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Jun 2009 06:58:05 +0000 (07:58 +0100)]
Only on Windows do wait for input at the end of benchmark
Under MS Visual C++ debug window always unconditionally closes
when program exits, this is bad because we want to read results before.
So limit this kludge on Windows only.
Original patch by Heinz van Saanen.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 18 Jun 2009 13:22:39 +0000 (15:22 +0200)]
Skip castle rights update when not needed
Micro optimization in do_move(), a quick check
avoid us to update castle rights in almost 90%
of cases.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Joona Kiiski [Wed, 17 Jun 2009 10:16:51 +0000 (13:16 +0300)]
Disable use of aspiration window in known win positions
When we are hunting for mate, transposition table is filled in
with mate scores. Current implemenatation of aspiration search
can't cope with this very well.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Joona Kiiski [Wed, 17 Jun 2009 08:07:16 +0000 (11:07 +0300)]
Bugfix: KRK was not classified as KNOWN_WIN
Problem is that npMaterial is compared to _endgame_ value
of rook, although npMaterial is always (also in endgame!)
calculated using _middlegame_ values.
Bug was hidden as long as Rook middlegame
and endgame values were same.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 17 Jun 2009 06:59:09 +0000 (08:59 +0200)]
Give proper credit to Joona
Stockfish would not be as where is now without his
contributions.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 16 Jun 2009 13:06:26 +0000 (15:06 +0200)]
Joona tweaks of mobility and outposts bonus
These are the tuned values of mobility and outposts
after 100.000 games on Joona QUAD.
After 999 games at 1+0
Mod vs Orig +248 =537 -214 51.70% +12 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 16 Jun 2009 18:20:53 +0000 (19:20 +0100)]
Fix king value in SEE
When SEE piece values changed in
aaad48464b
of 9/12/2008 we forgot to update the value assigned in
case of captured king.
In that patch we changed the SEE piece values but without
proper testing. Probably it is a good idea to make some
tests with the old Glaurung values.
Bug spotted by Joona.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 13 Jun 2009 10:13:09 +0000 (11:13 +0100)]
Reduce SMP contention on TT
Move TT object away from heavy write accessed NodesSincePoll
and also, inside TT isolate the heavy accessed writes variable.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 12 Jun 2009 10:05:48 +0000 (12:05 +0200)]
Better clarify why recent generate_pawn_checks() works
We can have false positives, but these are filtered out
anyhow by following conditions so they are harmless.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 11 Jun 2009 13:57:42 +0000 (15:57 +0200)]
Code style triviality in search.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 11 Jun 2009 13:11:08 +0000 (15:11 +0200)]
Remove global variables from search.h
Globals are not really needed, so redefine as locals.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 11 Jun 2009 09:04:05 +0000 (11:04 +0200)]
MovePicker doesn't need to know if called from a pv node
This was needed by an old optimization in sorting of
non-captures that is now obsoleted by new std::sort()
approach.
Remove also the unused depth member data. Interestingly
this has always been unused since the Glaurung days.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 9 Jun 2009 10:21:35 +0000 (11:21 +0100)]
Joona tweaks of piece-square tables
These are the tuned psqt values after 100.000 games
on Joona QUAD. Results seem very good.
On PC 1 after 999 games
Mod vs Orig +261 =511 -227 51.70 % +12 ELO
On PC 2 after 913 games
Mod vs Orig +254 =448 -211 52.35 % +16 ELO
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 8 Jun 2009 11:52:52 +0000 (12:52 +0100)]
Move initialization of PawnInfo in its c'tor
Where it belongs.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>