]> git.sesse.net Git - stockfish/log
stockfish
14 years agoSet IncrementalFutilityMargin to 8
Marco Costalba [Tue, 8 Dec 2009 10:16:14 +0000 (11:16 +0100)]
Set IncrementalFutilityMargin to 8

After 999 games we are almost equal (+2 ELO),
but we have a good result against Rybka

Rybka 2.3.2a mp 32-bit vs Mod  254.5 - 242.5 +152/-140/=205 51.21%
Rybka 2.3.2a mp 32-bit vs Orig 259.5 - 236.5 +151/-128/=217 52.32%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoReplace 100 with PLY_MAX in ok_to_use_TT
Joona Kiiski [Wed, 2 Dec 2009 20:08:58 +0000 (22:08 +0200)]
Replace 100 with PLY_MAX in ok_to_use_TT

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdjust SingleReplyMargin 0x64 -> 0x20
Joona Kiiski [Wed, 2 Dec 2009 18:34:55 +0000 (20:34 +0200)]
Adjust SingleReplyMargin 0x64 -> 0x20

Mod - Orig: 920 - 890 (+6 elo)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDon't clear hash at the beginning of a new game
Marco Costalba [Tue, 1 Dec 2009 10:56:48 +0000 (11:56 +0100)]
Don't clear hash at the beginning of a new game

After 900 games at 1+0
Mod vs Orig +217 =480 -196 +8 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoTry to prune also when approximateEval < beta
Marco Costalba [Tue, 1 Dec 2009 10:48:28 +0000 (11:48 +0100)]
Try to prune also when approximateEval < beta

Now we always try to filter out moves, we will have
more wasted evaluation calls, but also more pruned
nodes.

After 786 games

Mod vs Orig +196 =413 -177 +8 ELO

Verified also against Rybka it increases score to 50-51%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not crash if we are asked to search mate or stalemate position.
Joona Kiiski [Sat, 28 Nov 2009 18:49:36 +0000 (20:49 +0200)]
Do not crash if we are asked to search mate or stalemate position.

We might be asked to ponder mate or stalemate position.
This being the case, simply wait for stop or ponderhit.
Currently we crash.

UCI specs aren't clear on the issue, but it cost nothing to
add little check.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix get_option_value() for strings with spaces
Marco Costalba [Sat, 28 Nov 2009 16:31:56 +0000 (17:31 +0100)]
Fix get_option_value() for strings with spaces

Problem is that

istream& operator>> (istream& is, char* str );

according to C++ documentation "Ends extraction when the
next character is either a valid whitespace or a null character,
or if the End-Of-File is reached."

So if the parameter value is a string with spaces the currently
used instruction 'ss >> ret;' copies the chars only up to the first
white space and not the whole string.

Use a specialization of get_option_value() to fix this corner case.

Bug reported by xiaozhi

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire FutilityMargins[] array
Marco Costalba [Sat, 28 Nov 2009 10:52:13 +0000 (11:52 +0100)]
Retire FutilityMargins[] array

Now we use a formula to calculate margins on the fly.

Node count has changed because we fixed a leftover when
we still where using FutilityMargins to calculate futilityValue
in the case that we had the evaluation score in TT.

Also small indentation fix.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIncrementalFutilityMargin to 4 and increased pruning
Marco Costalba [Thu, 26 Nov 2009 10:37:21 +0000 (11:37 +0100)]
IncrementalFutilityMargin to 4 and increased pruning

Increase pruning at low depths while tone downa bit at
higher depths (linearize a bit the logaritmic behaviour)

This goes togheter with IncrementalFutilityMargin decreased
to 4 compensate the bigger pruning effect.

Total pruned nodes are more or less the same. We go from 36%
of nodes after prune to 37% with this patch.

After 999 games at 1+0
Mod vs Orig +250 =526 -223 +9 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDrop OnlyMoveExt PV-condition from 8 plies to 6 plies
Joona Kiiski [Fri, 27 Nov 2009 10:06:55 +0000 (12:06 +0200)]
Drop OnlyMoveExt PV-condition from 8 plies to 6 plies

Orig - Mod: 731 - 750

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse move not ttMove in exclude search
Marco Costalba [Fri, 27 Nov 2009 14:35:34 +0000 (15:35 +0100)]
Use move not ttMove in exclude search

