Compare commits

..

6 Commits

Author SHA1 Message Date
Marco Costalba e3b23eb818 Stockfish 2.1.1
stockfish bench signature is: 6487630

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-08 08:46:33 +01:00
Marco Costalba d494725400 Spell fix in evaluate.cpp
Spotted by Eelco.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-07 10:08:53 +01:00
Marco Costalba 2535dc1340 Fix reading of book file
Bug is subtle because appears only under MSVC 32 bits in
optimized version, hence was missed before.

Bug is due to the fact that evaluation order of terms of a
sum is undefined by the standard, so in get_int() we have:

return 256 * get_int<n-1>() + bookFile.get();

And if get() is evaluated before get_int() we have a corrupted
key.

The patch rewrites the code in a more natural and predictable way.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-07 09:51:33 +01:00
Marco Costalba 339bf9b7e1 Remove redundant assignment in search()
It is already assigned few lines before.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-05 12:16:26 +01:00
Marco Costalba bb86691a0d Restore development version
No functional change.
2011-05-05 06:35:42 +01:00
Marco Costalba f7fee4c616 Fix a warning in debug mode
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-05-03 19:29:21 +01:00
5 changed files with 22 additions and 17 deletions
+16 -1
View File
@@ -502,6 +502,18 @@ int Book::find_entry(uint64_t key) {
} }
/// Book::get_number() reads sizeof(T) chars from the file's binary byte
/// stream and converts them in a number of type T.
template<typename T>
void Book::get_number(T& n) {
n = 0;
for (size_t i = 0; i < sizeof(T); i++)
n = (n << 8) + (T)bookFile.get();
}
/// Book::read_entry() takes an integer index, and returns the BookEntry /// Book::read_entry() takes an integer index, and returns the BookEntry
/// at the given index in the book file. /// at the given index in the book file.
@@ -514,7 +526,10 @@ BookEntry Book::read_entry(int idx) {
bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg); bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg);
*this >> e.key >> e.move >> e.count >> e.learn; get_number(e.key);
get_number(e.move);
get_number(e.count);
get_number(e.learn);
if (!bookFile.good()) if (!bookFile.good())
{ {
+1 -10
View File
@@ -48,12 +48,7 @@ public:
const std::string name() const { return bookName; } const std::string name() const { return bookName; }
private: private:
// read n chars from the file stream and converts them in an template<typename T> void get_number(T& n);
// integer number. Integers are stored with highest byte first.
template<int n> uint64_t get_int();
template<typename T>
Book& operator>>(T& n) { n = (T)get_int<sizeof(T)>(); return *this; }
BookEntry read_entry(int idx); BookEntry read_entry(int idx);
int find_entry(uint64_t key); int find_entry(uint64_t key);
@@ -64,8 +59,4 @@ private:
RKISS RKiss; RKISS RKiss;
}; };
// Yes, we indulge a bit here ;-)
template<int n> inline uint64_t Book::get_int() { return 256 * get_int<n-1>() + bookFile.get(); }
template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); }
#endif // !defined(BOOK_H_INCLUDED) #endif // !defined(BOOK_H_INCLUDED)
+4 -4
View File
@@ -142,9 +142,9 @@ namespace {
{ S(0, 0), S(15, 39), S(15, 39), S(15, 39), S(15, 39), S( 0, 0) } // QUEEN { S(0, 0), S(15, 39), S(15, 39), S(15, 39), S(15, 39), S( 0, 0) } // QUEEN
}; };
// ThreatedByPawnPenalty[PieceType] contains a penalty according to which // ThreatenedByPawnPenalty[PieceType] contains a penalty according to which
// piece type is attacked by an enemy pawn. // piece type is attacked by an enemy pawn.
const Score ThreatedByPawnPenalty[] = { const Score ThreatenedByPawnPenalty[] = {
S(0, 0), S(0, 0), S(56, 70), S(56, 70), S(76, 99), S(86, 118) S(0, 0), S(0, 0), S(56, 70), S(56, 70), S(76, 99), S(86, 118)
}; };
@@ -524,7 +524,7 @@ namespace {
// Decrease score if we are attacked by an enemy pawn. Remaining part // Decrease score if we are attacked by an enemy pawn. Remaining part
// of threat evaluation must be done later when we have full attack info. // of threat evaluation must be done later when we have full attack info.
if (bit_is_set(ei.attackedBy[Them][PAWN], s)) if (bit_is_set(ei.attackedBy[Them][PAWN], s))
score -= ThreatedByPawnPenalty[Piece]; score -= ThreatenedByPawnPenalty[Piece];
// Bishop and knight outposts squares // Bishop and knight outposts squares
if ((Piece == BISHOP || Piece == KNIGHT) && pos.square_is_weak(s, Us)) if ((Piece == BISHOP || Piece == KNIGHT) && pos.square_is_weak(s, Us))
@@ -924,7 +924,7 @@ namespace {
// Opponent king cannot block because path is defended and position // Opponent king cannot block because path is defended and position
// is not in check. So only friendly pieces can be blockers. // is not in check. So only friendly pieces can be blockers.
assert(!pos.in_check()); assert(!pos.in_check());
assert(queeningPath & pos.occupied_squares() == queeningPath & pos.pieces_of_color(c)); assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces_of_color(c)));
// Add moves needed to free the path from friendly pieces and retest condition // Add moves needed to free the path from friendly pieces and retest condition
movesToGo += count_1s<Max15>(queeningPath & pos.pieces_of_color(c)); movesToGo += count_1s<Max15>(queeningPath & pos.pieces_of_color(c));
+1 -1
View File
@@ -54,7 +54,7 @@ using namespace std;
/// current date (in the format YYMMDD) is used as a version number. /// current date (in the format YYMMDD) is used as a version number.
static const string AppName = "Stockfish"; static const string AppName = "Stockfish";
static const string EngineVersion = "2.1"; static const string EngineVersion = "2.1.1";
static const string AppTag = ""; static const string AppTag = "";
-1
View File
@@ -1067,7 +1067,6 @@ split_point_start: // At split points actual search starts from here
ss->reduction = reduction<PvNode>(depth, moveCount); ss->reduction = reduction<PvNode>(depth, moveCount);
if (ss->reduction) if (ss->reduction)
{ {
alpha = SpNode ? sp->alpha : alpha;
Depth d = newDepth - ss->reduction; Depth d = newDepth - ss->reduction;
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d); value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d);