From ed834bdfbd950e4403a0247f2253d505a2fe83e7 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 19 Nov 2011 10:11:26 +0000 Subject: [PATCH] DroidFish: Updated Stockfish engine to version 2.1.1. --- DroidFish/jni/stockfish/book.cpp | 17 ++++++++++++++++- DroidFish/jni/stockfish/book.h | 11 +---------- DroidFish/jni/stockfish/evaluate.cpp | 6 +++--- DroidFish/jni/stockfish/misc.cpp | 2 +- DroidFish/jni/stockfish/search.cpp | 1 - 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/DroidFish/jni/stockfish/book.cpp b/DroidFish/jni/stockfish/book.cpp index 8c7cd52..26fd7c9 100644 --- a/DroidFish/jni/stockfish/book.cpp +++ b/DroidFish/jni/stockfish/book.cpp @@ -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 +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 /// 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); - *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()) { diff --git a/DroidFish/jni/stockfish/book.h b/DroidFish/jni/stockfish/book.h index ed68210..8299b03 100644 --- a/DroidFish/jni/stockfish/book.h +++ b/DroidFish/jni/stockfish/book.h @@ -48,12 +48,7 @@ public: const std::string name() const { return bookName; } private: - // read n chars from the file stream and converts them in an - // integer number. Integers are stored with highest byte first. - template uint64_t get_int(); - - template - Book& operator>>(T& n) { n = (T)get_int(); return *this; } + template void get_number(T& n); BookEntry read_entry(int idx); int find_entry(uint64_t key); @@ -64,8 +59,4 @@ private: RKISS RKiss; }; -// Yes, we indulge a bit here ;-) -template inline uint64_t Book::get_int() { return 256 * get_int() + bookFile.get(); } -template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); } - #endif // !defined(BOOK_H_INCLUDED) diff --git a/DroidFish/jni/stockfish/evaluate.cpp b/DroidFish/jni/stockfish/evaluate.cpp index 8b77a82..9868d54 100644 --- a/DroidFish/jni/stockfish/evaluate.cpp +++ b/DroidFish/jni/stockfish/evaluate.cpp @@ -142,9 +142,9 @@ namespace { { 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. - const Score ThreatedByPawnPenalty[] = { + const Score ThreatenedByPawnPenalty[] = { 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 // of threat evaluation must be done later when we have full attack info. if (bit_is_set(ei.attackedBy[Them][PAWN], s)) - score -= ThreatedByPawnPenalty[Piece]; + score -= ThreatenedByPawnPenalty[Piece]; // Bishop and knight outposts squares if ((Piece == BISHOP || Piece == KNIGHT) && pos.square_is_weak(s, Us)) diff --git a/DroidFish/jni/stockfish/misc.cpp b/DroidFish/jni/stockfish/misc.cpp index f168782..2a47650 100644 --- a/DroidFish/jni/stockfish/misc.cpp +++ b/DroidFish/jni/stockfish/misc.cpp @@ -54,7 +54,7 @@ using namespace std; /// current date (in the format YYMMDD) is used as a version number. static const string AppName = "Stockfish"; -static const string EngineVersion = "2.1"; +static const string EngineVersion = "2.1.1"; static const string AppTag = ""; diff --git a/DroidFish/jni/stockfish/search.cpp b/DroidFish/jni/stockfish/search.cpp index 49473a2..dc534fe 100644 --- a/DroidFish/jni/stockfish/search.cpp +++ b/DroidFish/jni/stockfish/search.cpp @@ -1068,7 +1068,6 @@ split_point_start: // At split points actual search starts from here ss->reduction = reduction(depth, moveCount); if (ss->reduction) { - alpha = SpNode ? sp->alpha : alpha; Depth d = newDepth - ss->reduction; value = -search(pos, ss+1, -(alpha+1), -alpha, d);