If we arrive until the exclusion search call then
we know that move == ttMove == tte->move()

But using ttMove in search call while, during excluded search
conditions we have used tte->Move()could be a little bit suboptimal.
On the other side using tte->move() also in search call is a bit ugly
so opt for the third choice that is the most clean becasue from the
conditions the reader easily understands that we are talking of ttMove
and that we ant to exclude the move we are evaluating in that moment.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter document previous patch
Marco Costalba [Fri, 27 Nov 2009 10:54:07 +0000 (11:54 +0100)]
Better document previous patch

If tte->move() != MOVE_NONE then tte->move() == ttMove

What could happen is that we have a ttMove without a tte, or,
we have a tte but tte->move() == MOVE_NONE

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a possible crash in excluded search condition
Marco Costalba [Thu, 26 Nov 2009 12:44:48 +0000 (13:44 +0100)]
Fix a possible crash in excluded search condition

Due to IID we could have a ttMove and not a tte, or,
even if we have a tte they could belong to different
searches so that the depth and type of tte don't
have the same origin of the ttMove.

To fix this we always use tte entry in excluded search
condition and, after an IID, we reprobe the TT table.

No functional change. Apart from possible crash fix.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDocument why we don't use TT to prune in search_pv()
Marco Costalba [Wed, 25 Nov 2009 16:16:51 +0000 (17:16 +0100)]
Document why we don't use TT to prune in search_pv()

From a Joona' s post on talkchess.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert last Only move extensions tweaks
Joona Kiiski [Wed, 25 Nov 2009 13:15:47 +0000 (15:15 +0200)]
Revert last Only move extensions tweaks

They gave bad results:

Mod - Orig: 361 - 404

Master is now verified to be functional equivalent with F_63

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSpeed up sorting of non-captures
Marco Costalba [Tue, 24 Nov 2009 12:39:47 +0000 (13:39 +0100)]
Speed up sorting of non-captures

Becasue we have a lot of zero scores (around 30% of moves)
it is a good idea to do a couple a presorting loops across
the move list and shuffle the moves a bit so that with a
small effort we end up with 3 groups of moves: positives
scores, zero scores and negative scores.

We have two advantages

1) We don't need to sort zero scores

2) Sort two small groups is faster then sort a single big one

Speed up is of about 2%

Because equal scored moves could be reordered in a different way
this is not a "no functional change" although I have verified
the output list is always correctly sorted.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRewrite messy LSN-code take 2
Marco Costalba [Wed, 25 Nov 2009 12:53:48 +0000 (13:53 +0100)]
Rewrite messy LSN-code take 2

We already reset loseOnTime flag at the beginning of
a new game, so we can simplify a bit the ligic there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRewrite messy LSN-code
Joona Kiiski [Tue, 24 Nov 2009 22:14:12 +0000 (00:14 +0200)]
Rewrite messy LSN-code

* New version is documented and logic should be easier to follow
* Add extra check to not use LSN with x moves / y seconds time control
* New code fixes some rear cases where old code (still) causes program to lose on time at move 1.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove RootMoveList::scan_for_easy_move()
Joona Kiiski [Tue, 24 Nov 2009 21:49:17 +0000 (23:49 +0200)]
Remove RootMoveList::scan_for_easy_move()

* The function is called only in one place
* It must not be called elsewhere
* The function call easily replaced with simple one line condition

No functional change (tested with usual set + 2000 random positions)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove 2 FIXMEs from search.cpp
Joona Kiiski [Tue, 24 Nov 2009 22:43:19 +0000 (00:43 +0200)]
Remove 2 FIXMEs from search.cpp

* First one is without any documentation, code is working just fine,
  so there seems to be nothing that really should be fixed.

* Second one requesting emergency measures on aspiration fail low
  when we are running out of time and we are without good move.
  After very long time, I've come to conclusion that this is
  impossible to fix, so remove request.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDocument and cleanup new effective-single-reply code
Marco Costalba [Mon, 23 Nov 2009 11:40:18 +0000 (12:40 +0100)]
Document and cleanup new effective-single-reply code

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAlways extend full ply in PV
Joona Kiiski [Sun, 22 Nov 2009 14:50:44 +0000 (16:50 +0200)]
Always extend full ply in PV

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd mild extension in low depths
Joona Kiiski [Sun, 22 Nov 2009 12:58:07 +0000 (14:58 +0200)]
Add mild extension in low depths

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix currentMove bug
Joona Kiiski [Sat, 21 Nov 2009 15:05:18 +0000 (17:05 +0200)]
Fix currentMove bug

