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

3923 commits

Author SHA1 Message Date
Marco Costalba
4119955044 Get rid of get_key()
And also of namespace Zobrist: there is no more need
for TB code to look at Position's internals.
2016-04-24 21:46:06 +02:00
Marco Costalba
fe6ba8d805 Retire load_dtz_table() 2016-04-24 20:49:07 +02:00
Marco Costalba
637f5b5ecb Convert DTZ_table to a std::list
Because it is used as a list, with a LRU
replacement policy and LRU enries order.

Also drop the hardcoded limit on max 64 entries.
2016-04-24 18:50:06 +02:00
Marco Costalba
216e8cc195 Get rid of fixed size array
Use std::deque instead because it preserves references
to its elements when resizing (std::vector does not).

DTZ_table is still an array because it seems its size
is fixed and does not depend on TB exsisting files.
2016-04-24 14:33:41 +02:00
Marco Costalba
1a8e0416bb Document encode_piece
Retire Flipdiag[] while there
2016-04-24 14:07:13 +02:00
Marco Costalba
39e4398133 Retire probe_dtz() from Tablebases
It is not needed in SF.
2016-04-24 12:40:29 +02:00
Marco Costalba
7aeef7285f Sync with master 2016-04-24 11:55:44 +02:00
Marco Costalba
9bf2a9f842 Add a FIXME on the odd probe_ab()
Given a position probe_ab() does a kind of qsearch,
but instead of evaluating the position at the begin,
through a table look up, it performs a depth-first
search and only at the end checks for current position
score.
2016-04-24 11:47:59 +02:00
lucasart
d434fc465b Use Square instead of int
No functional change.
2016-04-24 07:41:21 +02:00
lucasart
3771db79eb Use File instead of int
No functional change.
2016-04-24 07:41:21 +02:00
lucasart
eb484823d7 Document enc_type
No functional change.
2016-04-24 07:41:21 +02:00
VoyagerOne
e082112cfe Use FMHs to assist with LMR formula.
STC:
LLR: 2.99 (-2.94,2.94) [0.00,5.00]
Total: 52232 W: 9654 L: 9304 D: 33274

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 115988 W: 15550 L: 15049 D: 85389

Bench: 7890808

Resolves #651
2016-04-24 01:00:58 +01:00
erbsenzaehler
4048bae47b Use -O3 for all compilers (including ICC)
There seems to be no benefit from using -fast over -O3 with icc.
So use -O3 everywhere.

No functional change

Resolves #652
2016-04-24 00:55:56 +01:00
Marco Costalba
63b39c5bff Use SF Position to calculate material key
Don't reinvent the wheel.

Also clarify that init_tb it is used to
populate TBHash: rename it in proper way.
2016-04-23 23:05:22 +02:00
Marco Costalba
024fec7a2b Drop another couple of define
And simplify file name extarction function
2016-04-23 13:14:24 +02:00
Marco Costalba
a14fa77ede Free Tablebases before to exit
Fix valgrind errors.
2016-04-23 12:20:07 +02:00
Marco Costalba
7bc5946fc9 Clean up decompress_pairs
Also replace platform specific byte swap with
a software version. Amazingly it seems it is
even faster now!

Also removing the templatized form does not slow down.
2016-04-23 11:52:51 +02:00
DU-jdto
c737062436 Remove some pointless micro-optimizations
Seems to give around 1% speed-up for CPUs with popcnt support.
Seems to give a very minor speed-up for CPUs without popcnt.

No functional change

Resolves #646
2016-04-23 02:04:28 +01:00
Marco Costalba
5414eaba35 Introduce WDLScore
Start to add some type safety above naked int

Improve code self-documenting readibility as well.
2016-04-22 09:23:36 +02:00
Marco Costalba
54d0cf1f89 Assorted cleanup 2016-04-22 08:39:13 +02:00
lucasart
b82f6dabcc Assorted cleanup
No functional change.
2016-04-22 10:20:37 +08:00
Marco Costalba
c6e96881ca Cleanup probe_wdl_table()
Memory barrier is totally unused inside a locked scope.
2016-04-21 22:23:34 +02:00
Marco Costalba
1073ffb26a Hash rewrite 2016-04-21 22:11:25 +02:00
Marco Costalba
8db35c8a5f Rework hash table access 2016-04-21 22:01:11 +02:00
Marco Costalba
b4985de966 Assorted formatting 2016-04-21 22:01:10 +02:00
lucasart
f4c930e038 Additional work in init_tb()
* document 0x38

* remove useless enc_type

For whatever reason (?), syzygy tables have the information to play a stupid
chess variant that (apparently) can result in having only 1 King on the board
instead of 2. Obviously, we do not care about this "game" which is neither
Chess, nor Chess960, so get rid of that useless code.

