]> git.sesse.net Git - stockfish/log
stockfish
14 years agoRemove an useless comparison in futility pruning
Marco Costalba [Mon, 27 Apr 2009 08:45:15 +0000 (09:45 +0100)]
Remove an useless comparison in futility pruning

Currently futility is allowed when depth < SelectiveDepth
and SelectiveDepth is 7*OnePly, so the comprison is
always true.

Patch could introduce a functional change only if
we choose to increase SelectiveDepth.

Currently no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not hardcode default values of UCI variables
Marco Costalba [Sat, 25 Apr 2009 14:26:06 +0000 (15:26 +0100)]
Do not hardcode default values of UCI variables

If a variable will be populated reading an UCI option
then do not hard code its default values.

This avoids misleadings when reading the sources.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoGreatly speedup has_mate_threat()
Marco Costalba [Mon, 20 Apr 2009 07:10:27 +0000 (09:10 +0200)]
Greatly speedup has_mate_threat()

Instead of loop across all legal moves to find a mate
loop across possible check moves only.

This reduces more then 10 times the number of moves to
check for a possible mate.

Also rename generate_checks() in generate_non_capture_checks()
so to better clarify what the function does.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize generate_piece_checks() take 2
Marco Costalba [Sun, 19 Apr 2009 19:09:53 +0000 (21:09 +0200)]
Micro optimize generate_piece_checks() take 2

Add some missing bits of this patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoAdd missing header file to make stockfish compile with latest Inter C++ Compiler...
Joona Kiiski [Sun, 19 Apr 2009 16:46:07 +0000 (19:46 +0300)]
Add missing header file to make stockfish compile with latest Inter C++ Compiler under Linux (memcpy needs cstring)

Correct some references glaurung -> stockfish in Makefile

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSimplify Position::is_mate()
Marco Costalba [Sun, 19 Apr 2009 15:44:12 +0000 (16:44 +0100)]
Simplify Position::is_mate()

Should be a bit faster too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize generate_piece_checks()
Marco Costalba [Sat, 18 Apr 2009 15:21:44 +0000 (16:21 +0100)]
Micro optimize generate_piece_checks()

Avoid calculating piece attacks if there aren't
available check sqaures for the given piece.

About 15% of cases. Not a biggie but still something
especially in the middle game where king is well covered
inside his castle.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMovePicker: retire per square MVV/LVA ordering
Marco Costalba [Sat, 18 Apr 2009 13:19:19 +0000 (14:19 +0100)]
MovePicker: retire per square MVV/LVA ordering

Is not used anyway and in case we need it again we
can resurrect from git archives.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoIn qsearch store the cut move in TT
Marco Costalba [Sat, 18 Apr 2009 13:03:33 +0000 (14:03 +0100)]
In qsearch store the cut move in TT

And upon reentering the same position try it as first.

Normally qsearch moves order is already very good, first move
is the cut off in almost 90% of cases. With this patch, we get
a cut off on TT move of 98%.

Another good side effect is that we don't generate captures
and/or checks when we already have a TT move.

Unfortunatly we found a TT move only in 1% of cases. So real
impact of this patch is relatively low.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMerge Joona's new aspiration window search
Marco Costalba [Thu, 16 Apr 2009 06:35:26 +0000 (08:35 +0200)]
Merge Joona's new aspiration window search
It seems very positive.

After 999 games at 1'+0" result is: +249 -216 =534 +11 ELO

And after another 456 games we still have: +122 -113 =221

15 years agoIntroduce move_pawns() helper in movegen.cpp
Marco Costalba [Tue, 14 Apr 2009 10:36:34 +0000 (12:36 +0200)]
Introduce move_pawns() helper in movegen.cpp

This let us to have more readable code keeping the
same speed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRemove failHigh/Low bits from IterationInfoType
Marco Costalba [Thu, 16 Apr 2009 08:02:01 +0000 (10:02 +0200)]
Remove failHigh/Low bits from IterationInfoType

We don't use that info anyway.