Orig vs Master: +15 elo 887.5 - 812.5 (1700 games, finished) [4CPU]

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOnly move extension based on exclusion search
Joona Kiiski [Sat, 21 Nov 2009 13:22:52 +0000 (15:22 +0200)]
Only move extension based on exclusion search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBase work for exclusion search
Joona Kiiski [Sat, 21 Nov 2009 12:44:50 +0000 (14:44 +0200)]
Base work for exclusion search

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoTone down a bit futility parameters
Marco Costalba [Sun, 22 Nov 2009 10:11:36 +0000 (11:11 +0100)]
Tone down a bit futility parameters

After 999 games at 1+0

Mod vs Orig +239 =542 -218  +7 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove 4*IncrementalFutilityMargin from futilityValue
Marco Costalba [Sat, 21 Nov 2009 13:41:07 +0000 (14:41 +0100)]
Remove 4*IncrementalFutilityMargin from futilityValue

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoLogaritmic futility margins
Marco Costalba [Thu, 19 Nov 2009 14:58:22 +0000 (15:58 +0100)]
Logaritmic futility margins

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoExponential futility margins
Marco Costalba [Wed, 18 Nov 2009 13:54:59 +0000 (14:54 +0100)]
Exponential futility margins

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoHistory pruning exponential limit
Marco Costalba [Sat, 14 Nov 2009 16:38:22 +0000 (17:38 +0100)]
History pruning exponential limit

Use an exponenital law instead of a linear one for
history pruning.

This should prune more at low depths and a bit less
at high depths.

After 965 games

Mod vs Orig +233 =504 -228 +2 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIncremental Futility Margin
Marco Costalba [Sat, 14 Nov 2009 20:36:43 +0000 (21:36 +0100)]
Incremental Futility Margin

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIn razor qsearch use corrected beta
Marco Costalba [Wed, 18 Nov 2009 08:30:02 +0000 (09:30 +0100)]
In razor qsearch use corrected beta

Correct beta by razor margin when callin qsearch

After 1019 games on Joona's QUAD

Mod - Orig: 524 - 495 (+10 elo)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoCode style triviality
Marco Costalba [Sat, 21 Nov 2009 13:39:29 +0000 (14:39 +0100)]
Code style triviality

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMicro-optimize get_material_info()
Marco Costalba [Sun, 15 Nov 2009 08:35:22 +0000 (09:35 +0100)]
Micro-optimize get_material_info()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert pawns evaluation to Score
Marco Costalba [Fri, 13 Nov 2009 16:23:21 +0000 (17:23 +0100)]
Convert pawns evaluation to Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMove game phase computation to MaterialInfo
Marco Costalba [Fri, 13 Nov 2009 12:29:04 +0000 (13:29 +0100)]
Move game phase computation to MaterialInfo

Game phase is a strictly function of the material
combination so its natural place is MaterialInfo,
not position.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoNull move dynamic reduction based on value
Marco Costalba [Fri, 13 Nov 2009 10:25:34 +0000 (11:25 +0100)]
Null move dynamic reduction based on value

After 994 games at 1+0

Mod vs Orig +244 =521 -229 50.75%  504.5/994 +5 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse a more standard perft UCI interface
Marco Costalba [Fri, 13 Nov 2009 09:27:14 +0000 (10:27 +0100)]
Use a more standard perft UCI interface

Call directly 'perft 6' to search up to depth 6*OnePly
instead of the old 'perft depth 6'.

It is more in line to what other engines do. Also a bit
of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter document king safety evaluation
Marco Costalba [Thu, 12 Nov 2009 18:01:44 +0000 (19:01 +0100)]
Better document king safety evaluation

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRearrange table layout in evaluate.cpp
Marco Costalba [Thu, 12 Nov 2009 16:42:43 +0000 (17:42 +0100)]
Rearrange table layout in evaluate.cpp

A bit more cache friendly.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove dcCandidates data member from SplitPoint
Marco Costalba [Thu, 12 Nov 2009 15:55:31 +0000 (16:55 +0100)]
Remove dcCandidates data member from SplitPoint