No functional change.
2016-04-21 22:00:39 +02:00
Marco Costalba
6b5a350bc3 Merge cpp files
* Properly include tbcore.cpp

* Merge *cpp files

* Additional reshuffle and consolidation

* Cosmetic touch

- run: astyle -A3 -s4 -f -xn -xc -xl *.cpp *.h. Mainly this breaks blocks (if,
  do, while, for etc.)

- remove static_cast<>: inconsistently used, and ugly. Prefer C-style cast.
  Eventually, the code will be rewritten so that less casting is needed...

No functional change.
2016-04-21 06:40:27 +02:00
Marco Costalba
8a3569f667 Platform agnostic file functions (#643)
Platform agnostic file functions

Reduce the platform specific code to bare minimum
and localize all in a single place.
2016-04-20 15:12:32 +02:00
lucasart
e2507b23ff regenerate syzygy.epd (#644)
this time, without stalemates and checkmates...
2016-04-20 14:13:16 +02:00
Marco Costalba
be45c212cd Avoid encode/decode madness in init_tb (#641)
* Avoid encode/decode madness in init_tb

We encode pieces in a string passed to init_tb() that
just decodes the exactly same string to get the pieces back!

Sanitize this madness.

No functional change.

* Further cleanup init_tb

* Avoid useless intermediate conversions of TB paths

In many cases original information is converted to
an intermediate form to be then further used later.

In many cases this intermediate form is useless and
the original information can be used directly instead.

This patch removes a typical case.

Also simplified open_tb() signature.

* Address some Lucas review comments
2016-04-19 15:19:42 +02:00
lucasart
8609c4ece4 use std::sort() (#640)
No functional change.
2016-04-18 15:13:03 +02:00
Marco Costalba
994f9a7a35 Fix incorrect draw detection
In this position we should have draw for repetition:

position fen rnbqkbnr/2pppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves g1f3 g8f6 f3g1
go infinite

But latest patch broke it.

Actually we had two(!) very subtle bugs, the first is that Position::set()
clears the passed state and in particular 'previous' member, so
that on passing setupStates, 'previous' pointer was reset.

Second bug is even more subtle: SetupStates was based on std::vector
as container, but when vector grows, std::vector copies all its contents
to a new location invalidating all references to its entries. Because
all StateInfo records are linked by 'previous' pointer, this made pointers
go stale upon adding more element to setupStates. So revert to use a
std::deque that ensures references are preserved when pushing back new
elements.

No functional change.
2016-04-18 15:09:42 +02:00
loco-loco
464fec0493 Add a second level of follow-up moves
STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 6438 W: 1229 L: 1077 D: 4132

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 4000 W: 605 L: 473 D: 2922

bench: 7378965

Resolves #636
2016-04-18 15:09:39 +02:00
lucasart
a037e20f28 Syzygy pull (#639)
* factorize repetitive code in calc_key() and calc_key_from_pcs()

and do some cleanup while at it.

* sync with master

No functional change.
2016-04-18 14:08:23 +02:00
Marco Costalba
e8610fbe7c Merge pull request #637 from mcostalba/init
Rework init
2016-04-18 12:43:31 +02:00
lucasart
af0eb46fad fix marco's binomial patch 2016-04-18 12:39:55 +02:00
Marco Costalba
8c58963897 Avoid wild casting of TBEntry and stale pointers
And reset DTZ_table[i].entry pointers after free to avoid
creating stale ones. We really would need something better
than plain old C-style pointers, but for now live with that.

Obfuscation level here is quite high....

No functional change.
2016-04-18 11:08:51 +02:00
Marco Costalba
94e41274bb Fix incorrect draw detection
In this position we should have draw for repetition:

position fen rnbqkbnr/2pppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves g1f3 g8f6 f3g1
go infinite

But latest patch broke it.

Actually we had two(!) very subtle bugs, the first is that Position::set()
clears the passed state and in particular 'previous' member, so
that on passing setupStates, 'previous' pointer was reset.

Second bug is even more subtle: SetupStates was based on std::vector
as container, but when vector grows, std::vector copies all its contents
to a new location invalidating all references to its entries. Because
all StateInfo records are linked by 'previous' pointer, this made pointers
go stale upon adding more element to setupStates. So revert to use a
std::deque that ensures references are preserved when pushing back new
elements.

No functional change.
2016-04-18 00:13:16 +02:00
Marco Costalba
9e53c3296d Get rid of useless 'initialized' global
And address formatting spaces as asked by Lucas.

No functional change.
2016-04-17 19:47:22 +02:00
loco-loco
ec6aab0136 Add a second level of follow-up moves
STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 6438 W: 1229 L: 1077 D: 4132

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 4000 W: 605 L: 473 D: 2922

bench: 7378965

Resolves #636
2016-04-17 15:19:20 +01:00
Marco Costalba
230685d4ae Better document binomial coefficents calculation
This is just a first cut at that part of init code.

Verified new binomial coefficents are the same.

No functional change.
2016-04-17 15:29:43 +02:00
Marco Costalba
f0650d499f Rework init
And fix compile on MSVC due to conflicting
use of std::min

No functional change.
2016-04-17 10:56:28 +02:00
Marco Costalba
7eaea3848c StateInfo is usually allocated on the stack by search()
And passed in do_move(), this ensures maximum efficiency and
speed and at the same time unlimited move numbers.

The draw back is that to handle Position init we need to
reserve a StateInfo inside Position itself and use at
init time and when copying from another Position.

After lazy SMP we don't need anymore this gimmick and we can
get rid of this special case and always pass an external
StateInfo to Position object.

Also rewritten and simplified Position constructors.

Verified it does not regress with a 3 threads SMP test:
ELO: -0.00 +-12.7 (95%) LOS: 50.0%
Total: 1000 W: 173 L: 173 D: 654

No functional change.
2016-04-17 08:29:33 +02:00
lucasart
9173d29c41 syzygy clean-up + unit test 2016-04-16 22:59:39 +01:00
Niklas Fiekas
ee7a68ea5f Fix last search info carried over to mate position
When starting search in a mate or stalemate position, Stockfish does not
even care to reinitialize and start worker threads. However after search
all threads are checked for the best move.

This can lead to bestmove and info beeing carried over from the last
search.

Example session:

    setoption name threads value 7
    go movetime 4000
    position startpos moves f2f3 e7e5 g2g4 d8h4
    go movetime 4000

Actual output is like (almost always):

    [...]
    bestmove e2e4
    info depth 0 score mate 0
    info depth 20 seldepth 29 multipv 1 score cp 28 [...] pv e2e4
    bestmove e2e4

Expected output / output after fix:

    [...]
    bestmove e2e4 ponder e7e6
    info depth 0 score mate 0
    bestmove (none)

Resolves #623
2016-04-16 10:22:36 +01:00
Marco Costalba
d30994ecd5 Hide global visibility when not needed
Also move PieceValue definition in psqt.cpp,
where it is initialized.

Fix a warning in popcount16() with Intel compiler

No functional change.
2016-04-09 10:42:04 +02:00
Marco Costalba
bd04f9a0f1 Fix Travis Cl
Broken after "32-bit/64-bit Makefile fix" commit.

Ubuntu "Precise" 12.04.5 supports multilib only until
g++ 4.6 that is not enough to compile Stockfish.

So move to Ubuntu 14.04.4 LTS (Trusty Tahr)

No functional change.
2016-04-09 09:35:19 +02:00
DU-jdto
1cbba8d6fa Small passed pawn simplification
STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 21993 W: 4197 L: 4078 D: 13718

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 67213 W: 9135 L: 9077 D: 49001

Bench: 7482426

Resolves #622
2016-04-08 19:48:03 +01:00
Alain SAVARD
e9e5f72c74 Undefended King Ring
There was already a penalty for squares only defended by King (undefended)

This test records a penalty for completely undefended squares in the so called extended king-ring
(so if we exclude squares defended by a Kg8 for example, we only look at h6 g6 and f6)

We also exclude squares occupied by opponent pieces in this computation,
based on the following results

Was yellow at STC
LLR: -2.97 (-2.94,2.94) [0.00,5.00]
Total: 112499 W: 20649 L: 20293 D: 71557

and passed LTC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 36805 W: 5100 L: 4857 D: 26848

Bench: 8430233

Resolves: #619
2016-04-08 19:22:33 +01:00
Alain SAVARD
29b5842da8 Backward simplication
On top of the usual conditions
a) some opponent in front (but no lever)
b) some neighbours (in front) (but no neighbour behind or same rank)
c) < rank_5

to find out if a pawn is backward we look at the squares in front of this pawn to reach the same rank as the next neighbour.

In current master, a pawn is backward if any of those squares is controlled by an enemy pawn on an adjacent file

In this version, a pawn is ALSO backward if any of those squares is occupied by an enemy pawn.

STC:
http://tests.stockfishchess.org/tests/view/56fe7efd0ebc59301a3541f1
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 19051 W: 3557 L: 3433 D: 12061

LTC:
http://tests.stockfishchess.org/tests/view/56febc2d0ebc59301a354209
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40810 W: 5619 L: 5526 D: 29665

Bench: 7525245

Resolves #614
2016-04-08 19:12:55 +01:00