Also document a little more new aspiration window code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRestore calling insert_pv after search is aborted + small clean-up
Joona Kiiski [Wed, 15 Apr 2009 15:14:06 +0000 (18:14 +0300)]
Restore calling insert_pv after search is aborted + small clean-up

Restore old behaviour that after search is aborted we call insert_pv,
before breaking out from the iterative deepening loop.

Remove one useless FIXME and document other better.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoLittle code style tweaks
Marco Costalba [Wed, 15 Apr 2009 10:44:55 +0000 (12:44 +0200)]
Little code style tweaks

Let the code be more conformant to current style.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert previous patch as per Joona request
Marco Costalba [Wed, 15 Apr 2009 08:20:35 +0000 (10:20 +0200)]
Revert previous patch as per Joona request
Joona says patch gives bad results after testing,
so revert for now.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoImprove handling of fail-highs in assumed PV
Joona Kiiski [Sun, 12 Apr 2009 21:27:07 +0000 (00:27 +0300)]
Improve handling of fail-highs in assumed PV

Check all fail highs in assumed PV with greater care (fruit/Toga already does this).
Add a flag when aspiration search fails high at ply 1 to prevent search to
be terminated prematurely.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert "Implement a fallback system when aspiration search fails low and we are out...
Joona Kiiski [Sun, 12 Apr 2009 20:30:40 +0000 (23:30 +0300)]
Revert "Implement a fallback system when aspiration search fails low and we are out of time."

This reverts commit 55dd98f7c717b94a659931cd20e088334b1cf7a6.

Revert fallback-system for root_search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoImplement a fallback system when aspiration search fails low and we are out of time.
Joona Kiiski [Sun, 12 Apr 2009 20:25:05 +0000 (23:25 +0300)]
Implement a fallback system when aspiration search fails low and we are out of time.

However also this patch is immediately reverted. For three reasons:
1) the case it affects is very rare (and then we are likely to lose anyway),
   so we can well live without this.

2) Because the case is so rare it's hard to test this change properly.

3) To perform fallback search, we must reset so many global variables that this
   patch is very likely both buggy and extremely bad style.

Consider including this again if we clean-up global variables one day...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert "Implement bestValue in root_search."
Joona Kiiski [Sun, 12 Apr 2009 16:49:09 +0000 (19:49 +0300)]
Revert "Implement bestValue in root_search."

This reverts commit 9a39f93f35254787b7b57980019dde276a89c48c.

Revert bestValue in root_search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoImplement bestValue in root_search.
Joona Kiiski [Sun, 12 Apr 2009 16:42:47 +0000 (19:42 +0300)]
Implement bestValue in root_search.

However just after finished writing this patch I realized that this
is not the way to go. So this will be immediately reverted.

(Just save this here in git in case I change my mind later :) )

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoDynamic aspiration search without research.
Joona Kiiski [Sat, 11 Apr 2009 13:46:35 +0000 (16:46 +0300)]
Dynamic aspiration search without research.

Implement system where aspiration search window is calculated using
values from previous iterations.

And then some crazy experimental stuff: If search fails low at the root,
don't widen window, but continue and hope we will find a better move
with given window. If search fails high at the root, cut immediately,
add some more time and start new iteration.

Note: this patch is not complete implementation, but a first test
for this idea. There are many FIXMEs left around. Most importantly
how to deal with the situation when we don't have any move!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRe-fix square.h warning to avoid a compile error under MSVC
Marco Costalba [Sun, 12 Apr 2009 15:45:33 +0000 (16:45 +0100)]
Re-fix square.h warning to avoid a compile error under MSVC

