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

2087 commits

Author SHA1 Message Date
Marco Costalba
15683034a7 Speed up kpk initialization
The trick is to classify more position at first cycle,
so to reduce following work. Speed up is of about 50% !

Also some cleanup while there.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-15 12:11:35 +01:00
Marco Costalba
4c9d570e43 Use Carry-Rippler trick to speed up magics
Nice trick discovered on:

http://chessprogramming.wikispaces.com/Traversing+Subsets+of+a+Set

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-15 02:15:41 +01:00
Marco Costalba
fc519ca74a Retire init_piece_square_tables()
Merge in init_zobrist() and rename the latter.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-13 17:28:09 +01:00
Marco Costalba
a24c0a736c Increase LMR limit by one ply
Seems there is no regression so prefer to prune less.

After 8278 games
Mod vs Orig 1246 - 1265 - 5767 +0 ELO (+- 4.2)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-12 21:14:07 +01:00
Marco Costalba
b3a0b389d2 Better self-document init_zobrist()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-12 11:50:19 +01:00
Marco Costalba
47959c56fd Fix initialization of BSFTable[]
We should start from i = 0, it works by accident because
static storage BSFTable[] is init to zero by default.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-12 11:37:02 +01:00
Marco Costalba
aee75ae105 Don't update_gains() in qsearch
Is almost unuseful becuase captures are skipped.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-12 07:09:30 +01:00
Marco Costalba
4b8a7f2793 Fix score_captures() for the case of capture promotions
In case we have more than one promotion move, prefer
the one that captures the biggest piece.

Almost no functional change, anyhow I don't expect any
ELO change, it is just the correct thing to do.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-11 22:12:13 +01:00
Marco Costalba
89ec224cb9 Retire some unused functions
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-11 15:56:12 +01:00
Marco Costalba
b21a5e2f06 Micro-optimize castling handling in do_move()
And better self-document the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-11 15:31:39 +01:00
Marco Costalba
735cac5d53 Retire PieceLetters struct
Use a much simpler std::string instead.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-10 17:12:10 +01:00
Marco Costalba
bc4f3155ae Better document move_to_san()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-10 11:59:53 +01:00
Marco Costalba
a21a110188 Revert refinedValue in ProbCut
It seems much worst in number of nodes seacrhed to reach
the depth and anyhow does not give any advantage to the
Onno's oroginal one.

So revert by now and perhaps readd when we find something
clearly better.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-09 21:59:24 +01:00
Marco Costalba
b414fc0dfd Use double rotate for magic generation
Allow to choose among 4096 instances of pseudo-random
sequences instead of the previous 64 so the probability
to find a better sequence increases and actually we have
a much better 64 bit case and we can also use the 64 bit
version of pick_magic() also for 32 bits and althoug sub
optimal, because now we can have more choices results are
even slightly better also for 32 bit.

Use also a faster submask().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-09 18:47:58 +01:00
Marco Costalba
e0215f3222 Use refinedValue in ProbCut condition
After 12613 games at 20"+0.1 on QUAD
Mod vs Orig 1870 - 1863 - 8880 ELO +0 (+- 3.3)

So no performance change but it is a code semplification
and also is more easy to understand.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-08 18:03:26 +01:00
Marco Costalba
3dfff5bdae Small pick_magic() touches
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-08 17:59:47 +01:00
Marco Costalba
d632e77058 Find magics on the fly
Good result for 32 bit case where computation is very fast,
still not satisfying on 64 bit case where the magics seem
a bit harder to get.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-07 20:59:12 +01:00
Marco Costalba
6d665b7f78 Partially revert previous patches
Due to a -2% speed penalty. This patch takes the best
of the previous series without the regression due to
introduction of Magic struct.

Speedup against previous revision is of almost 3% !!!!

No functional change both in 32 and 64 bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-06 11:56:17 +01:00
Marco Costalba
b1b0c64046 Skip offset calculation in slider attacks
Another small simplification and micro optimization.

No functional change in both 32 and 64 bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-05 15:01:22 +01:00
Marco Costalba
670cee44f0 Get rid of Shift[] tables
We can calculate them counting the masks bits.

Also small tweak to sliding_attacks()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-05 14:13:41 +01:00
Marco Costalba
3092f0c646 Better name and document magic botboard stuff
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-05 12:28:36 +01:00
Marco Costalba
2f6142cb9b Try to keep memory access in the same cache line
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-05 12:27:53 +01:00
Marco Costalba
3b2bcee0a8 Skip draw by repetition check in qsearch
Cut in half the time spent in pos.draw() that accounts
for a whopping 1% of total time !

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-04 11:29:54 +01:00
Marco Costalba
91407f4f74 Move bitboards initializations under one function
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-04 11:05:12 +01:00
Marco Costalba
025d57855a Calculate Bit Scan tables at initialization
Instead of hard-coding them.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-04 09:59:18 +01:00
Marco Costalba
8647fbd6ed Do not sort negative non captures at low depth
Speedup of the whole 3 patch series is of 2,5% !!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-04 06:35:24 +01:00
Marco Costalba
811037c845 Split non capture in two sets when ordering
But keep same ordering. This patch is prerequisite
for future work.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-03 22:10:23 +01:00
Marco Costalba
181cc3f93f Inline extension()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-03 13:14:03 +01:00
Marco Costalba
91b919fd1d Use TT also in Root nodes
And other small stuff ti be tested in SMP