It is no more used now that we have CheckInfo.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove update_checkers()
Marco Costalba [Wed, 11 Nov 2009 09:41:46 +0000 (10:41 +0100)]
Remove update_checkers()

Now that we have CheckInfo we don't need it anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire evaluate_mobility()
Marco Costalba [Wed, 11 Nov 2009 20:17:38 +0000 (21:17 +0100)]
Retire evaluate_mobility()

Move the code to the caller and also move mob_area
computation out of evaluate_pieces(). It is more clear
the code flow and it is also faster.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall sort_moves() deobfuscation
Marco Costalba [Wed, 11 Nov 2009 19:32:58 +0000 (20:32 +0100)]
Small sort_moves() deobfuscation

Write the for loop in a more idiomatic way, no assembly
change and of course no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDon't futility-prune ttMove
Marco Costalba [Tue, 10 Nov 2009 17:15:22 +0000 (18:15 +0100)]
Don't futility-prune ttMove

After 933 games
Mod vs Orig +219 =505 -208 +4 ELO

A small increase as expected.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoPropagate "move is check" info to do_move()
Marco Costalba [Tue, 10 Nov 2009 10:05:20 +0000 (11:05 +0100)]
Propagate "move is check" info to do_move()

When false (common case) we avoid to update checkers
bitboard that although not so costly slows down a bit
this very hot and critical path.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall update_checkers() cleanup
Marco Costalba [Tue, 10 Nov 2009 09:05:09 +0000 (10:05 +0100)]
Small update_checkers() cleanup

And is a bit faster too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall update to pop_1st_bit()
Marco Costalba [Tue, 10 Nov 2009 07:55:52 +0000 (08:55 +0100)]
Small update to pop_1st_bit()

Avoid a 64 bit load using a pointer. It saves a couple of push/pop
instructions so advantage is only theorical, but anyway we use
pop_1st_bit() as a reference implementation for 32 bit systems so
we keep it more for documentation purposes then for other reasons.

Idea of pointer is of Eric Mullins.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall CheckInfo fallout
Marco Costalba [Mon, 9 Nov 2009 20:48:02 +0000 (21:48 +0100)]
Small CheckInfo fallout

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFully convert move_is_check() internally
Marco Costalba [Mon, 9 Nov 2009 20:29:22 +0000 (21:29 +0100)]
Fully convert move_is_check() internally

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert move_is_check() to take a CheckInfo reference
Marco Costalba [Mon, 9 Nov 2009 20:02:07 +0000 (21:02 +0100)]
Convert move_is_check() to take a CheckInfo reference

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse CheckInfo to compute dcCandidates
Marco Costalba [Mon, 9 Nov 2009 19:54:45 +0000 (20:54 +0100)]
Use CheckInfo to compute dcCandidates

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce CheckInfo struct
Marco Costalba [Mon, 9 Nov 2009 19:49:01 +0000 (20:49 +0100)]
Introduce CheckInfo struct

Keeps info used to speed-up move_is_check()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix operator/(Score s, int i)
Marco Costalba [Mon, 9 Nov 2009 08:00:24 +0000 (09:00 +0100)]
Fix operator/(Score s, int i)

And remove some useless declarations

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDon't copy the key in do_move
Marco Costalba [Sun, 8 Nov 2009 16:56:41 +0000 (17:56 +0100)]
Don't copy the key in do_move

It will be overwritten anyway.