This fix adds ugliness to an already ugly previous fix...hopefully
it is the last one :-(

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a gcc warning due to order of initialization in Option
Marco Costalba [Sun, 12 Apr 2009 16:05:09 +0000 (18:05 +0200)]
Fix a gcc warning due to order of initialization in Option

Move idx declaration before minValue and maxValue and silence
this last warning.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a compile error with Intel icc
Marco Costalba [Sun, 12 Apr 2009 16:01:06 +0000 (18:01 +0200)]
Fix a compile error with Intel icc

To make std::sort() work operator<() should be
declared const.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a warning under Intel compiler in square.h
Marco Costalba [Sun, 12 Apr 2009 15:58:30 +0000 (17:58 +0200)]
Fix a warning under Intel compiler in square.h

We need to cast to char the whole expression...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a very nasty conversion bug in Option c'tor
Marco Costalba [Sun, 12 Apr 2009 00:09:03 +0000 (01:09 +0100)]
Fix a very nasty conversion bug in Option c'tor

Sometimes C++ can be really bad!

In this case an hard coded c string selects Option c'tor
with int argument instead of the std::string one becuase
it is considered a better matching by the compiler.

Fix the bug changing the argument type from std::string to
const char* so to be a better match then the int one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoStore UCI options of type CHECK according to C++ convention
Marco Costalba [Sat, 11 Apr 2009 12:04:33 +0000 (14:04 +0200)]
Store UCI options of type CHECK according to C++ convention

Store boolean values as "1" and "0" instead of "true" and "false"
and convert back to UCI protocol convention when needed.

This is simpler then the other way around.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRestore original UCI option printing order
Marco Costalba [Sat, 11 Apr 2009 11:28:51 +0000 (13:28 +0200)]
Restore original UCI option printing order

For each option store its index so to be printed
according to insertion order.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoUse a map instead of a vector to store UCI options
Marco Costalba [Sat, 11 Apr 2009 10:46:47 +0000 (12:46 +0200)]
Use a map instead of a vector to store UCI options

Apart from the teoretical speed increase, the main reason
of this patch is a good amount of code cleanup.

Note that now UCI options are printed in alphabetical
order and not in insertion order as before. Next patch
will take care of restoring old behaviour.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRemove unused currentMoveCaptureValue from search stack
Marco Costalba [Tue, 7 Apr 2009 07:54:32 +0000 (09:54 +0200)]
Remove unused currentMoveCaptureValue from search stack

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoLess aggressive null move dynamic reduction
Marco Costalba [Fri, 10 Apr 2009 08:49:29 +0000 (09:49 +0100)]
Less aggressive null move dynamic reduction

In null move search do not jump directly in
qsearch() from depth(4*OnePly), but only
from depth(3*OnePly).

After 999 games at 1+0: +248 -224 =527 +8ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert dynamic LMR
Marco Costalba [Fri, 3 Apr 2009 19:34:22 +0000 (20:34 +0100)]
Revert dynamic LMR

It doesn't seem to work against Toga. After more then 400 games
we are at -13 ELO while, without it we are at + 5 ELO after 1000
games.

So revert for now to keep code simple.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix compile in the debug mode
Marco Costalba [Mon, 30 Mar 2009 10:12:52 +0000 (12:12 +0200)]
Fix compile in the debug mode

Due to previous patches we end up with a compile
error in debug mode.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSilence idiotic warning on two's complement of an unsigned
Marco Costalba [Mon, 30 Mar 2009 10:07:45 +0000 (12:07 +0200)]
Silence idiotic warning on two's complement of an unsigned

MSVC gives:

warning C4146: unary minus operator applied to unsigned type,
               result still unsigned

When finds -b where b is an unsigned integer. So rewrite the two's
complement in a way to avoid the warning. Theoretically the new
version is slower, but in practice changes nothing.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSilence a bunch of warnings under MSVC /W4
Marco Costalba [Mon, 30 Mar 2009 09:55:13 +0000 (11:55 +0200)]
Silence a bunch of warnings under MSVC /W4

Still some remain, but are really the silly ones.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert setting a flag when TT value equals static evaluation
Marco Costalba [Tue, 31 Mar 2009 12:57:44 +0000 (14:57 +0200)]
Revert setting a flag when TT value equals static evaluation
Strangely enough it seems that optimization doesn't work.

After 760 games at 1+0: +155 -184 =421 -13 ELO

Probably the overhead, although small, for setting the flag
is not compensated by the saved evaluation call.

This could be due to the fact that after a TT value is stored,
if and when we hit the position again the stored TT value is
actually used as a cut-off so that we don't need to go on
with another search and evaluation is avoided in any case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoAn VALUE_TYPE_EVAL score cannot overwrite an entry
Marco Costalba [Mon, 30 Mar 2009 08:09:27 +0000 (09:09 +0100)]
An VALUE_TYPE_EVAL score cannot overwrite an entry

If we want to store a value of type VALUE_TYPE_EVAL for
a given position and we found an already exsisting entry
for the same position then we skip.

We don't want to overwrite a more valuable score with a
lesser one. Note that also in case the exsisting entry is
of VALUE_TYPE_EVAL type the overwrite is unuseful because
we would store the same score again.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRemember when TT value equals static evaluation value
Marco Costalba [Mon, 30 Mar 2009 07:54:09 +0000 (08:54 +0100)]
Remember when TT value equals static evaluation value

When the stored TT value equals the static value set a
proper flag so to not call evaluation() if we hit the
same position again but use the stored TT value instead.

This is another trick to avoid calling costly evaluation()
in qsearch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoDocument TTEntry and move layouts
Marco Costalba [Mon, 30 Mar 2009 07:29:02 +0000 (08:29 +0100)]
Document TTEntry and move layouts

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoA move needs 17 bits not 19
Marco Costalba [Sun, 29 Mar 2009 16:22:10 +0000 (17:22 +0100)]
A move needs 17 bits not 19

Fix a bug in the way a move is stored and read in a TT entry.
We use a mask of 19 bits insteaad of 17 so that the last
two bits in the TT entry end up to be random data.

This bug will bite us when we will use these two until now
unused bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRemove some obsolete code in movepick.cpp
Marco Costalba [Fri, 27 Mar 2009 18:18:21 +0000 (19:18 +0100)]
Remove some obsolete code in movepick.cpp

This fixes some warning under Intel compiler.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert storing of TT when returning from "stand pat"
Marco Costalba [Fri, 27 Mar 2009 14:30:45 +0000 (15:30 +0100)]
Revert storing of TT when returning from "stand pat"

After testing it seems patch is bad:

After 999 games 1+0: +242 -271 =486 -10 ELO

So restore saving of TT at the end but using new Joona
idea of storing as VALUE_TYPE_UPPER/VALUE_TYPE_LOWER instead
of VALUE_TYPE_EXACT.

Some optimization is still possible but better test new ideas
one by one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoCache evaluation score in qsearch
Marco Costalba [Tue, 24 Mar 2009 14:48:14 +0000 (15:48 +0100)]
Cache evaluation score in qsearch

Instead of just drop evaluation score after stand pat
logic save it in TT so to be reused if the same position
occurs again.

Note that we NEVER use the cached value apart to avoid an
evaluation call, in particulary we never return to caller
after a succesful tt hit.

To accomodate this a new value type VALUE_TYPE_EVAL has been
introduced so that ok_to_use_TT() always returns false.

With this patch we cut about 15% of total evaluation calls.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoLet to toggle dynamic LMR
Marco Costalba [Tue, 24 Mar 2009 13:34:46 +0000 (14:34 +0100)]
Let to toggle dynamic LMR

It is now disabled by default due to bad results
against a pool of engines...more testing is needed tough.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoIn qsearch update TT only if returning from stand pat
Marco Costalba [Tue, 24 Mar 2009 10:26:43 +0000 (11:26 +0100)]
In qsearch update TT only if returning from stand pat

This is the only "correct" exact value we can store.

Otherwise there could be spurious failed high/low nodes.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoWhen asked for position key print it as an hex value
Marco Costalba [Tue, 24 Mar 2009 09:50:13 +0000 (10:50 +0100)]
When asked for position key print it as an hex value

Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoWait at least until iteration 3 before to stop the search
Marco Costalba [Tue, 24 Mar 2009 09:49:02 +0000 (10:49 +0100)]
Wait at least until iteration 3 before to stop the search

It was 2 before.

Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoLet zobrist keys to be compatible with Glaurung 1
Marco Costalba [Tue, 24 Mar 2009 09:40:22 +0000 (10:40 +0100)]
Let zobrist keys to be compatible with Glaurung 1

Some changes to the zobrist keys, to make them identical
to those used by Glaurung 1.

The only purpose is to make it possible for both programs
to use the same opening book.

Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFixed a sliding attack bitboard bug in 32-bit mode
Marco Costalba [Tue, 24 Mar 2009 09:30:27 +0000 (10:30 +0100)]
Fixed a sliding attack bitboard bug in 32-bit mode

This is what prevented USE_32BIT_ATTACKS from working
on some architectures (like PowerPC).

Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a bug in insert_pv() where minimum depth is zero
Marco Costalba [Mon, 23 Mar 2009 14:30:20 +0000 (15:30 +0100)]
Fix a bug in insert_pv() where minimum depth is zero

We implicitly considered the minimum depth stored in TT
to be Depth(0), but because we store values in TT also in
qsearch() where depth is < 0, we need to use a negative
number as minimum depth.

Bug spotted by Joona Kiiski.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert odd depths razoring
Marco Costalba [Mon, 23 Mar 2009 11:02:15 +0000 (12:02 +0100)]
Revert odd depths razoring
I have just made a new rule that no modification
that increases pruning is allowed if after 1000 games
ELO is not increased by at least 10 point (was +5 in this case)

Yes, I like this kind of nosense rules :-)

15 years agoMore aggressive dynamic LMR
Marco Costalba [Mon, 23 Mar 2009 10:58:28 +0000 (11:58 +0100)]
More aggressive dynamic LMR

Previous setup didn't change anything

After 996 games 1+0: +267 -261 =468 +2 ELO

Now with this new setup we have

After 999 games 1+0: +277 -245 =477 +11 ELO

Seems reasonable...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoLMR dynamic reduction
Marco Costalba [Fri, 20 Mar 2009 11:33:30 +0000 (12:33 +0100)]
LMR dynamic reduction

Reduce of two plies near the leafs and when we still
have enough depth to go so to limit horizon effects.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoAlways print a best move when requested
Marco Costalba [Sun, 22 Mar 2009 13:49:18 +0000 (14:49 +0100)]
Always print a best move when requested

Little fix merged from iPhone Glaurung.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoBetter castle move detector in move_to_san()
Marco Costalba [Sun, 22 Mar 2009 13:32:00 +0000 (14:32 +0100)]
Better castle move detector in move_to_san()

Merged from iPhone Glaurung.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a smal bug in Position::from_fen
Marco Costalba [Sun, 22 Mar 2009 13:18:25 +0000 (14:18 +0100)]
Fix a smal bug in Position::from_fen

We could fail to parse an en-passant position
in same cases.

Merged from iPhone Glaurung.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMerge new pawn storm evaluation
Marco Costalba [Sun, 22 Mar 2009 12:55:08 +0000 (13:55 +0100)]
Merge new pawn storm evaluation

More accuracy in pawn storm evaluation
directly from iPhone Glaurung.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a small bug in king safety
Marco Costalba [Sun, 22 Mar 2009 12:11:24 +0000 (13:11 +0100)]
Fix a small bug in king safety

Merged from iPhone Glaurung.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMerge KBPP vs KB endgame from iPhone Glaurung
Marco Costalba [Sun, 22 Mar 2009 12:06:29 +0000 (13:06 +0100)]
Merge KBPP vs KB endgame from iPhone Glaurung

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix: In qsearch do not use TT value when in a PV node
Marco Costalba [Sat, 21 Mar 2009 13:51:31 +0000 (14:51 +0100)]
Fix: In qsearch do not use TT value when in a PV node

We already do like this in search_pv(), so extend
also in qsearch().

Bug spotted by Joona Kiiski.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoBig headers cleanup
Marco Costalba [Wed, 18 Mar 2009 14:36:03 +0000 (15:36 +0100)]
Big headers cleanup

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSafe guard some wild and ugly casts
Marco Costalba [Mon, 16 Mar 2009 12:59:41 +0000 (13:59 +0100)]
Safe guard some wild and ugly casts

These casts are needed but plain ugly, at least be
sure they don't hide any subtle conversion bug.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoPartially revert pawns storm bug fix
Marco Costalba [Mon, 16 Mar 2009 07:02:33 +0000 (08:02 +0100)]
Partially revert pawns storm bug fix

Try to save space and use the minimum size
possible.

In particular restore int16_t for values and int8_t
for halfOpenFiles.

Use int16_t for storm values insted of int and also
instead of original buggy and too small int8_t.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSilence a good bunch of Intel warnings
Marco Costalba [Sun, 15 Mar 2009 17:07:28 +0000 (18:07 +0100)]
Silence a good bunch of Intel warnings

Note that some pawns and material info has been switched
to int from int8_t.

This is a waste of space but it is not clear if we have a
faster or slower code (or nothing changed), some test should be
needed.

Few warnings still are alive.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix an overflow bug in pawns stormValue
Marco Costalba [Sun, 15 Mar 2009 17:06:40 +0000 (18:06 +0100)]
Fix an overflow bug in pawns stormValue

These fields are defined as int8_t but values bigger
then 127 are stored there so that we silently overflow.

Fix bringing up all the fields to a sane int type. This
will increase memory usage, but apart from being safe, it is
not clear if code is slower or faster. Test is needed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a silly warning on Intel compiler
Marco Costalba [Sun, 15 Mar 2009 16:02:09 +0000 (17:02 +0100)]
Fix a silly warning on Intel compiler

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert NULL move beta corrections
Marco Costalba [Sun, 15 Mar 2009 15:44:12 +0000 (16:44 +0100)]
Revert NULL move beta corrections
After testing result is bad -25 ELO

15 years agoRetire Null Driven IID
Marco Costalba [Fri, 13 Mar 2009 14:39:22 +0000 (15:39 +0100)]
Retire Null Driven IID

It does not seem to clearly improve things and
in any case is disabled by default, so retire for now.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMerge Joona Kiiski NULL search beta correction
Marco Costalba [Fri, 13 Mar 2009 14:26:02 +0000 (15:26 +0100)]
Merge Joona Kiiski NULL search beta correction

Prune more moves after a null search because of
a lower beta limit then in main search.

In test positions reduces the searched nodes of 30% !!!!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMerge Joona Kiiski evaluation tweaks
Marco Costalba [Fri, 13 Mar 2009 10:20:24 +0000 (11:20 +0100)]
Merge Joona Kiiski evaluation tweaks

Merge tewaks to many evaluation parameters
by Joona Kiiski.

After test they seem good!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize move_is_check()
Marco Costalba [Sat, 7 Mar 2009 19:38:05 +0000 (20:38 +0100)]
Micro optimize move_is_check()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize pl_move_is_legal()
Marco Costalba [Sat, 7 Mar 2009 19:08:45 +0000 (20:08 +0100)]
Micro optimize pl_move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize previous patch
Marco Costalba [Fri, 6 Mar 2009 19:39:43 +0000 (20:39 +0100)]
Micro optimize previous patch

Also remove some Intel warnings, not all :-(

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoIntroduce evaluate_pieces<>() to remove redundancy
Marco Costalba [Fri, 6 Mar 2009 15:29:46 +0000 (16:29 +0100)]
Introduce evaluate_pieces<>() to remove redundancy

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix compile error with inlines under gcc and Intel
Marco Costalba [Wed, 4 Mar 2009 22:11:23 +0000 (23:11 +0100)]
Fix compile error with inlines under gcc and Intel

It seems that these compilers do not like inline functions
that call a template when template definition is not in scope.

So move functions from header to in *.cpp file

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix some comments in position.cpp
Marco Costalba [Wed, 4 Mar 2009 15:34:04 +0000 (16:34 +0100)]
Fix some comments in position.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoAvoid to call useless sliders attacks in update_checkers()
Marco Costalba [Wed, 4 Mar 2009 13:50:39 +0000 (14:50 +0100)]
Avoid to call useless sliders attacks in update_checkers()

Quickly filter out some calls to sliders attacks
when we already know that will fail for sure.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSuper fast hidden_checkers()
Marco Costalba [Wed, 4 Mar 2009 11:04:28 +0000 (12:04 +0100)]
Super fast hidden_checkers()

Rewritten hidden_checkers() to avoid calling
sliders attacks functions but just a much
faster squares_between()

Also a good code semplification.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoCleanup SearchStack initialization
Marco Costalba [Tue, 3 Mar 2009 10:17:43 +0000 (11:17 +0100)]
Cleanup SearchStack initialization

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoMicro optimize copy of new state in do_move()
Marco Costalba [Mon, 2 Mar 2009 16:32:30 +0000 (17:32 +0100)]
Micro optimize copy of new state in do_move()

Instead of copying all, copy only the fields that
are updated incrementally, not the ones that are
recalcuated form scratch anyway.

This reduces copy overhead of 30%.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRevert hidden checkers rework
Marco Costalba [Mon, 2 Mar 2009 15:20:00 +0000 (16:20 +0100)]
Revert hidden checkers rework

It is slower the previous uglier but faster code.

So completely restore old one for now :-(

Just leave in the rework of status backup/restore in do_move().

We will cherry pick bits of previous work once we are sure
we have fixed the performance regression.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoUse checker info to remove a bunch of hidden checks updates
Marco Costalba [Sat, 28 Feb 2009 15:49:50 +0000 (16:49 +0100)]
Use checker info to remove a bunch of hidden checks updates

Another powerful condition let us remove a big chunk of
useless updates.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoStricter condition to check for dc candidates
Marco Costalba [Sat, 28 Feb 2009 12:43:49 +0000 (13:43 +0100)]
Stricter condition to check for dc candidates

Another optimization that let us remove another half
of find_hidden_checks(them, DcCandidates) calls.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSplit calculation of pinners from dc candidates
Marco Costalba [Sat, 28 Feb 2009 09:20:57 +0000 (10:20 +0100)]
Split calculation of pinners from dc candidates

This let us to calculate only pinners when we now that
dc candidates are not possible.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSlightly better condition in update_hidden_checks()
Marco Costalba [Sat, 28 Feb 2009 08:42:52 +0000 (09:42 +0100)]
Slightly better condition in update_hidden_checks()

Use a more strict condition to check if we have captured
an opponent pinner or hidden checker.

With this patch the occurrence of checkerCaptured == true are
reduced of 50%.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoCompute pinned and friends incrementally
Marco Costalba [Sat, 28 Feb 2009 08:18:29 +0000 (09:18 +0100)]
Compute pinned and friends incrementally

In do_move() use previous pinned bitboards values to compute
the new one after the move. In particulary we end up with the
same bitboards in most cases. So detect these cases and just
keep the old values.

This should speedup a lot this slow computation in a very hot
path so that we can use this important info everywhere in the
code at very cheap cost.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix a subtle bug due to the StateInfo pointer became stale
Marco Costalba [Mon, 23 Feb 2009 17:46:33 +0000 (18:46 +0100)]
Fix a subtle bug due to the StateInfo pointer became stale

There was one occurence when the StateInfo variable went
out of scope before the corresponding Position object.

This yelds to a crash. Bug was not hit before because occurs
only when using an UCI interface and not the usual benchmark.

The fix consists in copying internally the content of the
about to stale StateInfo.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoTeach SEE about pinned pieces
Marco Costalba [Mon, 23 Feb 2009 14:19:51 +0000 (15:19 +0100)]
Teach SEE about pinned pieces

Remove pinned pieces from attacks when calculating
SEE value.

Algorithm is not perfect, there should be no false
positives, but can happen that we miss to remove a
pinned piece. Currently we don't cach 100% of cases,
but is a tradeoff between speed and accuracy. In any
case we stay on the safe side, so we remove an attacker
when we are sure it is pinned.

About only 0,5% of cases are affected by this patch, not
a lot given the hard work: this is a difficult patch!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoSmall Position::clear() cleanup
Marco Costalba [Mon, 23 Feb 2009 11:48:57 +0000 (12:48 +0100)]
Small Position::clear() cleanup

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoDo not copy the whole old state in do_move()
Marco Costalba [Mon, 23 Feb 2009 11:06:06 +0000 (12:06 +0100)]
Do not copy the whole old state in do_move()

Instead of copy the old state in the new one, copy only
fields that will be updated incrementally, not the ones
that will be recalculcated anyway.

This let us copy 13 bytes instead of 28 for each do_move()
call.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoUpdate pinned bitboards and friends in do_move()
Marco Costalba [Mon, 23 Feb 2009 10:37:31 +0000 (11:37 +0100)]
Update pinned bitboards and friends in do_move()

Probably is slightly slow, but code is surely better
in this way. We will optimize later for speed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoFix some asserts unhidden by a debug compile
Marco Costalba [Sun, 22 Feb 2009 23:21:11 +0000 (00:21 +0100)]
Fix some asserts unhidden by a debug compile

Fallback form previous patches.
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoAvoid resetting pinners[c]
Marco Costalba [Sun, 22 Feb 2009 20:06:52 +0000 (21:06 +0100)]
Avoid resetting pinners[c]

Small optimization. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoIntroduce StateInfo instead of UndoInfo
Marco Costalba [Sun, 22 Feb 2009 19:16:21 +0000 (20:16 +0100)]
Introduce StateInfo instead of UndoInfo

We don't backup anymore but use the renamed StateInfo
argument passed in do_move() to store the new position
state when doing a move.

Backup is now just revert to previous StateInfo that we know
because we store a pointer to it.
Note that now backing store is up to the caller, Position is
stateless in that regard, state is accessed through a pointer.

This patch will let us remove all the backup/restore copying,
just a pointer switch is now necessary.

Note that do_null_move() still uses StateInfo as backup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoWrap state variables in a named struct
Marco Costalba [Sun, 22 Feb 2009 17:31:24 +0000 (18:31 +0100)]
Wrap state variables in a named struct

This will allow us to more easily move the state
out of Position class.

No functioanl change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoConvert also undo_null_move() to avoid passing UndoInfo object
Marco Costalba [Sun, 22 Feb 2009 17:03:23 +0000 (18:03 +0100)]
Convert also undo_null_move() to avoid passing UndoInfo object

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoPassing UndoInfo is not needed anymore when undoing the move
Marco Costalba [Sun, 22 Feb 2009 16:49:52 +0000 (17:49 +0100)]
Passing UndoInfo is not needed anymore when undoing the move

We store it now in the same UndoInfo struct as 'previous'
field, so when doing a move we also know where to get
the previous info when undoing the back the move.

This is needed for future patches and is a nice cleanup anyway.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoRemove two useless calls to pinned_pieces()
Marco Costalba [Sat, 21 Feb 2009 18:59:29 +0000 (19:59 +0100)]
Remove two useless calls to pinned_pieces()

Are obsoleted by new pinned caching code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoPosition: Unify and templetize mg_pst() and eg_pst()
Marco Costalba [Fri, 20 Feb 2009 11:21:52 +0000 (12:21 +0100)]
Position: Unify and templetize mg_pst() and eg_pst()

Also templetize compute_value() can be simpler now that
the above is templetized too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
15 years agoUnify compute_mg_value() and compute_eg_value()
Marco Costalba [Fri, 20 Feb 2009 11:05:07 +0000 (12:05 +0100)]
Unify compute_mg_value() and compute_eg_value()

No functional change.

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