1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00
Commit graph

2581 commits

Author SHA1 Message Date
Marco Costalba
2f4a9a140a Avoid wake up master thread when useless
Check we are the last slave of the split point
before to wake up the master. This should avoid
spurious wakes up.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-19 23:01:47 +01:00
Marco Costalba
dba1bc354a Simplify idle_loop() signature
We can detect the split point master also from within idle_loop,
so we can call the function without parameters and remove an
overloaded member hack in Thread class.

Note that we don't need to take a lock around curSplitPoint
when entering idle_loop() because if we are the master then
curSplitPoint cannot change under our feet (because is_searching
is set and so we cannot be reallocated), if we are a slave
we enter idle_loop() only upon Thread creation and in that case
is always splitPointsCnt == 0. This is true even in the very rare
case that curSplitPoint != NULL, if we have been already allocated
even before entering idle_loop().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-19 23:01:28 +01:00
Marco Costalba
4b19430103 Prefer size_t over int for array sizes
Align to standard library conventions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-19 11:01:46 +01:00
Marco Costalba
7c1f8dbde9 Introduce namespace Bitbases
Let's continue this namespace galore...

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-18 13:08:12 +01:00
Marco Costalba
2c1ba2ab0d Introduce namespace UCI
Ater previous patch it comes naturally to take this
extra step.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-18 12:26:22 +01:00
Marco Costalba
b011818917 Retire struct OptionsMap
Directly use the underlying std::map instead and avoid
a useless inheritance.

As a nice side-effect Options global object has now a
default c'tor avoiding possible issues with globals
initializations.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-18 11:30:27 +01:00
Marco Costalba
bc4de9edae Explicitly qualify STL functions
Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-18 11:00:56 +01:00
Marco Costalba
9de4ee6d32 Retire MovePickerExt struct
Templetize MovePicker::next_move() member function instead. It
is easier and we also avoid the forwarding of MovePicker() c'tor
arguments in the common case.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-08-18 10:46:24 +01:00
Marco Costalba
90ec4a403a Guard against 'divide by zero' in bench
Also remove an useless cast.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-30 18:05:15 +01:00
Joseph R. Prostko
b61ec33f22 Added Haiku-specific changes to Makefile
First change: If Haiku is host platform, change
installation prefix to /boot/common/bin

Second change: Only link in pthreads if Haiku isn't
host platform.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-30 06:29:46 +01:00
Marco Costalba
1f7b5d9a79 Fix UCI promotion move notation
Regression introduced by revision
f0db6a6c0b

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-26 18:16:24 +01:00
Linus Arver
5c6ba81cf2 Readme.txt: more grammar/style fixes 2012-07-19 12:09:39 -07:00
Linus Arver
591adf564a Readme.txt: grammar/stylistic fixes 2012-07-18 16:46:51 -07:00
Marco Costalba
f0db6a6c0b Fix regression in move_to_san()
Broken since commit 628808a113

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-15 09:22:00 +01:00
Marco Costalba
520e680278 Introduce notation.h
And group there all the formatting functions but
uci_pv() that requires access to search.cpp variables.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-15 08:29:07 +01:00
Marco Costalba
abc6a0be2f Rewrite pv_info_xxx() signatures
Use the helpers to format the PV info but without
writing to output stream (file or cout). Message
formatting and sending are two logically different
task.

Incidentaly reintroduce the pretty_pv() name,
from Glaurung memories :-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-15 07:48:33 +01:00
Marco Costalba
9dbda6652e Include castle moves in 'dangerous' flag
Simplifies the code and seems more natural.

We have a very small fucntional change becuase now
at PV nodes castles are extended one ply anyhow.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-14 12:29:11 +01:00
Marco Costalba
5dc0df8435 Merge exclusion search conditions
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-14 12:18:14 +01:00
Marco Costalba
6e5a334c95 Remove redundant condition in is_dangerous()
A pawn on 7th is always passed so retire
this redundant condition.