No functional change in single thread.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-03 12:59:50 +01:00
Marco Costalba
5ff6289afd Microoptimize generate<MV_EVASION>
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-06-02 12:49:40 +01:00
Marco Costalba
fca0a2dd88 New extended probcut implementation
Here the idea is to test probcut not only after bad
captures, but after any bad move, i.e. any move that
leaves the opponent with a good capture.

Ported by a patch from Onno, the difference from
original version is that we have moved probcut after
null search.

After 7917 games 4 threads 20"+0.1
Mod vs Orig: 1261 - 1095 - 5561 ELO +7 (+- 4.2) LOS 96%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-30 20:49:04 +01:00
Marco Costalba
462a39ec49 Fix SAN disambiguation bug
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-29 10:52:03 +01:00
Marco Costalba
70125a3be0 Rename PH_TT_MOVES in PH_TT_MOVE
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-29 09:17:03 +01:00
Marco Costalba
cff8877a1a Retire mateKiller
Practically useless:
After 6456 games 1281 - 1293 - 3882 ELO +0 (+- 5.5)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-28 22:50:22 +01:00
Marco Costalba
8f51f09de7 Unify MovePickerExt template parameters
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-28 13:23:32 +01:00
Marco Costalba
013dc43d5d Unify search() template parameters
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-28 12:44:39 +01:00
Marco Costalba
853e2a9495 Fix moveCount after legality check delay
We really want PV moves and also Split Point moves to be
legal to avoid messing the move counter and corresonding
PV move detection or shared Split Point's counter variable.

This fixes a real bug where a position with only one move
allowed returns bestValue == -VALUE_INFINITE if the move
turns out to be illegal.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-28 11:16:00 +01:00
Marco Costalba
4c3a000211 A bit of reformatting after previous series
And some documentation update.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-24 21:24:40 +01:00
Marco Costalba
9884573561 Test for legality only after futility pruning
Although there is a small functional change it seems
an improvment of about 2% in speed !

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-23 20:21:02 +01:00
Marco Costalba
4b232f5ddc Move legal check out of MovePicker
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-23 20:20:52 +01:00
Marco Costalba
45ce92b89c Rename move_is_legal() in move_is_pl()
We disjoint pseudo legal detection from full legal detection.

It will be used by future patches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-23 20:20:42 +01:00
Marco Costalba
bc86668ba4 Output debug info to cerr
So to be clearly visible when redirecting stdout to /dev/null

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-23 20:20:31 +01:00
Marco Costalba
0783211950 Fix a shadowed variable warning under gcc
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-23 20:20:19 +01:00
Marco Costalba
13fe7ee4df Bug wrong evasion detection for king moves
When we are in check and we move the king then testing with
pl_move_is_legal(m, pinned) is not enough becuase we cannot
rely on attackers_to() but we have to explicitly remove the
king form the occupied bitboard to catch as invalid moves like
b1a1 when opposite queen is on c1.

Our move generator already produces correct evasions so we
just need to add the extra verification to move_is_legal().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-22 11:51:28 +01:00
Marco Costalba
21fc66c246 Add file distance condition in move_is_legal()
Found another missed control in move_is_legal() thanks to
brute force testing.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-22 09:49:44 +01:00
Marco Costalba
ff9e49bac9 Remove useless casts in types.h
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-22 08:52:39 +01:00
Marco Costalba
90e83fa879 Promotion piece must be empty if is not a promotion
Add a new check in  move_is_legal()

Avoid useless casting in move.h while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-22 08:48:19 +01:00
Marco Costalba
3ef4fdeaa0 Introduce MovePicker::isBadCapture() and use in probcut
Small functional change due to the fact that now we skip
probcut on evasions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-21 10:40:36 +01:00
Marco Costalba
13d8af1852 Correctly handle castle in see()
Suggested by Onno.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-20 06:58:53 +01:00
Marco Costalba
5b7a141065 Fix brekage from previous patches
It is interesting the fact that we need to test for
move_is_castle(m) anyway and not relying on testing
if destination square is attacked. Indeed the latter
condition fails if the castling rook is attacked,
castling is coded as "king captures the rook" but it
is legal in that case.

Verified no functional change with beginning of the series.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-18 07:05:36 +01:00