Marco Costalba [Fri, 6 Apr 2012 13:17:08 +0000 (14:17 +0100)]
Teach UI thread to use main thread resources
So to avoid a crash when setting the moves in
UCI "position startpos moves ...." command.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Apr 2012 12:46:53 +0000 (13:46 +0100)]
Don't store Thread info in Position
But use the newly introduced local storage
for this. A good code semplification and also
the correct way to go.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Apr 2012 10:39:07 +0000 (12:39 +0200)]
Introduce thread local storage
Use thread local storage to store a pointer to the thread we
are running on. This will allow to remove thread info from
Position class.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Apr 2012 09:37:07 +0000 (11:37 +0200)]
Rewrite pop_1st_bit() to be endian independent
With this change sources are fully endianess
independent, so we can simplify the Makefile.
Somewhat surprisingly we don't have any speed
regression !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 4 Apr 2012 06:54:02 +0000 (07:54 +0100)]
Use a Thread instead of an array index
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Apr 2012 17:21:17 +0000 (18:21 +0100)]
Big Position renaming
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 4 Apr 2012 05:52:07 +0000 (06:52 +0100)]
Micro-optimize last_1() for 32bits
Verified assembly it is a bit simpler.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Apr 2012 17:38:50 +0000 (18:38 +0100)]
Fix bench with fen files regression
Erroneusly adds default positions to the fens
loaded from external file.
Bug introduced in
adb71b8096436a
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Apr 2012 06:41:26 +0000 (07:41 +0100)]
Simplify Endgames::probe()
With this API change we simplify both function and caller site.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 14:12:39 +0000 (15:12 +0100)]
Use polymorphism to resolve map() overloading
The 2 overload functions map() accept a pointer to
EndgameBase<Value> or a pointer to EndgameBase<ScaleFactor>.
Because Endgame<E> is derived from one of them we can
directly use a pointer to this class to resolve the
overload as is needed in Endgames::add().
Also made class Endgames fully parametrized and no more
hardcoded to the types (Value or ScaleFactor) of endgames
stored.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 11:26:14 +0000 (12:26 +0100)]
Use a std::vector to store searchMoves
A std::set (that is a rb_tree) seems really
overkill to store at most a handful of moves
and nothing in the common case.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 11:00:15 +0000 (12:00 +0100)]
Retire platform specifics include in misc.cpp
Now that platform.h is included in types.h we
don't need this stuff anymore.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 10:30:54 +0000 (11:30 +0100)]
Better document square flipping helpers
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 09:46:38 +0000 (10:46 +0100)]
Introduce Bitboards namespace
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Apr 2012 08:25:07 +0000 (09:25 +0100)]
Process 'bench' also from SF prompt
It is possible to start with 'stockfish', then from
command prompt type 'bench' and SF will do what you expect.
Old behaviour is anyhow preserved. As a bonus we can now
start from command line any UCI command understood by
Stockfish. The difference is that after execution of a
command from arguments SF quits, while at the end of the
same command from prompt SF stays in UCI loop.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Mar 2012 11:15:57 +0000 (12:15 +0100)]
Use std::vector to implement HashTable
Allows some code semplification and avoids directly
allocation and managing heap memory.
Also the usual renaming while there.
No functional change and no speed regression.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Mar 2012 08:43:16 +0000 (09:43 +0100)]
Rename Materials and Pawns hash stuff
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Mar 2012 08:16:09 +0000 (09:16 +0100)]
Complete the renaming in Search::LimitsType
This completes the job started with revision
4124c94583c8f61.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Mar 2012 09:01:31 +0000 (10:01 +0100)]
Reset search time as early as possible
In particualr before to wake up main thread that
could take some random time. Until we don't reset
search time we are not able to correctly track
the elapsed search time and this can be dangerous
under extreme time pressure.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Mar 2012 10:44:31 +0000 (12:44 +0200)]
Revert "Call wait_for_search_finished() only when quitting"
We need to wake up main thread if it is sleeping
waiting for stop or ponderhit, so we cannot skip
calling wait_for_search_finished().
Found by Othello1984.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Mar 2012 05:04:44 +0000 (06:04 +0100)]
Last touches to pawns shelter code
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Mar 2012 19:04:27 +0000 (20:04 +0100)]
Fix an hang when max depth is reached
In this case SF stop searching and goes sleeping
waiting for a stop / ponderhit before to return
best move. So when a "stop" arrives we need to wake
up the main thread again.
Another regression introduced by
3aa471f2a9cb,
hopefully the last one.
Thanks to Otello1984 to reporting this.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Mar 2012 10:44:41 +0000 (12:44 +0200)]
Refactor pawns shelter and storm
Renamed stuff and added comments. The aim is to make more
readable, at least by me ;-) , this newly added part of code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Mar 2012 18:01:37 +0000 (19:01 +0100)]
Restore MS1BTable[]
Incredible typo from my side!
The 2 tables are completely different, one counts 1s the
other returns the msb position. Even more incredible
the 'stockfish bench' command returns the same number
of nodes!!!
Spotted by Justin Blanchard.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Mar 2012 17:22:40 +0000 (18:22 +0100)]
Silently handle "ucinewgame" command
Avoid returning "Unknown command", it seems some
GUI are misguided by this.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Mar 2012 09:03:06 +0000 (11:03 +0200)]
Replace MS1BTable[] with BitCount8Bit[]
We already have the necessary infrastructure
in place.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Mar 2012 05:40:17 +0000 (22:40 -0700)]
Merge pull request #11 from glinscott/squash
Add more detailed pawn shelter/storm evaluation
After 10670 games at 10"+0.05
Mod vs Orig 2277 - 1941 - 6452 ELO +11 !!!
The first real increase since 2.2.2, congratulations Gary !!!
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 27 Mar 2012 17:47:41 +0000 (18:47 +0100)]
Set do_sleep out of lock protection
Fixes a not so rare crash (once every 100 games)
newly introduced. Unfortunatly I am still not
able to figure out why :-(
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 27 Mar 2012 10:27:57 +0000 (12:27 +0200)]
Use UCI names in Search::LimitsType
There is no need to "invent" different names
from the original UCI parameters.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 26 Mar 2012 18:55:32 +0000 (11:55 -0700)]
Merge pull request #9 from glinscott/master
Penalty for undefended rook
Almost no change at longer TC, but perhaps there
is a tiny increase....
After 17522 games at 10"+0.05
Mod vs Orig 3064 - 2967 - 11491 ELO +2
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 26 Mar 2012 17:56:48 +0000 (18:56 +0100)]
Simplify start_searching() signature
Retire the "sync" behaviour that now is up to
the caller to honour.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 26 Mar 2012 17:35:23 +0000 (18:35 +0100)]
Call wait_for_search_finished() only when quitting
When quitting we should avoid RootPosition to be
destroyed while threads are still running, leading
to a crash. In case of a "stop" or "ponderhit"
command there is no need for the UI thread to wait.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 26 Mar 2012 15:19:37 +0000 (17:19 +0200)]
Introduce and use wait_for_search_finished()
Helper function that allows us to simplify
the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Gary Linscott [Mon, 26 Mar 2012 11:52:10 +0000 (07:52 -0400)]
Add more detailed pawn shelter/storm evaluation
Marco Costalba [Mon, 26 Mar 2012 06:58:10 +0000 (07:58 +0100)]
Move ThreadsManager::exit() to d'tor
And add final touches to this long patch series.
All the series has been verified against regression with
20K games at fast TC.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 25 Mar 2012 22:08:35 +0000 (23:08 +0100)]
Fix compile error with gcc
We have a clash with start_fn defined both as a
Thread memeber and as a function pointer type in
pthread_create().
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 25 Mar 2012 15:44:55 +0000 (16:44 +0100)]
Reset Thread::maxPly before a new search
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 25 Mar 2012 15:31:50 +0000 (16:31 +0100)]
Fix race in ThreadsManager::sleep()
We cannot set do_sleep flag of main thread before
"bestmove" is sent to GUI, otherwise GUI could send
immediately the next "go" command that triggers
start_thinking() and because do_sleep is set UI
thread resets the flag to launch a new search. But
when shortly after main thread returns to main_loop()
flag is incorrectly reset and main thread goes to sleep
hanging the engine.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Gary Linscott [Sun, 25 Mar 2012 14:18:29 +0000 (10:18 -0400)]
Merge remote-tracking branch 'upstream/master'
Marco Costalba [Sun, 25 Mar 2012 11:01:56 +0000 (12:01 +0100)]
Try to mimic std::thread API
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 24 Mar 2012 20:36:33 +0000 (21:36 +0100)]
Use std::vector<Thread*> to store threads
We store pointers instead of Thread objects because
Thread is not copy-constructible nor copy-assignable
and default ones are not suitable. So we cannot store
directly in a std::vector.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 24 Mar 2012 19:10:13 +0000 (20:10 +0100)]
Refactor Thread class
Associate platform OS thread to the Thread class instead of
creating it from ThreadsManager.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 24 Mar 2012 18:29:12 +0000 (19:29 +0100)]
Refactor ThreadsManager::set_size() functionality
Split the data allocation, now done (mostly once)
in read_uci_options(), from the wake up and sleeping
of the slave threads upon entering/exiting the search.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 25 Mar 2012 09:23:16 +0000 (10:23 +0100)]
Revert "Don't sync with C library I/O buffers"
It seems is the cause of strange and rare hangs
reported by some users where Stockfish stops
responding to GUI. It is not clear why but for
the moment revert the patch.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 25 Mar 2012 08:54:20 +0000 (09:54 +0100)]
Don't ceil cpu_count()
It is already done at calling site where it is
more appropiate.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 24 Mar 2012 09:14:21 +0000 (10:14 +0100)]
Fix a MSVC warning
Not correct warning about use of an uninitialized
variable. The warning is not correct becuase we can
never reach the warned code when in SpNode, anyhow
the fix is simple.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 24 Mar 2012 08:52:41 +0000 (09:52 +0100)]
Rename lock.h to platform.h
And move some more platform specific code there.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 23 Mar 2012 12:12:26 +0000 (13:12 +0100)]
Remove last platform specific code form thread.cpp
A somewhat tricky function pointer cast allows us
to move the platform specifics to lock.h, the cast
is tricky because return type is not the same of the
casted function in Linux (for Windows return type is
a DWORD that is a long) but this should not be a
problem as long as the size is the same;
From: http://stackoverflow.com/questions/188839/function-pointer-cast-to-different-signature
"OpenSSL was only casting functions pointers to
other function types taking and returning the same
number of values of the same exact sizes, and this
(assuming you're not dealing with floating-point)
happens to be safe across all the platforms and
calling conventions I know of. However, anything
else is potentially unsafe."
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 22 Mar 2012 21:39:10 +0000 (22:39 +0100)]
Merge two loops in ThreadsManager::init()
In analogy with ThreadsManager::exit()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 20 Mar 2012 10:45:27 +0000 (11:45 +0100)]
Use a local copy of tte->value()
This should avoid some aliasing issues
with TT table access.
After 3913 games at 10"+0.05
Mod vs Orig 662 - 651 - 2600 ELO +0 (+- 6.4)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Gary Linscott [Thu, 22 Mar 2012 11:33:47 +0000 (07:33 -0400)]
Penalty for undefended rook as well
mcostalba [Thu, 22 Mar 2012 06:39:53 +0000 (23:39 -0700)]
Merge pull request #8 from glinscott/master
Optimize undefended minor check. Little editing by
me, no change even at assembly level.
No regression after 8K games at fast TC on a 64bit CPU.
Gary Linscott [Wed, 21 Mar 2012 12:19:21 +0000 (08:19 -0400)]
Optimize undefended minor check.
Gary Linscott [Wed, 21 Mar 2012 06:26:46 +0000 (07:26 +0100)]
Penalize undefended minors
Even if not under attack. This seems to be good
especially on openings.
After 12112 games at 10"+0.05
Mod vs Orig 2175 - 1997 - 7940 ELO +5 (+- 3.7)
[Patch series from Gary, little edited by me]
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 20 Mar 2012 19:50:24 +0000 (20:50 +0100)]
Fix Logger under MSVC iostream libraries
We need splitted Tie classes because MSVC stream library
takes a lock on buffer both on reading and on writing and
this causes an hang because, while searching, the I/O
thread is locked on getline() and when main thread is
trying to std::cout() something it blocks on the same
lock waiting for I/O thread getting some input and
releasing the lock.
The solution is to use separated streambuf objects for
cin and cout.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 20 Mar 2012 13:40:09 +0000 (14:40 +0100)]
Remove cruft from Logger class
A big code simplification and cruft removing, make
Logger class a singleton and fully self conteined.
Also add direction indicators (">>" and "<<") to
better differentiate input and output lines in the
log file.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 20 Mar 2012 06:09:58 +0000 (07:09 +0100)]
Better on_change() argument name
Using "o" as a parameter with the on_xxx(const UICOption& o)
functions is a bit dangerous because of confusion with "0".
Suggested by Rein Halbersma.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 19 Mar 2012 20:36:25 +0000 (21:36 +0100)]
Add also logging of std::cin
Some trial was needed to find the correct recipe but now
we log both stdin and stdout to file "io_log.txt".
Link http://spec.winprog.org/streams/ was very useful
to understand the details of iostreams implementation.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 18 Mar 2012 02:20:43 +0000 (03:20 +0100)]
Add (smart) logging facility
By means of "Use Debug Log" UCI option it is possible to toggle
the logging of std::cout to file "out.txt" while preserving
the usual output to stdout. There is zero overhead when logging
is disabled and we achieved this without changing a single line
of exsisting code, in particular we still use std::cout as usual.
The idea and part of the code comes from this article:
http://groups.google.com/group/comp.lang.c++/msg/
1d941c0f26ea0d81
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 18 Mar 2012 22:08:37 +0000 (23:08 +0100)]
Show startup messages immediately
In particular before initialization. So that SF
seems more snappy at startup.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 18 Mar 2012 10:33:54 +0000 (11:33 +0100)]
Revert to byTypeBB[0] storing occupied squares
As it was in Glaurung times. Also rearranged order
so that byTypeBB[0] is accessed before byTypeBB[x]
to be more cache friendly. It seems there is even
a small speedup.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 18 Mar 2012 10:10:12 +0000 (11:10 +0100)]
Rename occupied_squares() to pieces()
Also some microoptimizations, were there from ages
but hidden: the renaming suddendly made them visible!
This is a good example of how better naming lets you write
better code. Naming is really a kind of black art!
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 17 Mar 2012 20:18:02 +0000 (21:18 +0100)]
UCI buttons don't need a value
Take advantage of this to further simplify the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 17 Mar 2012 12:16:23 +0000 (13:16 +0100)]
Don't use "OwnBook" by default
Stick to UCI protocol that says:
* by default all the opening book handling is done by the GUI,
but there is an option for the engine to use its own book
("OwnBook" option, see below)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 17 Mar 2012 10:24:19 +0000 (11:24 +0100)]
Retire "ucinewgame" UCI option
UCI protocol it is not clear about what the engine
should be supposed to do when "ucinewgame" is
received. Stockfish simply sets the position to
start FEN, but it is redundant becuase the GUI always
resends the position after "ucinewgame" command, so
it seems we can safely ignore that command.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 17 Mar 2012 09:29:33 +0000 (10:29 +0100)]
Fix UCI 'button' options
When a button fires UCIOption::operator=() is called and from
there the on_change() function. Now it happens that in case of
a button the on_change() function resets option's value to
"false" triggering again UCIOption::operator=() that calls again
on_change() and so on in an endless loop that is experienced
by the user as an application hang.
Rework the button logic to fix the issue and also be more clear
about how button works.
Reported by several people working with Scid and tracked down
to the "Clear Hash" UCI button by Steven Atkinson.
Bug recently introduced by
2ef5b4066e649.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 12 Mar 2012 14:21:54 +0000 (15:21 +0100)]
Don't sync with C library I/O buffers
Now we are forced to just use C++ iostream becuase
buffers are independent and using C library functions
like printf() or scanf() could yield to issues.
Speed up of about 1%.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 10 Mar 2012 18:38:56 +0000 (19:38 +0100)]
Fix time_to_msec() precision
Result of t.time * 1000 should be a 64 bit value, not an int.
Bug reported by several users.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 6 Mar 2012 09:09:37 +0000 (10:09 +0100)]
Introduce Eval namespace
Wrap evaluation related stuff and reshuffle
a bit the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 25 Feb 2012 11:45:34 +0000 (12:45 +0100)]
Double pinner bonus
Fine tune newly introduced pinner bonus score:
After 34696 games at 2"+0.05
Mod vs Orig 7474 - 7087 - 20135 ELO +3 (+- 2.4)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 5 Mar 2012 18:24:59 +0000 (19:24 +0100)]
Convert init of eval to async option
So to be done only once at startup and in the (unlikely)
cases that a relevant UCI parameter is changed, instead
of doing it at the beginning of each search.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 4 Mar 2012 16:57:01 +0000 (17:57 +0100)]
Async UCI options actions
Introduce 'on change' actions that are triggered as soon as
an UCI option is changed by the GUI. This allows to set hash
size before to start the game, helpful especially on very fast
TC and big TT size.
As a side effect remove the 'button' type option, that now
is managed as a 'check' type.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 3 Mar 2012 17:53:37 +0000 (18:53 +0100)]
Use new Time class in timed_wait()
And simplify the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 4 Mar 2012 22:26:08 +0000 (23:26 +0100)]
Introduce single_bit() helper
Self-documenting code instead of a tricky
bitwise tweak, not known by everybody.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 25 Feb 2012 11:45:34 +0000 (12:45 +0100)]
Introduce pinning bonus
Add a bonus if a slider is pinning an enemy piece.
Idea from Critter.
After 27443 games at 2"+0.05
Mod vs Orig 5900 - 5518 - 16025 ELO +4 (+- 2.7)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 3 Mar 2012 08:35:56 +0000 (09:35 +0100)]
Rewrite time measurement code
Introduce and use a new Time class designed after
QTime, from Qt framework. Should be a more clear and
self documented code.
As an added benefit we now use 64 bits internally to get
millisecs from system time. This avoids to wrap around
to 0 every 2^32 milliseconds, which is 49.71 days.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 8 Jan 2012 08:58:03 +0000 (09:58 +0100)]
Halve rook on open file bonus for endgame
After 42206 fast games TC 2"+0.05
Mod vs Orig 12871 - 16849 - 12486 ELO +3 (+- 2.6)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 27 Feb 2012 19:30:34 +0000 (20:30 +0100)]
Fix a shift overflow warning
Visual Studio 11 is worried that shift result could
overflow an integer, this is impossible becuase max
value of the shift is 4, but compiler cannot know it.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 27 Feb 2012 11:11:18 +0000 (12:11 +0100)]
Micro-optmize castling moves
Pre compute castle path so to quickly test
for impeded rule.
This speeds up perft on starting position
of more than 2%.
No functional change
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Feb 2012 17:31:02 +0000 (18:31 +0100)]
Rename promotion_piece_type() to promotion_type()
Shorter and equally clear to understand.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Feb 2012 16:34:24 +0000 (17:34 +0100)]
Introduce another two (bitboard,square) operators
And simplify the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 26 Feb 2012 11:04:35 +0000 (12:04 +0100)]
Fix MSVC warning on streampos to size_t conversion
Fix this warning with MSVC 64 bits:
warning C4244: '=' : conversion from 'std::streampos' to 'size_t',
possible loss of data
Point is that std::streampos could be negative, while size_t
is always non-negative.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Feb 2012 13:21:25 +0000 (14:21 +0100)]
Retire ss->bestMove
And introduce SPlitPoint bestMove to pass back the
best move after a split point.
This allow to define as const the search stack passed
to split.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Feb 2012 13:07:43 +0000 (14:07 +0100)]
Don't update bestValue in check_is_dangerous()
It is a prerequisite for next patch and simplifies
the function. testing at ultra fast TC shows no
regression.
After 24302 games at 2"+0.05
Mod vs Orig 5122 - 5038 - 13872 ELO +1 (+- 2.9)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Feb 2012 18:32:15 +0000 (19:32 +0100)]
Fix a wrong check in pos_is_ok()
Bug introduced by revision
a44c5cf4f77b05a038
of 3/12/2011.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 20 Feb 2012 09:23:55 +0000 (10:23 +0100)]
Further simplify castling rights
Reverse the meaning of castleRightsMask[sq] so that now
is stored the castling right that will be removed in
case a move starts from or arrives to sq square. This
allows to simplify the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 13 Feb 2012 08:17:56 +0000 (09:17 +0100)]
Spread usage of pos.piece_moved()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 19 Feb 2012 10:44:45 +0000 (11:44 +0100)]
Retire empty_squares()
Use ~pos.occupied_squares() instead and avoid to
hide the ~ computation.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 19 Feb 2012 10:28:42 +0000 (11:28 +0100)]
Index en-passant zobrist keys by file
Instead of by square. This is a more conventional
approach, as reported also in:
http://chessprogramming.wikispaces.com/Zobrist+Hashing
We shrink zobEp[] from 64 to 8 keys at the cost of an extra
'and 7' at runtime to get the file out of the ep square.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 19 Feb 2012 09:32:06 +0000 (10:32 +0100)]
Move some stuff out of lock protection in split()
We shouldn't need lock protection to increment
splitPointsCnt and set curSplitPoint of masterThread.
Anyhow because this code is very tricky and prone to
races bound the change in a single patch.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 18 Feb 2012 20:30:33 +0000 (21:30 +0100)]
Micro-optimize castleRights update
When updating castleRights in do_move() perform only one
64bit xor with zobCastle[] instead of two.
The trick here is to define zobCastle[] keys of composite
castling rights as a xor combination of the keys of the
single castling rights, instead of 16 independent keys.
Idea from Critter although implementation is different.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 18 Feb 2012 09:57:00 +0000 (10:57 +0100)]
Small renaming in Thread struct
Should be a bit more clear the meaning of the
single variables.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 17 Feb 2012 19:38:17 +0000 (20:38 +0100)]
Fix a race when extracting PV from TT
Because TT table is shared tte->move() could change
under our feet, in particular we could validate
tte->move() then the move is changed by another
thread and we call pos.do_move() with a move different
from the original validated one !
This leads to a very rare but reproducible crash once
every about 20K games.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 18 Feb 2012 09:16:01 +0000 (10:16 +0100)]
Increase MAX_PLY from 100 to 256
There is no need to limit the maximum ply searched to
100, with deep exclusion search extensions we could
reach it even with much smaller search depths.
The only drawback is an increase in stack usage, but
is limited mainly to id_loop(), in particular the
recursive search() functions are not affected.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 13 Feb 2012 08:52:58 +0000 (09:52 +0100)]
Micro-optimize pop_1st_bit() for 32 bits
Small perft speed-up of 2% and also a code
simplification.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 15:02:13 +0000 (16:02 +0100)]
Templetize sliding attacks
No functional change and no speed regression, it seems
to be even a bit faster on MSVC and gcc.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 14:12:01 +0000 (15:12 +0100)]
Speedup sliders attacks for 32bit CPU
Replace a 64 bit 'and' by two 32 bits ones and
use unsigned instead of int.
This simple patch increases perft speed of 6% on
my Intel Core 2 Duo !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 13:07:21 +0000 (14:07 +0100)]
Don't wake up threads at the beginning of the search
But only when needed, after a split point. This behaviour
does not apply when useSleepingThreads is false, becuase
in this case threads are not woken up at split points so
must be already running.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 08:59:19 +0000 (09:59 +0100)]
Don't reset 50-move counter after castling
Rule says should be reset only after a capture and/or
a pawn move.
This incredible bug was here since Glaurung times !
Spotted by Kiriakos.
No functional change in the test bench because we
don't reach the 50 moves limits.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
mcostalba [Mon, 6 Feb 2012 05:34:32 +0000 (21:34 -0800)]
Merge pull request #3 from glinscott/
b46bf29
Detect stalemate in evaluation