No funtional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-13 17:57:26 +01:00
Marco Costalba
6becc81446 Silence a MSVC warning in class Tie
With warning level 4 MSVC complains that a default
assignment operator could not be generated due to
member 'file' is a reference (warning C4512).

Use a pointer instead of a reference and move
struct Tie outisde class Logger while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-08 10:50:23 +01:00
Marco Costalba
6b5322ce00 Rename first_1 / last_1 in lsb / msb
It seems more accurate: lsb is clear while 'first
bit' depends from where you look at the bitboard.

And fix compile in case of 64 bits platforms that
do not use BSFQ intrinsics.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-08 09:36:40 +01:00
Marco Costalba
67d91dfd50 Use last_1() to compute new TT size
Transposition table consists of a power of 2
number of TTCluster entries.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-07 19:46:13 +01:00
Marco Costalba
089e54c7fd Revert to -O3 with Clang
Instead of -O4 option that does not work with both mingw and
Linux gcc (tested with Clang 3.1).

As reported by Reed Kotler:
Turns out that -O4 is not a valid option for clang unless you have
the proper gold linker and plugins built. That's because -O4 enables
LTO, which writes out bitcode files during the compile, and then loads
those and optimizes them during the link phase.

It requires a linker that supports LLVM's LTO. There is a plugin for
Gold available as part of LLVM.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-07 19:05:38 +01:00
Marco Costalba
0b3ffb54b7 Fix signedness warning in time_to_msec()
We have a signed integer here so let the return type
take in account that.

Found by Clang with -Weverything option.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-07 16:28:39 +01:00
Marco Costalba
775488340e More idiomatic signature for operator=()
Return a reference instead of void so to enable
chained assignments like

"p = q = Position(...);"

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-05 11:55:35 +01:00
Marco Costalba
7d2530873e Streamline null search reduction formula
Although a (little) functional change, we have no ELO change
but formula it is now more clear.

After 13019 games at 30"+0.05
Mod vs Orig 2075 - 2088 - 8856 ELO 0 (+- 3.4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-07-05 11:48:17 +01:00
Marco Costalba
18505f1fc4 Clear transposition table on "ucinewgame"
It seems the standard behaviour as implemented
in most engines although UCI protocol does not
specify what to do upon "ucinewgame" command.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-30 08:00:48 +01:00
Marco Costalba
dc88cd691f Templetize make_move() helpers
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-25 08:09:55 +01:00
Marco Costalba
ebe8009aff Reduce indentation in UCIOption::operator=()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-25 00:14:42 +01:00
Marco Costalba
628808a113 Micro-optimize move_to_san()
Calculate the attacks only for the piece to disambiguate,
not for all.

Also some reformatting while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-24 12:38:29 +01:00
Marco Costalba
dc7fd868f4 Use type_of() to categorize the moves
Needed to rename old MoveType (used in move generation)
to GenType.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-24 11:07:18 +01:00
Marco Costalba
7b4aa10708 Rename move.cpp to notation.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-24 09:46:31 +01:00
Marco Costalba
960a689769 Rename ThreadsManager to ThreadPool
It is a more standard naming convention.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-24 09:45:37 +01:00
Marco Costalba
5f5d056c8f Replace make_square() with operator|(File, Rank)
Be fancy :-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-23 09:17:54 +01:00
Marco Costalba
9c7e2c8f9d Coding style in move.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-23 08:34:07 +01:00
Marco Costalba
4f5680950a Add min pawn-king distance to endgame evaluation
At endgame time push the king near his pawns (actually
one of them).

Original idea is from Critter (although slightly different),
implementation is mine and is completely different from the
original, in particular it is different the algorithm to
compute the minimum distance from pawns.

After 19895 games at 15"+0.05
Mod vs Orig 3638 - 3248 - 13009 ELO +7

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-22 06:31:18 +01:00
Marco Costalba
9793fa1906 Calculate min distance between king and his pawns
Just added infrastructure.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-17 09:41:18 +01:00
Marco Costalba
0446fc85de Reformat pick_random() in magics calculation
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-10 11:46:52 +01:00
Marco Costalba
764d3f44b6 Fix a compile error in opposite_colors()
Error is due to ambiguous overloading of operator^
because we have both the built-in operator^(int, int)
and the user defined operator^(Bitboard, Square).

This error does not trigger when using Makefile becuase,
due to luck, the user defined operator^(Bitboard, Square)
happens to be always defined _after_ opposite_colors() so
that compiler does not claim. But in case of Microsoft MSVC
we don't have a Makefile and the order of files compilation
is chosen by the compiler (in an unpredictable way). So it
could still happen that error is not detected (as in my case),
but in another case the order of compilation of the files could
be so that at some point both operator^ were defined before
opposite_colors() and this triggers the error.

The fix is much simpler than the explanation :-)

