Big trailing whitespace cleanup part 1

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-01-07 14:26:58 +01:00
parent 5cacefe7c6
commit c97104e854
16 changed files with 126 additions and 129 deletions

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -53,7 +53,7 @@ const std::string BenchmarkPositions[] = {
"4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - 3 22", "4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - 3 22",
"3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26" "3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26"
}; };
//// ////
//// Functions //// Functions
@@ -88,7 +88,7 @@ void benchmark(const std::string& commandLine) {
std::cerr << "The number of threads must be between 1 and " << THREAD_MAX std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
<< std::endl; << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
set_option_value("Hash", ttSize); set_option_value("Hash", ttSize);
set_option_value("Threads", threads); set_option_value("Threads", threads);
set_option_value("OwnBook", "false"); set_option_value("OwnBook", "false");
@@ -109,7 +109,7 @@ void benchmark(const std::string& commandLine) {
maxNodes = val; maxNodes = val;
std::vector<std::string> positions; std::vector<std::string> positions;
if (fileName != "default") if (fileName != "default")
{ {
std::ifstream fenFile(fileName.c_str()); std::ifstream fenFile(fileName.c_str());
@@ -118,7 +118,7 @@ void benchmark(const std::string& commandLine) {
std::cerr << "Unable to open positions file " << fileName std::cerr << "Unable to open positions file " << fileName
<< std::endl; << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
std::string pos; std::string pos;
while (fenFile.good()) while (fenFile.good())
{ {

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -53,11 +53,11 @@ namespace {
Bitboard wk_attacks() const; Bitboard wk_attacks() const;
Bitboard bk_attacks() const; Bitboard bk_attacks() const;
Bitboard pawn_attacks() const; Bitboard pawn_attacks() const;
Square whiteKingSquare, blackKingSquare, pawnSquare; Square whiteKingSquare, blackKingSquare, pawnSquare;
Color sideToMove; Color sideToMove;
}; };
Result *Bitbase; Result *Bitbase;
const int IndexMax = 2*24*64*64; const int IndexMax = 2*24*64*64;
@@ -69,7 +69,7 @@ namespace {
Result classify_btm(const KPKPosition &p); Result classify_btm(const KPKPosition &p);
int compute_index(Square wksq, Square bksq, Square psq, Color stm); int compute_index(Square wksq, Square bksq, Square psq, Color stm);
int compress_result(Result r); int compress_result(Result r);
} }
@@ -113,7 +113,7 @@ namespace {
return compute_index(whiteKingSquare, blackKingSquare, pawnSquare, return compute_index(whiteKingSquare, blackKingSquare, pawnSquare,
sideToMove); sideToMove);
} }
bool KPKPosition::is_legal() const { bool KPKPosition::is_legal() const {
if(whiteKingSquare == pawnSquare || whiteKingSquare == blackKingSquare || if(whiteKingSquare == pawnSquare || whiteKingSquare == blackKingSquare ||
@@ -137,7 +137,7 @@ namespace {
if(sideToMove == BLACK) { if(sideToMove == BLACK) {
Bitboard wka = this->wk_attacks(); Bitboard wka = this->wk_attacks();
Bitboard bka = this->bk_attacks(); Bitboard bka = this->bk_attacks();
// Case 1: Stalemate // Case 1: Stalemate
if((bka & ~(wka | this->pawn_attacks())) == EmptyBoardBB) if((bka & ~(wka | this->pawn_attacks())) == EmptyBoardBB)
return true; return true;
@@ -166,7 +166,7 @@ namespace {
(square_distance(blackKingSquare, pawnSquare+DELTA_N) > 1 || (square_distance(blackKingSquare, pawnSquare+DELTA_N) > 1 ||
bit_is_set(this->wk_attacks(), pawnSquare+DELTA_N)); bit_is_set(this->wk_attacks(), pawnSquare+DELTA_N));
} }
Bitboard KPKPosition::wk_attacks() const { Bitboard KPKPosition::wk_attacks() const {
return StepAttackBB[WK][whiteKingSquare]; return StepAttackBB[WK][whiteKingSquare];
@@ -204,7 +204,7 @@ namespace {
bool next_iteration() { bool next_iteration() {
KPKPosition p; KPKPosition p;
int previousUnknownCount = UnknownCount; int previousUnknownCount = UnknownCount;
for(int i = 0; i < IndexMax; i++) for(int i = 0; i < IndexMax; i++)
if(Bitbase[i] == RESULT_UNKNOWN) { if(Bitbase[i] == RESULT_UNKNOWN) {
p.from_index(i); p.from_index(i);
@@ -231,7 +231,7 @@ namespace {
bool unknownFound = false; bool unknownFound = false;
Bitboard b; Bitboard b;
Square s; Square s;
// King moves // King moves
b = p.wk_attacks(); b = p.wk_attacks();
while(b) { while(b) {
@@ -260,14 +260,14 @@ namespace {
BLACK)]) { BLACK)]) {
case RESULT_LOSS: case RESULT_LOSS:
return RESULT_WIN; return RESULT_WIN;
case RESULT_UNKNOWN: case RESULT_UNKNOWN:
unknownFound = true; unknownFound = true;
break; break;
case RESULT_DRAW: case RESULT_INVALID: case RESULT_DRAW: case RESULT_INVALID:
break; break;
default: default:
assert(false); assert(false);
} }
@@ -279,20 +279,20 @@ namespace {
BLACK)]) { BLACK)]) {
case RESULT_LOSS: case RESULT_LOSS:
return RESULT_WIN; return RESULT_WIN;
case RESULT_UNKNOWN: case RESULT_UNKNOWN:
unknownFound = true; unknownFound = true;
break; break;
case RESULT_DRAW: case RESULT_INVALID: case RESULT_DRAW: case RESULT_INVALID:
break; break;
default: default:
assert(false); assert(false);
} }
} }
} }
return unknownFound? RESULT_UNKNOWN : RESULT_DRAW; return unknownFound? RESULT_UNKNOWN : RESULT_DRAW;
} }
@@ -345,5 +345,5 @@ namespace {
int compress_result(Result r) { int compress_result(Result r) {
return (r == RESULT_WIN || r == RESULT_LOSS)? 1 : 0; return (r == RESULT_WIN || r == RESULT_LOSS)? 1 : 0;
} }
} }

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -317,22 +317,22 @@ namespace {
/// Indices to the Random64[] array /// Indices to the Random64[] array
const int RandomPiece = 0; const int RandomPiece = 0;
const int RandomCastle = 768; const int RandomCastle = 768;
const int RandomEnPassant = 772; const int RandomEnPassant = 772;
const int RandomTurn = 780; const int RandomTurn = 780;
/// Convert pieces to the range 0..1 /// Convert pieces to the range 0..1
const int PieceTo12[] = { const int PieceTo12[] = {
0, 0, 2, 4, 6, 8, 10, 0, 0, 1, 3, 5, 7, 9, 11 0, 0, 2, 4, 6, 8, 10, 0, 0, 1, 3, 5, 7, 9, 11
}; };
/// Prototypes /// Prototypes
uint64_t book_key(const Position &pos); uint64_t book_key(const Position &pos);
uint64_t book_piece_key(Piece p, Square s); uint64_t book_piece_key(Piece p, Square s);
uint64_t book_castle_key(const Position &pos); uint64_t book_castle_key(const Position &pos);
@@ -364,7 +364,7 @@ void Book::open(const std::string &fName) {
if (!bookFile.is_open()) if (!bookFile.is_open())
return; return;
bookFile.seekg(0, std::ios::end); bookFile.seekg(0, std::ios::end);
bookSize = bookFile.tellg() / 16; bookSize = bookFile.tellg() / 16;
bookFile.seekg(0, std::ios::beg); bookFile.seekg(0, std::ios::beg);
@@ -388,7 +388,7 @@ void Book::close() {
/// Book::is_open() tests whether a book file has been opened. /// Book::is_open() tests whether a book file has been opened.
bool Book::is_open() const { bool Book::is_open() const {
return bookFile.is_open() && bookSize != 0; return bookFile.is_open() && bookSize != 0;
} }
@@ -400,7 +400,7 @@ const std::string Book::file_name() const {
return bookFile.is_open() ? fileName : ""; return bookFile.is_open() ? fileName : "";
} }
/// Book::get_move() gets a book move for a given position. Returns /// Book::get_move() gets a book move for a given position. Returns
/// MOVE_NONE if no book move is found. /// MOVE_NONE if no book move is found.
@@ -524,7 +524,7 @@ namespace {
return result; return result;
} }
uint64_t book_piece_key(Piece p, Square s) { uint64_t book_piece_key(Piece p, Square s) {
return Random64[RandomPiece + (PieceTo12[int(p)]^1)*64 + int(s)]; return Random64[RandomPiece + (PieceTo12[int(p)]^1)*64 + int(s)];
@@ -545,29 +545,29 @@ namespace {
return result; return result;
} }
uint64_t book_ep_key(const Position &pos) { uint64_t book_ep_key(const Position &pos) {
return (pos.ep_square() == SQ_NONE)? return (pos.ep_square() == SQ_NONE)?
0ULL : Random64[RandomEnPassant + square_file(pos.ep_square())]; 0ULL : Random64[RandomEnPassant + square_file(pos.ep_square())];
} }
uint64_t book_color_key(const Position &pos) { uint64_t book_color_key(const Position &pos) {
return (pos.side_to_move() == WHITE)? Random64[RandomTurn] : 0ULL; return (pos.side_to_move() == WHITE)? Random64[RandomTurn] : 0ULL;
} }
uint16_t read_integer16(std::ifstream& file) { uint16_t read_integer16(std::ifstream& file) {
uint64_t n = read_integer(file, 2); uint64_t n = read_integer(file, 2);
assert(n == (uint16_t)n); assert(n == (uint16_t)n);
return (uint16_t)n; return (uint16_t)n;
} }
uint64_t read_integer64(std::ifstream& file) { uint64_t read_integer64(std::ifstream& file) {
return read_integer(file, 8); return read_integer(file, 8);
} }

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -153,7 +153,7 @@ namespace {
const int KRKNKingKnightDistancePenalty[8] = { 0, 0, 4, 10, 20, 32, 48, 70 }; const int KRKNKingKnightDistancePenalty[8] = { 0, 0, 4, 10, 20, 32, 48, 70 };
// Various inline functions for accessing the above arrays: // Various inline functions for accessing the above arrays:
inline Value mate_table(Square s) { inline Value mate_table(Square s) {
return Value(MateTable[s]); return Value(MateTable[s]);
} }
@@ -174,7 +174,7 @@ namespace {
int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm); int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm);
} }
//// ////
//// Functions //// Functions
@@ -244,7 +244,7 @@ Value KXKEvaluationFunction::apply(const Position &pos) {
/// Mate with KBN vs K. This is similar to KX vs K, but we have to drive the /// Mate with KBN vs K. This is similar to KX vs K, but we have to drive the
/// defending king towards a corner square of the right color. /// defending king towards a corner square of the right color.
Value KBNKEvaluationFunction::apply(const Position &pos) { Value KBNKEvaluationFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(weakerSide) == Value(0)); assert(pos.non_pawn_material(weakerSide) == Value(0));
@@ -280,7 +280,7 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(weakerSide) == Value(0)); assert(pos.non_pawn_material(weakerSide) == Value(0));
assert(pos.piece_count(strongerSide, PAWN) == 1); assert(pos.piece_count(strongerSide, PAWN) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0); assert(pos.piece_count(weakerSide, PAWN) == 0);
Square wksq, bksq, wpsq; Square wksq, bksq, wpsq;
Color stm; Color stm;
@@ -421,7 +421,7 @@ Value KQKREvaluationFunction::apply(const Position &pos) {
Square winnerKSq = pos.king_square(strongerSide); Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide); Square loserKSq = pos.king_square(weakerSide);
Value result = QueenValueEndgame - RookValueEndgame + Value result = QueenValueEndgame - RookValueEndgame +
mate_table(loserKSq) + distance_bonus(square_distance(winnerKSq, loserKSq)); mate_table(loserKSq) + distance_bonus(square_distance(winnerKSq, loserKSq));
@@ -764,9 +764,9 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
// Case 2: Opposite colored bishops. // Case 2: Opposite colored bishops.
if(square_color(strongerBishopSq) != square_color(weakerBishopSq)) { if(square_color(strongerBishopSq) != square_color(weakerBishopSq)) {
// We assume that the position is drawn in the following three situations: // We assume that the position is drawn in the following three situations:
// //
// a. The pawn is on rank 5 or further back. // a. The pawn is on rank 5 or further back.
// b. The defending king is somewhere in the pawn's path. // b. The defending king is somewhere in the pawn's path.
// c. The defending bishop attacks some square along the pawn's path, // c. The defending bishop attacks some square along the pawn's path,
@@ -774,7 +774,7 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
// //
// These rules are probably not perfect, but in practice they work // These rules are probably not perfect, but in practice they work
// reasonably well. // reasonably well.
if(relative_rank(strongerSide, pawnSq) <= RANK_5) if(relative_rank(strongerSide, pawnSq) <= RANK_5)
return ScaleFactor(0); return ScaleFactor(0);
else { else {
@@ -807,7 +807,7 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
Square pawnSq = pos.piece_list(strongerSide, PAWN, 0); Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0); Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide); Square weakerKingSq = pos.king_square(weakerSide);
if(square_file(weakerKingSq) == square_file(pawnSq) if(square_file(weakerKingSq) == square_file(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq) && relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
&& (square_color(weakerKingSq) != square_color(strongerBishopSq) && (square_color(weakerKingSq) != square_color(strongerBishopSq)
@@ -909,9 +909,9 @@ namespace {
int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm) { int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm) {
int wp = int(square_file(wpsq)) + (int(square_rank(wpsq)) - 1) * 4; int wp = int(square_file(wpsq)) + (int(square_rank(wpsq)) - 1) * 4;
int index = int(stm) + 2*int(bksq) + 128*int(wksq) + 8192*wp; int index = int(stm) + 2*int(bksq) + 128*int(wksq) + 8192*wp;
assert(index >= 0 && index < 24576*8); assert(index >= 0 && index < 24576*8);
return KPKBitbase[index/8] & (1 << (index&7)); return KPKBitbase[index/8] & (1 << (index&7));
} }
} }

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -92,7 +92,7 @@ int History::move_ordering_score(Piece p, Move m) const {
/// History::ok_to_prune() decides whether a move has been sufficiently /// History::ok_to_prune() decides whether a move has been sufficiently
/// unsuccessful that it makes sense to prune it entirely. /// unsuccessful that it makes sense to prune it entirely.
bool History::ok_to_prune(Piece p, Move m, Depth d) const { bool History::ok_to_prune(Piece p, Move m, Depth d) const {
assert(piece_is_ok(p)); assert(piece_is_ok(p));

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -41,7 +41,7 @@
using std::string; using std::string;
//// ////
//// Functions //// Functions
//// ////

View File

@@ -309,7 +309,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
/// EndgameFunctions member definitions. This class is used to store the maps /// EndgameFunctions member definitions. This class is used to store the maps
/// of end game and scaling functions that MaterialInfoTable will query for /// of end game and scaling functions that MaterialInfoTable will query for
/// each key. The maps are constant and are populated only at construction, /// each key. The maps are constant and are populated only at construction,
/// but are per-thread instead of globals to avoid expensive locks. /// but are per-thread instead of globals to avoid expensive locks.

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -310,10 +310,10 @@ void MovePicker::score_qcaptures() {
} }
/// find_best_index() loops across the moves and returns index of /// find_best_index() loops across the moves and returns index of
/// the highest scored one. There is also a second version that /// the highest scored one. There is also a second version that
/// lowers the priority of moves that attack the same square, /// lowers the priority of moves that attack the same square,
/// so that if the best move that attack a square fails the next /// so that if the best move that attack a square fails the next
/// move picked attacks a different square if any, not the same one. /// move picked attacks a different square if any, not the same one.
int MovePicker::find_best_index() { int MovePicker::find_best_index() {
@@ -329,41 +329,41 @@ int MovePicker::find_best_index() {
return bestIndex; return bestIndex;
} }
int MovePicker::find_best_index(Bitboard* squares, int values[]) { int MovePicker::find_best_index(Bitboard* squares, int values[]) {
int hs; int hs;
Move m; Move m;
Square to; Square to;
int bestScore = -10000000, bestIndex = -1; int bestScore = -10000000, bestIndex = -1;
for (int i = movesPicked; i < numOfMoves; i++) for (int i = movesPicked; i < numOfMoves; i++)
{ {
m = moves[i].move; m = moves[i].move;
to = move_to(m); to = move_to(m);
if (!bit_is_set(*squares, to)) if (!bit_is_set(*squares, to))
{ {
// Init at first use // Init at first use
set_bit(squares, to); set_bit(squares, to);
values[to] = 0; values[to] = 0;
} }
hs = moves[i].score - values[to]; hs = moves[i].score - values[to];
if (hs > bestScore) if (hs > bestScore)
{ {
bestIndex = i; bestIndex = i;
bestScore = hs; bestScore = hs;
} }
} }
if (bestIndex != -1) if (bestIndex != -1)
{ {
// Raise value of the picked square, so next attack // Raise value of the picked square, so next attack
// to the same square will get low priority. // to the same square will get low priority.
to = move_to(moves[bestIndex].move); to = move_to(moves[bestIndex].move);
values[to] += 0xB00; values[to] += 0xB00;
} }
return bestIndex; return bestIndex;
} }

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -72,13 +72,13 @@ namespace {
Value(32), Value(32), Value(32), Value(28) Value(32), Value(32), Value(32), Value(28)
}; };
// Pawn chain membership bonus by file, middle game. // Pawn chain membership bonus by file, middle game.
const Value ChainMidgameBonus[8] = { const Value ChainMidgameBonus[8] = {
Value(14), Value(16), Value(17), Value(18), Value(14), Value(16), Value(17), Value(18),
Value(18), Value(17), Value(16), Value(14) Value(18), Value(17), Value(16), Value(14)
}; };
// Pawn chain membership bonus by file, endgame. // Pawn chain membership bonus by file, endgame.
const Value ChainEndgameBonus[8] = { const Value ChainEndgameBonus[8] = {
Value(16), Value(16), Value(16), Value(16), Value(16), Value(16), Value(16), Value(16),
Value(16), Value(16), Value(16), Value(16) Value(16), Value(16), Value(16), Value(16)
@@ -107,7 +107,7 @@ namespace {
31, 40, 40, 31, 0, 0, 0, 0, 31, 40, 40, 31, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0
}; };
const int KStormTable[64] = { const int KStormTable[64] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,-4,-13,-22,-27,-27, 0, 0, 0,-4,-13,-22,-27,-27,
@@ -167,7 +167,7 @@ void PawnInfoTable::clear() {
/// PawnInfoTable::get_pawn_info() takes a position object as input, computes /// PawnInfoTable::get_pawn_info() takes a position object as input, computes
/// a PawnInfo object, and returns a pointer to it. The result is also /// a PawnInfo object, and returns a pointer to it. The result is also
/// stored in a hash table, so we don't have to recompute everything when /// stored in a hash table, so we don't have to recompute everything when
/// the same pawn structure occurs again. /// the same pawn structure occurs again.
@@ -179,7 +179,7 @@ PawnInfo *PawnInfoTable::get_pawn_info(const Position &pos) {
int index = int(key & (size - 1)); int index = int(key & (size - 1));
PawnInfo *pi = entries + index; PawnInfo *pi = entries + index;
// If pi->key matches the position's pawn hash key, it means that we // If pi->key matches the position's pawn hash key, it means that we
// have analysed this pawn structure before, and we can simply return the // have analysed this pawn structure before, and we can simply return the
// information we found the last time instead of recomputing it // information we found the last time instead of recomputing it
if (pi->key == key) if (pi->key == key)
@@ -370,7 +370,7 @@ PawnInfo *PawnInfoTable::get_pawn_info(const Position &pos) {
mgValue[us] += mv; mgValue[us] += mv;
egValue[us] += ev; egValue[us] += ev;
// If the pawn is passed, set the square of the pawn in the passedPawns // If the pawn is passed, set the square of the pawn in the passedPawns
// bitboard // bitboard
if (passed) if (passed)

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -42,9 +42,9 @@ const SquareDelta Directions[16][16] = {
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO}, DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, {DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO}, {DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, {DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, {DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_ZERO}, {DELTA_ZERO},
{DELTA_ZERO}, {DELTA_ZERO},
@@ -53,11 +53,11 @@ const SquareDelta Directions[16][16] = {
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO}, DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, {DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO}, {DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, {DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, {DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO}, DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
}; };
const SquareDelta PawnPush[2] = { const SquareDelta PawnPush[2] = {
DELTA_N, DELTA_S DELTA_N, DELTA_S

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View File

@@ -208,6 +208,3 @@ TTEntry::TTEntry(Key k, Value v, ValueType t, Depth d, Move m,
int generation) : int generation) :
key_ (k), data((m & 0x7FFFF) | (t << 20) | (generation << 23)), key_ (k), data((m & 0x7FFFF) | (t << 20) | (generation << 23)),
value_(v), depth_(int16_t(d)) {} value_(v), depth_(int16_t(d)) {}

View File

@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Stockfish is distributed in the hope that it will be useful, Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */