stockfish
12 years agoAdd simple debug hit rate counter
Marco Costalba [Sat, 6 Sep 2008 10:22:10 +0000 (12:22 +0200)]
Add simple debug hit rate counter

Add a very simple debug framework to
measure the hit rate of a given condition.

Simply insert macro

dbg_hit_on(x);

Anywhere you want to compute hit rate of condition x
and then call, as example in poll(), function
dbg_print_hit_rate() to print current results.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTranspositionTable: micro optimize first cycle
Marco Costalba [Sat, 6 Sep 2008 10:21:08 +0000 (12:21 +0200)]
TranspositionTable: micro optimize first cycle

In the common case (>95%) tte == replace so skip
additional comparisons in this case.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTranspositionTable: early skip on an empty TT entry
Marco Costalba [Sat, 6 Sep 2008 10:20:28 +0000 (12:20 +0200)]
TranspositionTable: early skip on an empty TT entry

Instead of going for the whole 4 cycle loop early
skip if TT entry is empty.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTranspositionTable: spaces inflate
Marco Costalba [Sat, 6 Sep 2008 10:19:29 +0000 (12:19 +0200)]
TranspositionTable: spaces inflate

No functional change, just a tidy up in
preparation for next patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRootMoveList: inline trivial accessors
Marco Costalba [Sat, 6 Sep 2008 04:37:00 +0000 (06:37 +0200)]
RootMoveList: inline trivial accessors

Although not performance critical, trivial
accessors can be inlined without any harm.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRootMoveList sorting: be compatible with std::sort
Marco Costalba [Fri, 5 Sep 2008 07:04:45 +0000 (09:04 +0200)]
RootMoveList sorting: be compatible with std::sort

sort() and sort_multipv() are almost the same, so
use only one implementation.

Also introduce the natural RootMove::operator<() to
compare the moves instead of compare_root_moves(),
this will allow to use std::sort instead of our
home grown bubble-sort.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoscan_for_easy_move: we don't need a loop here
Marco Costalba [Wed, 3 Sep 2008 21:33:49 +0000 (23:33 +0200)]
scan_for_easy_move: we don't need a loop here

Moves are already sorted, so just consider the best
and the second one.

Some trailing whitespace remove noise crept in due
to my editor removes it before to save.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoBetter document RootMoveList c'tor
Marco Costalba [Wed, 3 Sep 2008 21:29:04 +0000 (23:29 +0200)]
Better document RootMoveList c'tor

Also some code tidy-up.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a couple of bugs (fallout from previous patches)
Marco Costalba [Mon, 1 Sep 2008 20:05:23 +0000 (22:05 +0200)]
Fix a couple of bugs (fallout from previous patches)

After testing and comparing output with standard Glaurung
a couple of issues arised.

A default value was wrong and init_uci_options() missed a couple
of stringify() calls. Also storing bool values as "false" and "true"
needs some care.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoucioptions: Fix stringification of a bool
Marco Costalba [Mon, 1 Sep 2008 14:58:02 +0000 (16:58 +0200)]
ucioptions: Fix stringification of a bool

We want stringify a bool as "true" and "false",
not "1" and "0".

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoPreserve options order when printed
Marco Costalba [Mon, 1 Sep 2008 14:03:01 +0000 (16:03 +0200)]
Preserve options order when printed

Use a vector instead of a map so that options
are printed according to their original order.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRewrite ucioptions.cpp to use C++
Marco Costalba [Mon, 1 Sep 2008 12:05:02 +0000 (14:05 +0200)]
Rewrite ucioptions.cpp to use C++

Instead of old-style C string functions use standard
library to greatly streamline the implementation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFinally remove UCIInputParser class altogether
Marco Costalba [Mon, 1 Sep 2008 06:16:17 +0000 (08:16 +0200)]
Finally remove UCIInputParser class altogether

Class UCIInputParser is now a typedef of a std::istringstream,
this greatly simplifies the code, especially the many conversions
from string to integer are now handled automatically by the
stream instead of relying on a chunk of C-style atoi() calls.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse a string stream in UCIInputParser
Marco Costalba [Mon, 1 Sep 2008 06:06:34 +0000 (08:06 +0200)]
Use a string stream in UCIInputParser

Use a std::istringstream instead of an home
grown string tokenizer code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAvoid casts to handle isspace() arguments
Marco Costalba [Mon, 1 Sep 2008 06:03:21 +0000 (08:03 +0200)]
Avoid casts to handle isspace() arguments

Use proper standard conversion to deal
with negative values of a char.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoInitial import of Glaurung 2.1
Marco Costalba [Mon, 1 Sep 2008 05:59:13 +0000 (07:59 +0200)]
Initial import of Glaurung 2.1