Reported by Quocvuong82.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-06-02 09:04:11 +01:00
Marco Costalba
0412f4a1ee Fix an issue when adding a book during the game
Currently when we fail to open a book file, for instance
if it doesn't exsist, we leave Book::open() with ifstream
failbit set. If then the book file is added, we correctly
open it at next attempt, but failbit is still set so that
after opening we exit because ifstream::good() returns false.

The fix is to reset failbit upon exiting.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-27 14:13:14 +01:00
Marco Costalba
6828325881 Retire PieceOffset[] in book.cpp
And calculate piece offset on the fly. Also
improve comments.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-27 13:46:55 +01:00
Marco Costalba
61a054b170 Fix a possible 'Division by zero'
In case a book entry has 'count' field set to 0
we crash. Spotted by Clang's static analyzer.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-26 23:17:22 +01:00
Marco Costalba
3361ad4242 Rename psq_score in ReducedStateInfo
So to be fully in sync with StateInfo, and move struct
to position.h, just below StateInfo.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-26 22:43:23 +01:00
Marco Costalba
6c9c6dd989 Fix book file regression
Revision 2aac860db3 of 27 / 4 / 2012
changed can_castle() signatures from bool to int and
this broke the code that calculates polyglot hash key
in book.cpp

Instead of directly fixing the code we prefer to change
castling rights definitions to align to the polyglot ones
(as we did in previous patch). After this step we can simply
take internal castle rights as they are and use them
directly to calculate polyglot book hash key, as we do
in this patch that fixes the regression.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-26 10:14:08 +01:00
Marco Costalba
a358dfe934 Redefine enum CastleRight
To be aligned with PolyGlot book castle right definitions.

This will be used by next patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-26 10:03:35 +01:00
Marco Costalba
0ecc920a09 Add a known draw case in kpk bitbase generation
Early classify as known draws the positions
where white king is trapped on the rook file.

Suggested by Dan Honeycutt.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-19 08:45:16 +01:00
Marco Costalba
f86182e791 Simplify Position::print()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-12 12:50:11 +01:00
Marco Costalba
c19a6ef82d Revert "Don't split if reduced below min_split_depth"
After extensive testing (I was off line this week and let
the test go on) it seems this change is useless:

After 33968 games on a QUAD (4 threads) at 15"+0.05
Mod vs Orig 5425 - 5550 - 22993 ELO -1 (+-2.1)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-12 10:00:26 +01:00
Marco Costalba
ecb84464f9 Improve previous patch
Only in case of promotion we care about an upper case
promotion piece char, so std::transform() is overkill
for the task.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-12 09:21:52 +01:00
Balint Pfliegel
1b2af05ea6 Junior promotion patch
Assumption: Junior sends promotions according to the side to move (ucase/lcase).
Fact: Stockfish generally handles promotion lcase.
Patch: Handling position fen input moves always with lcase promotions.

Ported back by Portfish. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-05-12 00:04:17 +01:00