Also other little small touches that seem to increase
speed more then the whole enum Score patch series :-(

Optimization is really a black art.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDefine Score as an enum
Marco Costalba [Sat, 7 Nov 2009 21:21:50 +0000 (22:21 +0100)]
Define Score as an enum

Increases performance because now we use one integer
for both midgame and endgame scores.

Unfortunatly the latest patches seem to have reduced a bit
the speed so at the end we are more or less at the same
performance level of the beginning. But this patch series
introduced also some code cleanup so it is the main reason
we commit anyway.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoChange Score definition to avoid the union
Marco Costalba [Sat, 7 Nov 2009 18:18:44 +0000 (19:18 +0100)]
Change Score definition to avoid the union

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert "Do not extend at low depths if not in PV"
Marco Costalba [Sat, 7 Nov 2009 18:47:02 +0000 (19:47 +0100)]
Revert "Do not extend at low depths if not in PV"

On Joona's QUAD:
Orig - Mod: 414 - 373

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert "IID in pv also when TT move depth is too small"
Marco Costalba [Sat, 7 Nov 2009 18:45:13 +0000 (19:45 +0100)]
Revert "IID in pv also when TT move depth is too small"

After almost 900 games we are at -2 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoLast conversions to Score in evaluate.cpp
Marco Costalba [Sat, 7 Nov 2009 14:56:56 +0000 (15:56 +0100)]
Last conversions to Score in evaluate.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert ThreatBonus to Score
Marco Costalba [Sat, 7 Nov 2009 14:43:45 +0000 (15:43 +0100)]
Convert ThreatBonus to Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert RookOn7thBonus and QueenOn7thBonus to be Score
Marco Costalba [Sat, 7 Nov 2009 14:35:11 +0000 (15:35 +0100)]
Convert RookOn7thBonus and QueenOn7thBonus to be Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert mobility bonus tables to Score
Marco Costalba [Sat, 7 Nov 2009 14:02:10 +0000 (15:02 +0100)]
Convert mobility bonus tables to Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert apply_weight() to handle Score
Marco Costalba [Sat, 7 Nov 2009 13:32:26 +0000 (14:32 +0100)]
Convert apply_weight() to handle Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert MaterialInfo and PawnInfo to use Score
Marco Costalba [Sat, 7 Nov 2009 13:05:55 +0000 (14:05 +0100)]
Convert MaterialInfo and PawnInfo to use Score

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce PieceSquareTable[16][64]
Marco Costalba [Sat, 7 Nov 2009 12:12:58 +0000 (13:12 +0100)]
Introduce PieceSquareTable[16][64]

Instead of MgPieceSquareTable[16][64] and EgPieceSquareTable[16][64]

This allows to fetch mg and eg values from adjacent words in memory.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoConvert Position to use Score struct
Marco Costalba [Sat, 7 Nov 2009 11:40:48 +0000 (12:40 +0100)]
Convert Position to use Score struct

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce Score struct
Marco Costalba [Sat, 7 Nov 2009 10:15:55 +0000 (11:15 +0100)]
Introduce Score struct

Save mid and end game scores in an union so to
operate on both values in one instruction.

This patch just introduces the infrastructure and changes
EvalInfo to use a single Score value instead of mgValue
and egValue.

Speed is more or less the same because we still don't use
unified midgame-endgame tables where the single assignment
optimization can prove effective.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix correct name of int64_t type
Marco Costalba [Sat, 7 Nov 2009 09:08:28 +0000 (10:08 +0100)]
Fix correct name of int64_t type

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not extend at low depths if not in PV
Marco Costalba [Fri, 6 Nov 2009 15:42:02 +0000 (16:42 +0100)]
Do not extend at low depths if not in PV

Only check extensions are allowed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIID in pv also when TT move depth is too small
Marco Costalba [Fri, 6 Nov 2009 15:08:39 +0000 (16:08 +0100)]
IID in pv also when TT move depth is too small

Try an internal iterative deepening not only when we don't
have a TT move but also if search depth is more then 4*OnePly
higher then TT move depth.

On some tests it seems that in around 20% of cases ttMove changes !

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter big-endian support wording in Makefile
Marco Costalba [Fri, 6 Nov 2009 16:33:14 +0000 (17:33 +0100)]
Better big-endian support wording in Makefile

Suggested by Joona.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoEnable POPCNT only through Makefile
Marco Costalba [Fri, 6 Nov 2009 16:23:02 +0000 (17:23 +0100)]
Enable POPCNT only through Makefile

Also remove some fallback templates that prevent a
compile error in case the user runs 'make icc-profile-popcnt'
from a non supported machine.

We want to loudly fail in that case instead of silently
fallback in a non-popcount compilation.

Updated documentation too.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd popcnt-support in Makefile
Joona Kiiski [Fri, 6 Nov 2009 07:59:42 +0000 (09:59 +0200)]
Add popcnt-support in Makefile

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall code-style touches in movegen.cpp
Marco Costalba [Fri, 6 Nov 2009 13:33:34 +0000 (14:33 +0100)]
Small code-style touches in movegen.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a small warning under icc
Marco Costalba [Fri, 6 Nov 2009 09:39:33 +0000 (10:39 +0100)]
Fix a small warning under icc

Variable 'f' in 'for' loop scope hides same named
one in outer scope.

Of curse no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBig-endian compatible pop_1st_bit()
Marco Costalba [Thu, 5 Nov 2009 18:29:26 +0000 (19:29 +0100)]
Big-endian compatible pop_1st_bit()

Thanks to Eric Mullins we have now endian friendly
pop_1st_bit() and also is removed the need to use
-fno-strict-aliasing compiler option with GCC.

Speed is almost as fast, very small difference if any in
perft test, so I assume almost no difference in real games.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a compile error in debug mode
Marco Costalba [Fri, 6 Nov 2009 07:24:06 +0000 (08:24 +0100)]
Fix a compile error in debug mode

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoEnable PH_TT_MOVES during evasion generation
Marco Costalba [Thu, 5 Nov 2009 13:40:51 +0000 (14:40 +0100)]
Enable PH_TT_MOVES during evasion generation

This allow us to avoid the generation of the
evasion moves if we already have a TT move, and
in case we have a cut-off we skip evasion generation
altoghter.

Node count is changed because now we try TT move _before_
to generate evasions. The search on the TT move alters the
piece lists so that when we come back to generate evasions
we build the move list with a diferent order and this alters
the node count.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoExtend move_is_legal() to work also when in check
Marco Costalba [Thu, 5 Nov 2009 11:52:40 +0000 (12:52 +0100)]
Extend move_is_legal() to work also when in check

This patch is a prerequisite to use TT phase
during evasions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMove locals definitions at the function start
Marco Costalba [Thu, 5 Nov 2009 10:11:02 +0000 (11:11 +0100)]
Move locals definitions at the function start

It seems to me function are easier to read now.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire MovePicker::discovered_check_candidates()
Marco Costalba [Wed, 4 Nov 2009 13:46:16 +0000 (14:46 +0100)]
Retire MovePicker::discovered_check_candidates()

It is now no more needed to know dc candidates
inside MovePicker, so avoid calculating there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRewrite generate_pawn_moves() and simplify evasions
Marco Costalba [Tue, 3 Nov 2009 11:29:07 +0000 (12:29 +0100)]
Rewrite generate_pawn_moves() and simplify evasions

Big cleanup and semplification of pawns evasions that
now are pseudo-legal as the remaining moves. This
allow us to remove a lot of tricky code.

Verified against perft: no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoGenerate pseudo-legal moves in generate_evasions()
Marco Costalba [Mon, 2 Nov 2009 17:27:26 +0000 (18:27 +0100)]
Generate pseudo-legal moves in generate_evasions()

This allow a big semplification in move generation
that will be committed with the next patch. And makes
handling of evasions similar to the other type of moves.

This patch plus the next seem to improve also on
the performance side because after 640 games to
verify there are no hidden regressions we are at +9 ELO

Verified with perft no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOptimize generate_evasions()
Marco Costalba [Mon, 2 Nov 2009 15:33:54 +0000 (16:33 +0100)]
Optimize generate_evasions()

Generate captures of checking piece and blocking
evasions in one go.

Also reduce of one indentation level early returning
when we have a double check.

Verified with perft no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSpeed up perft
Marco Costalba [Wed, 4 Nov 2009 10:11:04 +0000 (11:11 +0100)]
Speed up perft

There is no need to do / undo the move at the last ply

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove SEE optimizations
Marco Costalba [Sun, 1 Nov 2009 21:09:53 +0000 (22:09 +0100)]
Remove SEE optimizations

Don't seem to help, perhaps because we
return an approximate SEE score instead of the
real negative score so that we have some bad capture
or evasion sub-optimal ordering that compensates
the speed up.

Anyhow after 999 games at 1+0
Mod vs Orig +240 =514 -245 -2 ELO

So almost no harm to remove and make the code simpler.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoReorder evasions
Marco Costalba [Sat, 31 Oct 2009 09:51:04 +0000 (10:51 +0100)]
Reorder evasions

Always try ttMove as first. Then try good captures ordered
by MVV/LVA, then non-captures if destination square is not
under attack, ordered by history value, and at the end
bad-captures and non-captures with a negative SEE. This
last group is ordered by the SEE score.

After 999 games at 1+0
Mod vs Orig +254 =546 -199 +19 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAnother see() shortcut
Marco Costalba [Sat, 31 Oct 2009 10:16:40 +0000 (11:16 +0100)]
Another see() shortcut

Because we only generate legal moves we can assume
a king cannot be recaptured, so we can safely return
immediately with the captured piece score. If the move
turns out to be illegal it will be pruned anyhow,
independently from SEE value. This gives a good speed up
especially now that we SEE-test all the evasions that
are always legal and very often are king moves.

Another optimization catches almost 15% of cases, unfortunatly
we have already calculated the very expensive attacks, so
benefits are not so big anyway.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoShortcut see_sign() when SEE is known negative
Marco Costalba [Fri, 30 Oct 2009 12:34:45 +0000 (13:34 +0100)]
Shortcut see_sign() when SEE is known negative

This patch cuts 30% of SEE calculations, as a drawback
a returned negative value is no more always correct if
a shortcut is found.

This could impact move order when based on negative see
score as example bad captures and evasions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove castling moves in check generation
Marco Costalba [Sun, 1 Nov 2009 16:19:04 +0000 (17:19 +0100)]
Remove castling moves in check generation

Check generation is used only in qsearch and
only at Depth(0), castling moves that give check
are very rare overall and even almost not exsistent
at Depth(0).

So retire this almost never used code that adds
a small but consistent slow down in the normal path.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOptimize check generation
Marco Costalba [Sun, 1 Nov 2009 09:40:14 +0000 (10:40 +0100)]
Optimize check generation

Because discovery checks are very rare it is better to handle
them all in one go and strip from usual check generation
function.

Also rewrite direct checks generation to use piece lists instead
of pop_1st_bit()

On perft test we have a +6% of speed up and is verified we
generate the same moves, although in a different order.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoImplemented perft
Joona Kiiski [Fri, 2 Oct 2009 04:09:24 +0000 (07:09 +0300)]
Implemented perft

Patch from Joona with extension to benchmark and inclusion
of Depth(0) moves generation by me.

Note that to test also qsearch and in particulary checks
generations a change in the end condition is needed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoEvaluation threat values after 39089 games
Marco Costalba [Tue, 27 Oct 2009 19:48:19 +0000 (20:48 +0100)]
Evaluation threat values after 39089 games

Verified against tuning branch.

After 100 games at 1+0 on Joona QUAD

Mod - Orig: 527.5 - 471.5 (+20 elo)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix build under gcc
Marco Costalba [Sun, 25 Oct 2009 09:22:03 +0000 (10:22 +0100)]
Fix build under gcc

Also some warnings squashed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd threat evaluation
Marco Costalba [Sun, 25 Oct 2009 07:16:34 +0000 (08:16 +0100)]
Add threat evaluation

Give a bonus for each kind of attacked piece. Bonus
value is based on the type of attacked piece and the
type of attacking one.

Penalize pieces attacked by enemy pawns, also in
this case penality value depends on the type of
attacked piece.

This patch oboletes as redundant the increased mobility
count of the attcked squares that is then removed.

After 956 games at 1+0
Mod vs Orig  +262 =462 -232 51.57%  493.0/956 +11 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMicro optimize mobility calculation
Marco Costalba [Fri, 23 Oct 2009 10:24:53 +0000 (11:24 +0100)]
Micro optimize mobility calculation

Take out of mobility loop a constant expression.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUnify capture and promotion tests
Marco Costalba [Wed, 21 Oct 2009 10:41:24 +0000 (11:41 +0100)]
Unify capture and promotion tests

Small code cleanup and a bit faster too.

The only functional change is that in extension
in pv node we extend promotions and not only captures
when condition met.

This is practically an undetectable change and has
no impact on strenght.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDon't prune TT move in qsearch even if SEE < 0
Marco Costalba [Tue, 20 Oct 2009 15:14:57 +0000 (16:14 +0100)]
Don't prune TT move in qsearch even if SEE < 0

Even if SEE is negative there is always a good possibility
that TT move is a cut move anyway. For instance a lot of
BXN exchanges that have negative SEE can very easily be
good exchanges.

A nice side effect is a bit reduced frequency of
see_sign() calls.

After 643 games at 1+0
Mod vs Orig +174 =327 -142 52.49%  337.5/643 +17 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>