A bunch of Intel C++ warnings removed, other silent out.
Still few remaining but need deeper look.
Also usual whitespace crap removal noise.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
$(RM) *.o .depend glaurung
$(RM) *.o .depend glaurung
CXXFLAGS += -O3 -fno-exceptions -fomit-frame-pointer -fno-rtti -fstrict-aliasing
CXXFLAGS += -O3 -fno-exceptions -fomit-frame-pointer -fno-rtti -fstrict-aliasing
+# Disable most annoying warnings for the Intel C++ compiler
+
+CXXFLAGS += -wd383,869,981
+
# Compiler optimization flags for the Intel C++ compiler in Mac OS X:
# Compiler optimization flags for the Intel C++ compiler in Mac OS X:
# Profiler guided optimization with the Intel C++ compiler. To use it, first
# create the directory ./profdata if it does not already exist, and delete its
# Profiler guided optimization with the Intel C++ compiler. To use it, first
# create the directory ./profdata if it does not already exist, and delete its
-# contents if it does exist. Then compile with -prof_gen, and run the
+# contents if it does exist. Then compile with -prof_gen, and run the
# resulting binary for a while (for instance, do ./glaurung bench 128 1, and
# resulting binary for a while (for instance, do ./glaurung bench 128 1, and
-# wait 15 minutes for the benchmark to complete). Then do a 'make clean', and
+# wait 15 minutes for the benchmark to complete). Then do a 'make clean', and
# recompile with -prof_use.
# recompile with -prof_use.
-# CXXFLAGS += -prof_gen -prof_dir ./profdata
+# CXXFLAGS += -prof_gen -prof_dir profdata
# CXXFLAGS += -prof_use -prof_dir ./profdata
# CXXFLAGS += -prof_use -prof_dir ./profdata
-# Profiler guided optimization with GCC. I've never been able to make this
+# Profiler guided optimization with GCC. I've never been able to make this
# work.
# CXXFLAGS += -fprofile-generate
# work.
# CXXFLAGS += -fprofile-generate
# LDFLAGS += -arch x86_64
# LDFLAGS += -arch x86_64
-# Backwards compatibility with Mac OS X 10.4 when compiling under 10.5 with
+# Backwards compatibility with Mac OS X 10.4 when compiling under 10.5 with
# GCC 4.0. I haven't found a way to make it work with GCC 4.2.
# CXXFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk
# GCC 4.0. I haven't found a way to make it work with GCC 4.2.
# CXXFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-#ifdef _MSC_VER\r
- #include <intrin.h>\r
- #ifdef _WIN64\r
- #pragma intrinsic(_BitScanForward64)\r
- #else\r
- #pragma intrinsic(_BitScanForward)\r
- #endif\r
- #define USING_INTRINSICS\r
+#ifdef _MSC_VER
+ #include <intrin.h>
+ #ifdef _WIN64
+ #pragma intrinsic(_BitScanForward64)
+ #else
+ #pragma intrinsic(_BitScanForward)
+ #endif
+ #define USING_INTRINSICS
#endif
#include <iostream>
#endif
#include <iostream>
#if defined(USE_COMPACT_ROOK_ATTACKS)
void init_file_and_rank_attacks();
#endif
#if defined(USE_COMPACT_ROOK_ATTACKS)
void init_file_and_rank_attacks();
#endif
Square pop_1st_bit(Bitboard *b) {
Square pop_1st_bit(Bitboard *b) {
- unsigned long index;\r
- uint32_t *l, *h;\r
-\r
- if (*(l = (uint32_t*)b) != 0)\r
- {\r
- _BitScanForward(&index, *l);\r
- *l &= ~(1 << index);\r
- } \r
- else if (*(h = (uint32_t*)b + 1) != 0)\r
- {\r
- _BitScanForward(&index, *h);\r
- *h &= ~(1 << index);\r
- index += 32;\r
- } else\r
- return SQ_NONE;\r
-\r
+ unsigned long index;
+ uint32_t *l, *h;
+
+ if (*(l = (uint32_t*)b) != 0)
+ {
+ _BitScanForward(&index, *l);
+ *l &= ~(1 << index);
+ }
+ else if (*(h = (uint32_t*)b + 1) != 0)
+ {
+ _BitScanForward(&index, *h);
+ *h &= ~(1 << index);
+ index += 32;
+ } else
+ return SQ_NONE;
+
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 8 9 10 11 12 13 14 15
V( 24), V( 27), V(28), V(29), V(30), V(31), V(32), V(33)
};
// 8 9 10 11 12 13 14 15
V( 24), V( 27), V(28), V(29), V(30), V(31), V(32), V(33)
};
const Value EndgameRookMobilityBonus[] = {
// 0 1 2 3 4 5 6 7
V(-30), V(-18), V(-6), V(6), V(18), V(30), V(42), V(54),
const Value EndgameRookMobilityBonus[] = {
// 0 1 2 3 4 5 6 7
V(-30), V(-18), V(-6), V(6), V(18), V(30), V(42), V(54),
((1ULL << SQ_A1) | (1ULL << SQ_H1)),
((1ULL << SQ_A8) | (1ULL << SQ_H8))
};
((1ULL << SQ_A1) | (1ULL << SQ_H1)),
((1ULL << SQ_A8) | (1ULL << SQ_H8))
};
/// King safety constants and variables. The king safety scores are taken
/// from the array SafetyTable[]. Various little "meta-bonuses" measuring
/// the strength of the attack are added up into an integer, which is used
/// King safety constants and variables. The king safety scores are taken
/// from the array SafetyTable[]. Various little "meta-bonuses" measuring
/// the strength of the attack are added up into an integer, which is used
const int BishopAttackWeight = 2;
const int KnightAttackWeight = 2;
const int BishopAttackWeight = 2;
const int KnightAttackWeight = 2;
- // Bonuses for safe checks for each piece type.
+ // Bonuses for safe checks for each piece type.
int QueenContactCheckBonus = 4;
int RookContactCheckBonus = 2;
int QueenCheckBonus = 2;
int QueenContactCheckBonus = 4;
int RookContactCheckBonus = 2;
int QueenCheckBonus = 2;
void evaluate_trapped_bishop_a1h1(const Position &pos, Square s, Color us,
EvalInfo &ei);
void evaluate_trapped_bishop_a1h1(const Position &pos, Square s, Color us,
EvalInfo &ei);
- Value apply_weight(Value v, int w);
+ inline Value apply_weight(Value v, int w);
Value scale_by_game_phase(Value mv, Value ev, Phase ph, ScaleFactor sf[]);
int count_1s_8bit(Bitboard b);
Value scale_by_game_phase(Value mv, Value ev, Phase ph, ScaleFactor sf[]);
int count_1s_8bit(Bitboard b);
s = pos.knight_list(c, i);
evaluate_knight(pos, s, c, ei);
}
s = pos.knight_list(c, i);
evaluate_knight(pos, s, c, ei);
}
// Bishops
for(int i = 0; i < pos.bishop_count(c); i++) {
s = pos.bishop_list(c, i);
// Bishops
for(int i = 0; i < pos.bishop_count(c); i++) {
s = pos.bishop_list(c, i);
- ei.attackedBy[c][PAWN] | ei.attackedBy[c][KNIGHT]
- | ei.attackedBy[c][BISHOP] | ei.attackedBy[c][ROOK]
+ ei.attackedBy[c][PAWN] | ei.attackedBy[c][KNIGHT]
+ | ei.attackedBy[c][BISHOP] | ei.attackedBy[c][ROOK]
| ei.attackedBy[c][QUEEN] | ei.attackedBy[c][KING];
}
| ei.attackedBy[c][QUEEN] | ei.attackedBy[c][KING];
}
ei.pi->kingside_storm_value(BLACK);
else if(square_file(pos.king_square(WHITE)) <= FILE_D &&
square_file(pos.king_square(BLACK)) >= FILE_E)
ei.pi->kingside_storm_value(BLACK);
else if(square_file(pos.king_square(WHITE)) <= FILE_D &&
square_file(pos.king_square(BLACK)) >= FILE_E)
ei.pi->kingside_storm_value(WHITE) -
ei.pi->queenside_storm_value(BLACK);
}
ei.pi->kingside_storm_value(WHITE) -
ei.pi->queenside_storm_value(BLACK);
}
Value mgValue, egValue;
ScaleFactor factor[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
Phase phase;
Value mgValue, egValue;
ScaleFactor factor[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
Phase phase;
assert(pos.is_ok());
stm = pos.side_to_move();
assert(pos.is_ok());
stm = pos.side_to_move();
return Sign[stm] * value;
}
return Sign[stm] * value;
}
/// init_eval() initializes various tables used by the evaluation function.
/// init_eval() initializes various tables used by the evaluation function.
// evaluate_knight() assigns bonuses and penalties to a knight of a given
// color on a given square.
// evaluate_knight() assigns bonuses and penalties to a knight of a given
// color on a given square.
void evaluate_knight(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
void evaluate_knight(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
Bitboard bb = (b & ei.attackedBy[them][KING]);
if(bb) ei.attacked[us] += count_1s_max_15(bb);
}
Bitboard bb = (b & ei.attackedBy[them][KING]);
if(bb) ei.attacked[us] += count_1s_max_15(bb);
}
// Mobility
int mob = count_1s_max_15(b & ~p.pieces_of_color(us));
ei.mgMobility += Sign[us] * MidgameKnightMobilityBonus[mob];
// Mobility
int mob = count_1s_max_15(b & ~p.pieces_of_color(us));
ei.mgMobility += Sign[us] * MidgameKnightMobilityBonus[mob];
// Knight outposts:
if(p.square_is_weak(s, them)) {
Value v, bonus;
// Knight outposts:
if(p.square_is_weak(s, them)) {
Value v, bonus;
// Initial bonus based on square:
v = bonus = KnightOutpostBonus[relative_square(us, s)];
// Initial bonus based on square:
v = bonus = KnightOutpostBonus[relative_square(us, s)];
// evaluate_bishop() assigns bonuses and penalties to a bishop of a given
// color on a given square.
// evaluate_bishop() assigns bonuses and penalties to a bishop of a given
// color on a given square.
void evaluate_bishop(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
Bitboard b =
bishop_attacks_bb(s, p.occupied_squares() & ~p.queens(us));
void evaluate_bishop(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
Bitboard b =
bishop_attacks_bb(s, p.occupied_squares() & ~p.queens(us));
ei.attackedBy[us][BISHOP] |= b;
// King attack
ei.attackedBy[us][BISHOP] |= b;
// King attack
// Bishop outposts:
if(p.square_is_weak(s, them)) {
Value v, bonus;
// Bishop outposts:
if(p.square_is_weak(s, them)) {
Value v, bonus;
// Initial bonus based on square:
v = bonus = BishopOutpostBonus[relative_square(us, s)];
// Initial bonus based on square:
v = bonus = BishopOutpostBonus[relative_square(us, s)];
ei.mgValue += Sign[us] * bonus;
ei.egValue += Sign[us] * bonus;
ei.mgValue += Sign[us] * bonus;
ei.egValue += Sign[us] * bonus;
// evaluate_rook() assigns bonuses and penalties to a rook of a given
// color on a given square.
// evaluate_rook() assigns bonuses and penalties to a rook of a given
// color on a given square.
void evaluate_rook(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
void evaluate_rook(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
// Open and half-open files:
File f = square_file(s);
if(ei.pi->file_is_half_open(us, f)) {
// Open and half-open files:
File f = square_file(s);
if(ei.pi->file_is_half_open(us, f)) {
// evaluate_queen() assigns bonuses and penalties to a queen of a given
// color on a given square.
// evaluate_queen() assigns bonuses and penalties to a queen of a given
// color on a given square.
void evaluate_queen(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
void evaluate_queen(const Position &p, Square s, Color us, EvalInfo &ei) {
Color them = opposite_color(us);
Bitboard bb = (b & ei.attackedBy[them][KING]);
if(bb) ei.attacked[us] += count_1s_max_15(bb);
}
Bitboard bb = (b & ei.attackedBy[them][KING]);
if(bb) ei.attacked[us] += count_1s_max_15(bb);
}
// Mobility
int mob = count_1s(b & ~p.pieces_of_color(us));
ei.mgMobility += Sign[us] * MidgameQueenMobilityBonus[mob];
// Mobility
int mob = count_1s(b & ~p.pieces_of_color(us));
ei.mgMobility += Sign[us] * MidgameQueenMobilityBonus[mob];
// evaluate_king() assigns bonuses and penalties to a king of a given
// color on a given square.
// evaluate_king() assigns bonuses and penalties to a king of a given
// color on a given square.
void evaluate_king(const Position &p, Square s, Color us, EvalInfo &ei) {
void evaluate_king(const Position &p, Square s, Color us, EvalInfo &ei) {
int shelter = 0, sign = Sign[us];
// King shelter.
int shelter = 0, sign = Sign[us];
// King shelter.
}
// King safety. This is quite complicated, and is almost certainly far
}
// King safety. This is quite complicated, and is almost certainly far
- // from optimally tuned.
+ // from optimally tuned.
Color them = opposite_color(us);
if(p.queen_count(them) >= 1 && ei.attackCount[them] >= 2
&& p.non_pawn_material(them) >= QueenValueMidgame + RookValueMidgame
Color them = opposite_color(us);
if(p.queen_count(them) >= 1 && ei.attackCount[them] >= 2
&& p.non_pawn_material(them) >= QueenValueMidgame + RookValueMidgame
// Is it the attackers turn to move?
bool sente = (them == p.side_to_move());
// Is it the attackers turn to move?
bool sente = (them == p.side_to_move());
// Find the attacked squares around the king which has no defenders
// apart from the king itself:
Bitboard undefended =
// Find the attacked squares around the king which has no defenders
// apart from the king itself:
Bitboard undefended =
// Analyse safe distance checks:
if(QueenCheckBonus > 0 || RookCheckBonus > 0) {
b = p.rook_attacks(s) & ~p.pieces_of_color(them) & ~ei.attacked_by(us);
// Analyse safe distance checks:
if(QueenCheckBonus > 0 || RookCheckBonus > 0) {
b = p.rook_attacks(s) & ~p.pieces_of_color(them) & ~ei.attacked_by(us);
// evaluate_trapped_bishop_a7h7() determines whether a bishop on a7/h7
// (a2/h2 for black) is trapped by enemy pawns, and assigns a penalty
// if it is.
// evaluate_trapped_bishop_a7h7() determines whether a bishop on a7/h7
// (a2/h2 for black) is trapped by enemy pawns, and assigns a penalty
// if it is.
void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
EvalInfo &ei) {
Piece pawn = pawn_of_color(opposite_color(us));
void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
EvalInfo &ei) {
Piece pawn = pawn_of_color(opposite_color(us));
// (a8/h8 for black) is trapped by a friendly pawn on b2/g2 (b7/g7 for
// black), and assigns a penalty if it is. This pattern can obviously
// only occur in Chess960 games.
// (a8/h8 for black) is trapped by a friendly pawn on b2/g2 (b7/g7 for
// black), and assigns a penalty if it is. This pattern can obviously
// only occur in Chess960 games.
void evaluate_trapped_bishop_a1h1(const Position &pos, Square s, Color us,
EvalInfo &ei) {
Piece pawn = pawn_of_color(us);
void evaluate_trapped_bishop_a1h1(const Position &pos, Square s, Color us,
EvalInfo &ei) {
Piece pawn = pawn_of_color(us);
penalty = TrappedBishopA1H1Penalty;
else
penalty = TrappedBishopA1H1Penalty / 2;
penalty = TrappedBishopA1H1Penalty;
else
penalty = TrappedBishopA1H1Penalty / 2;
ei.mgValue -= Sign[us] * penalty;
ei.egValue -= Sign[us] * penalty;
}
ei.mgValue -= Sign[us] * penalty;
ei.egValue -= Sign[us] * penalty;
}
// scale_by_game_phase interpolates between a middle game and an endgame
// score, based on game phase. It also scales the return value by a
// ScaleFactor array.
// scale_by_game_phase interpolates between a middle game and an endgame
// score, based on game phase. It also scales the return value by a
// ScaleFactor array.
Value scale_by_game_phase(Value mv, Value ev, Phase ph, ScaleFactor sf[]) {
assert(mv > -VALUE_INFINITE && mv < VALUE_INFINITE);
assert(ev > -VALUE_INFINITE && ev < VALUE_INFINITE);
Value scale_by_game_phase(Value mv, Value ev, Phase ph, ScaleFactor sf[]) {
assert(mv > -VALUE_INFINITE && mv < VALUE_INFINITE);
assert(ev > -VALUE_INFINITE && ev < VALUE_INFINITE);
// count_1s_8bit() counts the number of nonzero bits in the 8 least
// significant bits of a Bitboard. This function is used by the king
// shield evaluation.
// count_1s_8bit() counts the number of nonzero bits in the 8 least
// significant bits of a Bitboard. This function is used by the king
// shield evaluation.
int count_1s_8bit(Bitboard b) {
return int(BitCount8Bit[b & 0xFF]);
}
int count_1s_8bit(Bitboard b) {
return int(BitCount8Bit[b & 0xFF]);
}
uciWeight = (uciWeight * 0x100) / 100;
return (uciWeight * internalWeight) / 0x100;
}
uciWeight = (uciWeight * 0x100) / 100;
return (uciWeight * internalWeight) / 0x100;
}
// init_safety() initizes the king safety evaluation, based on UCI
// parameters. It is called from read_weights().
// init_safety() initizes the king safety evaluation, based on UCI
// parameters. It is called from read_weights().
void init_safety() {
double a, b;
int maxSlope, peak, i, j;
void init_safety() {
double a, b;
int maxSlope, peak, i, j;
QueenContactCheckBonus = get_option_value_int("Queen Contact Check Bonus");
RookContactCheckBonus = get_option_value_int("Rook Contact Check Bonus");
QueenCheckBonus = get_option_value_int("Queen Check Bonus");
QueenContactCheckBonus = get_option_value_int("Queen Contact Check Bonus");
RookContactCheckBonus = get_option_value_int("Rook Contact Check Bonus");
QueenCheckBonus = get_option_value_int("Queen Check Bonus");
b = get_option_value_int("King Safety X Intercept") * 1.0;
maxSlope = get_option_value_int("King Safety Max Slope");
peak = (get_option_value_int("King Safety Max Value") * 256) / 100;
b = get_option_value_int("King Safety X Intercept") * 1.0;
maxSlope = get_option_value_int("King Safety Max Slope");
peak = (get_option_value_int("King Safety Max Value") * 256) / 100;
for(i = 0; i < 100; i++) {
if(i < b) SafetyTable[i] = Value(0);
else if(get_option_value_string("King Safety Curve") == "Quadratic")
for(i = 0; i < 100; i++) {
if(i < b) SafetyTable[i] = Value(0);
else if(get_option_value_string("King Safety Curve") == "Quadratic")
if(SafetyTable[i] > Value(peak))
SafetyTable[i] = Value(peak);
}
if(SafetyTable[i] > Value(peak))
SafetyTable[i] = Value(peak);
}
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Key KNPKMaterialKey, KKNPMaterialKey;
Key KPKPMaterialKey;
Key KNPKMaterialKey, KKNPMaterialKey;
Key KPKPMaterialKey;
-/// MaterialInfo::init() is called during program initialization. It
+/// MaterialInfo::init() is called during program initialization. It
/// precomputes material hash keys for a few basic endgames, in order
/// to make it easy to recognize such endgames when they occur.
/// precomputes material hash keys for a few basic endgames, in order
/// to make it easy to recognize such endgames when they occur.
/// MaterialInfoTable::get_material_info() takes a position object as input,
/// computes or looks up a MaterialInfo object, and returns a pointer to it.
/// If the material configuration is not already present in the table, it
/// MaterialInfoTable::get_material_info() takes a position object as input,
/// computes or looks up a MaterialInfo object, and returns a pointer to it.
/// If the material configuration is not already present in the table, it
-/// is stored there, so we don't have to recompute everything when the
+/// is stored there, so we don't have to recompute everything when the
/// same material configuration occurs again.
MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
/// same material configuration occurs again.
MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
int index = key & (size - 1);
MaterialInfo *mi = entries + index;
int index = key & (size - 1);
MaterialInfo *mi = entries + index;
- // If mi->key matches the position's material hash key, it means that we
+ // If mi->key matches the position's material hash key, it means that we
// have analysed this material configuration before, and we can simply
// return the information we found the last time instead of recomputing it:
if(mi->key == key)
// have analysed this material configuration before, and we can simply
// return the information we found the last time instead of recomputing it:
if(mi->key == key)
}
// Evaluate the material balance.
}
// Evaluate the material balance.
Color c;
int sign;
Value egValue = Value(0), mgValue = Value(0);
Color c;
int sign;
Value egValue = Value(0), mgValue = Value(0);
for(c = WHITE, sign = 1; c <= BLACK; c++, sign = -sign) {
// No pawns makes it difficult to win, even with a material advantage:
for(c = WHITE, sign = 1; c <= BLACK; c++, sign = -sign) {
// No pawns makes it difficult to win, even with a material advantage:
// Bishop pair:
if(pos.bishop_count(c) >= 2) {
mgValue += sign * BishopPairMidgameBonus;
egValue += sign * BishopPairEndgameBonus;
}
// Bishop pair:
if(pos.bishop_count(c) >= 2) {
mgValue += sign * BishopPairMidgameBonus;
egValue += sign * BishopPairEndgameBonus;
}
- // Knights are stronger when there are many pawns on the board. The
+ // Knights are stronger when there are many pawns on the board. The
// formula is taken from Larry Kaufman's paper "The Evaluation of Material
// formula is taken from Larry Kaufman's paper "The Evaluation of Material
- // Imbalances in Chess":
+ // Imbalances in Chess":
// http://mywebpages.comcast.net/danheisman/Articles/evaluation_of_material_imbalance.htm
mgValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
egValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
// http://mywebpages.comcast.net/danheisman/Articles/evaluation_of_material_imbalance.htm
mgValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
egValue += sign * Value(pos.knight_count(c)*(pos.pawn_count(c)-5)*16);
mgValue -= sign * v;
egValue -= sign * v;
}
mgValue -= sign * v;
egValue -= sign * v;
}
}
mi->mgValue = int16_t(mgValue);
}
mi->mgValue = int16_t(mgValue);
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
- Before using, initialize the state by using init_genrand(seed)
+ Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- 3. The names of its contributors may not be used to endorse or promote
- products derived from this software without specific prior written
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
/* initializes mt[N] with a seed */
static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s)
+static void init_genrand(unsigned long s)
{
mt[0]= s & 0xffffffffUL;
for (mti=1; mti<N; mti++) {
{
mt[0]= s & 0xffffffffUL;
for (mti=1; mti<N; mti++) {
- mt[mti] =
- (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
+ mt[mti] =
+ (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length)
+static void init_by_array(unsigned long init_key[], int key_length)
{
int i, j, k;
init_genrand(19650218UL);
{
int i, j, k;
init_genrand(19650218UL);
if (i>=N) { mt[0] = mt[N-1]; i=1; }
}
if (i>=N) { mt[0] = mt[N-1]; i=1; }
}
- mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
+ mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
}
/* generates a random number on [0,0xffffffff]-interval */
}
/* generates a random number on [0,0xffffffff]-interval */
y = mt[mti++];
/* Tempering */
y = mt[mti++];
/* Tempering */
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
case 'p': this->put_piece(BP, square); file++; break;
case '/': file = FILE_A; rank--; break;
case ' ': break;
case 'p': this->put_piece(BP, square); file++; break;
case '/': file = FILE_A; rank--; break;
case ' ': break;
std::cout << "Error in FEN at character " << i << std::endl;
return;
}
std::cout << "Error in FEN at character " << i << std::endl;
return;
}
else if(fen[i] >= 'A' && fen[i] <= 'H') {
File rookFile, kingFile = FILE_NONE;
for(Square square = SQ_B1; square <= SQ_G1; square++)
else if(fen[i] >= 'A' && fen[i] <= 'H') {
File rookFile, kingFile = FILE_NONE;
for(Square square = SQ_B1; square <= SQ_G1; square++)
- if(this->piece_on(square) == WK)
+ if(this->piece_on(square) == WK)
kingFile = square_file(square);
if(kingFile == FILE_NONE) {
std::cout << "Error in FEN at character " << i << std::endl;
kingFile = square_file(square);
if(kingFile == FILE_NONE) {
std::cout << "Error in FEN at character " << i << std::endl;
else if(fen[i] >= 'a' && fen[i] <= 'h') {
File rookFile, kingFile = FILE_NONE;
for(Square square = SQ_B8; square <= SQ_G8; square++)
else if(fen[i] >= 'a' && fen[i] <= 'h') {
File rookFile, kingFile = FILE_NONE;
for(Square square = SQ_B8; square <= SQ_G8; square++)
- if(this->piece_on(square) == BK)
+ if(this->piece_on(square) == BK)
kingFile = square_file(square);
if(kingFile == FILE_NONE) {
std::cout << "Error in FEN at character " << i << std::endl;
kingFile = square_file(square);
if(kingFile == FILE_NONE) {
std::cout << "Error in FEN at character " << i << std::endl;
for(Square sq = SQ_A1; sq <= SQ_H8; sq++)
castleRightsMask[sq] = ALL_CASTLES;
for(Square sq = SQ_A1; sq <= SQ_H8; sq++)
castleRightsMask[sq] = ALL_CASTLES;
- castleRightsMask[make_square(initialKFile, RANK_1)] ^=
+ castleRightsMask[make_square(initialKFile, RANK_1)] ^=
- castleRightsMask[make_square(initialKFile, RANK_8)] ^=
+ castleRightsMask[make_square(initialKFile, RANK_8)] ^=
(BLACK_OO|BLACK_OOO);
castleRightsMask[make_square(initialKRFile, RANK_1)] ^= WHITE_OO;
castleRightsMask[make_square(initialKRFile, RANK_8)] ^= BLACK_OO;
(BLACK_OO|BLACK_OOO);
castleRightsMask[make_square(initialKRFile, RANK_1)] ^= WHITE_OO;
castleRightsMask[make_square(initialKRFile, RANK_8)] ^= BLACK_OO;
/// the standard output.
void Position::print() const {
/// the standard output.
void Position::print() const {
- char pieceStrings[][8] =
- {"| ? ", "| P ", "| N ", "| B ", "| R ", "| Q ", "| K ", "| ? ",
+ char pieceStrings[][8] =
+ {"| ? ", "| P ", "| N ", "| B ", "| R ", "| Q ", "| K ", "| ? ",
"| ? ", "|=P=", "|=N=", "|=B=", "|=R=", "|=Q=", "|=K="
};
"| ? ", "|=P=", "|=N=", "|=B=", "|=R=", "|=Q=", "|=K="
};
- std::cout << "+---+---+---+---+---+---+---+---+\n";
+ std::cout << "+---+---+---+---+---+---+---+---+\n";
std::cout << this->to_fen() << std::endl;
std::cout << key << std::endl;
}
std::cout << this->to_fen() << std::endl;
std::cout << key << std::endl;
}
dc |= (squares_between(s, ksq) & b2);
}
}
dc |= (squares_between(s, ksq) & b2);
}
}
sliders = this->bishops_and_queens(c);
if(sliders & BishopPseudoAttacks[ksq]) {
b2 = this->bishop_attacks(ksq) & this->pieces_of_color(c);
sliders = this->bishops_and_queens(c);
if(sliders & BishopPseudoAttacks[ksq]) {
b2 = this->bishop_attacks(ksq) & this->pieces_of_color(c);
/// Position::square_is_attacked() checks whether the given side attacks the
/// given square.
/// Position::square_is_attacked() checks whether the given side attacks the
/// given square.
/// Position::find_checkers() computes the checkersBB bitboard, which
/// contains a nonzero bit for each checking piece (0, 1 or 2). It
/// Position::find_checkers() computes the checkersBB bitboard, which
/// contains a nonzero bit for each checking piece (0, 1 or 2). It
-/// Position::move_is_legal() tests whether a pseudo-legal move is legal.
+/// Position::move_is_legal() tests whether a pseudo-legal move is legal.
/// There are two versions of this function: One which takes only a
/// move as input, and one which takes a move and a bitboard of pinned
/// pieces. The latter function is faster, and should always be preferred
/// There are two versions of this function: One which takes only a
/// move as input, and one which takes a move and a bitboard of pinned
/// pieces. The latter function is faster, and should always be preferred
(!(rook_attacks_bb(ksq, b) & this->rooks_and_queens(them)) &&
!(bishop_attacks_bb(ksq, b) & this->bishops_and_queens(them)));
}
(!(rook_attacks_bb(ksq, b) & this->rooks_and_queens(them)) &&
!(bishop_attacks_bb(ksq, b) & this->bishops_and_queens(them)));
}
-
- // If the moving piece is a king, check whether the destination
+
+ // If the moving piece is a king, check whether the destination
// square is attacked by the opponent.
if(from == ksq) return !(this->square_is_attacked(move_to(m), them));
// A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king.
if(!bit_is_set(pinned, from)) return true;
// square is attacked by the opponent.
if(from == ksq) return !(this->square_is_attacked(move_to(m), them));
// A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king.
if(!bit_is_set(pinned, from)) return true;
- if(direction_between_squares(from, ksq) ==
+ if(direction_between_squares(from, ksq) ==
direction_between_squares(move_to(m), ksq))
return true;
direction_between_squares(move_to(m), ksq))
return true;
return true;
// Discovered check?
else if(bit_is_set(dcCandidates, from) &&
return true;
// Discovered check?
else if(bit_is_set(dcCandidates, from) &&
- direction_between_squares(from, ksq) !=
+ direction_between_squares(from, ksq) !=
direction_between_squares(to, ksq))
return true;
// Promotion with check?
direction_between_squares(to, ksq))
return true;
// Promotion with check?
clear_bit(&b, from); clear_bit(&b, capsq); set_bit(&b, to);
return
clear_bit(&b, from); clear_bit(&b, capsq); set_bit(&b, to);
return
- ((rook_attacks_bb(ksq, b) & this->rooks_and_queens(us)) ||
+ ((rook_attacks_bb(ksq, b) & this->rooks_and_queens(us)) ||
(bishop_attacks_bb(ksq, b) & this->bishops_and_queens(us)));
}
return false;
(bishop_attacks_bb(ksq, b) & this->bishops_and_queens(us)));
}
return false;
case KING:
// Discovered check?
if(bit_is_set(dcCandidates, from) &&
case KING:
// Discovered check?
if(bit_is_set(dcCandidates, from) &&
- direction_between_squares(from, ksq) !=
+ direction_between_squares(from, ksq) !=
direction_between_squares(to, ksq))
return true;
// Castling with check?
direction_between_squares(to, ksq))
return true;
// Castling with check?
return bit_is_set(rook_attacks_bb(rto, b), ksq);
}
return bit_is_set(rook_attacks_bb(rto, b), ksq);
}
-/// Position::backup() is called when making a move. All information
+/// Position::backup() is called when making a move. All information
/// necessary to restore the position when the move is later unmade
/// is saved to an UndoInfo object. The function Position::restore
/// does the reverse operation: When one does a backup followed by
/// necessary to restore the position when the move is later unmade
/// is saved to an UndoInfo object. The function Position::restore
/// does the reverse operation: When one does a backup followed by
castleRights &= castleRightsMask[from];
castleRights &= castleRightsMask[to];
key ^= zobCastle[castleRights];
castleRights &= castleRightsMask[from];
castleRights &= castleRightsMask[to];
key ^= zobCastle[castleRights];
// Update checkers bitboard:
checkersBB = EmptyBoardBB;
Square ksq = this->king_square(them);
// Update checkers bitboard:
checkersBB = EmptyBoardBB;
Square ksq = this->king_square(them);
-/// Position::do_promotion_move() is a private method used to make a promotion
-/// move. It is called from the main Position::do_move function. The
+/// Position::do_promotion_move() is a private method used to make a promotion
+/// move. It is called from the main Position::do_move function. The
/// UndoInfo object, which has been initialized in Position::do_move, is
/// used to store the captured piece (if any).
/// UndoInfo object, which has been initialized in Position::do_move, is
/// used to store the captured piece (if any).
assert(this->color_of_piece_on(to) == them || this->square_is_empty(to));
capture = this->type_of_piece_on(to);
assert(this->color_of_piece_on(to) == them || this->square_is_empty(to));
capture = this->type_of_piece_on(to);
if(capture) {
assert(capture != KING);
if(capture) {
assert(capture != KING);
// Update material:
npMaterial[us] += piece_value_midgame(promotion);
// Update material:
npMaterial[us] += piece_value_midgame(promotion);
// Clear the en passant square:
if(epSquare != SQ_NONE) {
key ^= zobEp[epSquare];
// Clear the en passant square:
if(epSquare != SQ_NONE) {
key ^= zobEp[epSquare];
// Reset rule 50 counter:
rule50 = 0;
// Reset rule 50 counter:
rule50 = 0;
// Update checkers BB:
checkersBB = attacks_to(this->king_square(them), us);
}
// Update checkers BB:
checkersBB = attacks_to(this->king_square(them), us);
}
void Position::do_ep_move(Move m) {
Color us, them;
Square from, to, capsq;
void Position::do_ep_move(Move m) {
Color us, them;
Square from, to, capsq;
assert(this->is_ok());
assert(move_is_ok(m));
assert(move_is_ep(m));
assert(this->is_ok());
assert(move_is_ok(m));
assert(move_is_ep(m));
assert(move_is_ok(m));
assert(move_is_castle(m));
assert(move_is_ok(m));
assert(move_is_castle(m));
- // When we have arrived here, some work has already been done by
+ // When we have arrived here, some work has already been done by
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
assert(move_is_ok(m));
assert(move_promotion(m));
assert(move_is_ok(m));
assert(move_promotion(m));
- // When we have arrived here, some work has already been done by
+ // When we have arrived here, some work has already been done by
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
clear_bit(&(byColorBB[us]), to);
clear_bit(&(byTypeBB[promotion]), to);
clear_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
clear_bit(&(byColorBB[us]), to);
clear_bit(&(byTypeBB[promotion]), to);
clear_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
// Insert pawn at source square:
set_bit(&(byColorBB[us]), from);
set_bit(&(byTypeBB[PAWN]), from);
// Insert pawn at source square:
set_bit(&(byColorBB[us]), from);
set_bit(&(byTypeBB[PAWN]), from);
assert(move_is_ok(m));
assert(move_is_ep(m));
assert(move_is_ok(m));
assert(move_is_ep(m));
- // When we have arrived here, some work has already been done by
+ // When we have arrived here, some work has already been done by
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
// Position::undo_move. In particular, the side to move has been switched,
// so the code below is correct.
us = this->side_to_move();
void Position::do_null_move(UndoInfo &u) {
assert(this->is_ok());
assert(!this->is_check());
void Position::do_null_move(UndoInfo &u) {
assert(this->is_ok());
assert(!this->is_check());
// Back up the information necessary to undo the null move to the supplied
// UndoInfo object. In the case of a null move, the only thing we need to
// remember is the last move made and the en passant square.
// Back up the information necessary to undo the null move to the supplied
// UndoInfo object. In the case of a null move, the only thing we need to
// remember is the last move made and the en passant square.
mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
void Position::undo_null_move(const UndoInfo &u) {
assert(this->is_ok());
assert(!this->is_check());
void Position::undo_null_move(const UndoInfo &u) {
assert(this->is_ok());
assert(!this->is_check());
// Restore information from the supplied UndoInfo object:
lastMove = u.lastMove;
epSquare = u.epSquare;
// Restore information from the supplied UndoInfo object:
lastMove = u.lastMove;
epSquare = u.epSquare;
mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
// before beginning the next iteration:
lastCapturingPieceValue = seeValues[pt];
c = opposite_color(c);
// before beginning the next iteration:
lastCapturingPieceValue = seeValues[pt];
c = opposite_color(c);
// Stop after a king capture:
if(pt == KING && (attackers & this->pieces_of_color(c))) {
assert(n < 32);
// Stop after a king capture:
if(pt == KING && (attackers & this->pieces_of_color(c))) {
assert(n < 32);
}
checkersBB = EmptyBoardBB;
}
checkersBB = EmptyBoardBB;
lastMove = MOVE_NONE;
sideToMove = WHITE;
lastMove = MOVE_NONE;
sideToMove = WHITE;
void Position::reset_game_ply() {
gamePly = 0;
}
void Position::reset_game_ply() {
gamePly = 0;
}
/// Position::put_piece() puts a piece on the given square of the board,
/// updating the board array, bitboards, and piece counts.
/// Position::put_piece() puts a piece on the given square of the board,
/// updating the board array, bitboards, and piece counts.
-/// Position::allow_oo() gives the given side the right to castle kingside.
+/// Position::allow_oo() gives the given side the right to castle kingside.
/// Used when setting castling rights during parsing of FEN strings.
void Position::allow_oo(Color c) {
/// Used when setting castling rights during parsing of FEN strings.
void Position::allow_oo(Color c) {
if(this->square_is_occupied(s))
result ^=
zobrist[this->color_of_piece_on(s)][this->type_of_piece_on(s)][s];
if(this->square_is_occupied(s))
result ^=
zobrist[this->color_of_piece_on(s)][this->type_of_piece_on(s)][s];
if(this->ep_square() != SQ_NONE)
result ^= zobEp[this->ep_square()];
result ^= zobCastle[castleRights];
if(this->ep_square() != SQ_NONE)
result ^= zobEp[this->ep_square()];
result ^= zobCastle[castleRights];
-/// Position::compute_pawn_key() computes the hash key of the position. The
-/// hash key is usually updated incrementally as moves are made and unmade,
-/// the compute_pawn_key() function is only used when a new position is set
-/// up, and to verify the correctness of the pawn hash key when running in
+/// Position::compute_pawn_key() computes the hash key of the position. The
+/// hash key is usually updated incrementally as moves are made and unmade,
+/// the compute_pawn_key() function is only used when a new position is set
+/// up, and to verify the correctness of the pawn hash key when running in
/// debug mode.
Key Position::compute_pawn_key() const {
/// debug mode.
Key Position::compute_pawn_key() const {
/// Position::compute_mg_value() and Position::compute_eg_value() compute the
/// incremental scores for the middle game and the endgame. These functions
/// Position::compute_mg_value() and Position::compute_eg_value() compute the
/// incremental scores for the middle game and the endgame. These functions
MOVE_NONE, Depth(0));
return mp.get_next_move() == MOVE_NONE;
}
MOVE_NONE, Depth(0));
return mp.get_next_move() == MOVE_NONE;
}
bool Position::is_draw() const {
// Draw by material?
if(!this->pawns() &&
bool Position::is_draw() const {
// Draw by material?
if(!this->pawns() &&
- this->non_pawn_material(WHITE) + this->non_pawn_material(BLACK)
+ this->non_pawn_material(WHITE) + this->non_pawn_material(BLACK)
<= BishopValueMidgame)
return true;
<= BishopValueMidgame)
return true;
// Draw by the 50 moves rule?
if(rule50 > 100 || (rule50 == 100 && !this->is_check()))
return true;
// Draw by the 50 moves rule?
if(rule50 > 100 || (rule50 == 100 && !this->is_check()))
return true;
for(int i = 2; i < Min(gamePly, rule50); i += 2)
if(history[gamePly - i] == key)
return true;
for(int i = 2; i < Min(gamePly, rule50); i += 2)
if(history[gamePly - i] == key)
return true;
if(this->is_check())
return false;
if(this->is_check())
return false;
// If the input color is not equal to the side to move, do a null move
if(c != stm) this->do_null_move(u1);
// If the input color is not equal to the side to move, do a null move
if(c != stm) this->do_null_move(u1);
for(int j = 0; j < 8; j++)
for(int k = 0; k < 64; k++)
zobrist[i][j][k] = Key(genrand_int64());
for(int j = 0; j < 8; j++)
for(int k = 0; k < 64; k++)
zobrist[i][j][k] = Key(genrand_int64());
for(int i = 0; i < 64; i++)
zobEp[i] = Key(genrand_int64());
for(int i = 0; i < 64; i++)
zobEp[i] = Key(genrand_int64());
for(int i = 0; i < 16; i++)
zobCastle[i] = genrand_int64();
for(int i = 0; i < 16; i++)
zobCastle[i] = genrand_int64();
zobSideToMove = genrand_int64();
zobSideToMove = genrand_int64();
for(int i = 0; i < 2; i++)
for(int j = 0; j < 8; j++)
for(int k = 0; k < 16; k++)
for(int i = 0; i < 2; i++)
for(int j = 0; j < 8; j++)
for(int k = 0; k < 16; k++)
/// Position::is_ok() performs some consitency checks for the position object.
/// This is meant to be helpful when debugging.
/// Position::is_ok() performs some consitency checks for the position object.
/// This is meant to be helpful when debugging.
if(kingCount[0] != 1 || kingCount[1] != 1)
return false;
}
if(kingCount[0] != 1 || kingCount[1] != 1)
return false;
}
// Can the side to move capture the opponent's king?
if(debugKingCapture) {
Color us = this->side_to_move();
// Can the side to move capture the opponent's king?
if(debugKingCapture) {
Color us = this->side_to_move();
// Material hash key OK?
if(debugMaterialKey && materialKey != this->compute_material_key())
return false;
// Material hash key OK?
if(debugMaterialKey && materialKey != this->compute_material_key())
return false;
// Incremental eval OK?
if(debugIncrementalEval) {
if(mgValue != this->compute_mg_value())
// Incremental eval OK?
if(debugIncrementalEval) {
if(mgValue != this->compute_mg_value())
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Glaurung is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Ambiguity move_ambiguity(Position &pos, Move m);
const std::string time_string(int milliseconds);
const std::string score_string(Value v);
Ambiguity move_ambiguity(Position &pos, Move m);
const std::string time_string(int milliseconds);
const std::string score_string(Value v);
Move move_from_san(Position &pos, const std::string &movestr) {
assert(pos.is_ok());
Move move_from_san(Position &pos, const std::string &movestr) {
assert(pos.is_ok());
MovePicker mp = MovePicker(pos, false, MOVE_NONE, MOVE_NONE, MOVE_NONE,
MOVE_NONE, OnePly);
MovePicker mp = MovePicker(pos, false, MOVE_NONE, MOVE_NONE, MOVE_NONE,
MOVE_NONE, OnePly);
int i;
// Initialize str[] by making a copy of movestr with the characters
int i;
// Initialize str[] by making a copy of movestr with the characters
- // 'x', '=', '+' and '#' removed.
+ // 'x', '=', '+' and '#' removed.
cc = str;
for(i=0, c=cstr; i<10 && *c!='\0' && *c!='\n' && *c!=' '; i++, c++)
if(!strchr("x=+#", *c)) {
cc = str;
for(i=0, c=cstr; i<10 && *c!='\0' && *c!='\n' && *c!=' '; i++, c++)
if(!strchr("x=+#", *c)) {
// Look for a matching move:
Move m, move = MOVE_NONE;
int matches = 0;
// Look for a matching move:
Move m, move = MOVE_NONE;
int matches = 0;
while((m = mp.get_next_move()) != MOVE_NONE) {
bool match = true;
if(pos.type_of_piece_on(move_from(m)) != pt)
while((m = mp.get_next_move()) != MOVE_NONE) {
bool match = true;
if(pos.type_of_piece_on(move_from(m)) != pt)
if(matches == 1)
return move;
else
if(matches == 1)
return move;
else
s << hours << ':';
s << std::setw(2) << std::setfill('0') << minutes << ':';
s << std::setw(2) << std::setfill('0') << seconds;
s << hours << ':';
s << std::setw(2) << std::setfill('0') << minutes << ':';
s << std::setw(2) << std::setfill('0') << seconds;
public:
RootMoveList(Position &pos, Move searchMoves[]);
public:
RootMoveList(Position &pos, Move searchMoves[]);
- Move get_move(int moveNum) const;
- Value get_move_score(int moveNum) const;
- void set_move_score(int moveNum, Value score);
- void set_move_nodes(int moveNum, int64_t nodes);
+ inline Move get_move(int moveNum) const;
+ inline Value get_move_score(int moveNum) const;
+ inline void set_move_score(int moveNum, Value score);
+ inline void set_move_nodes(int moveNum, int64_t nodes);
void set_move_pv(int moveNum, const Move pv[]);
void set_move_pv(int moveNum, const Move pv[]);
- Move get_move_pv(int moveNum, int i) const;
- int64_t get_move_cumulative_nodes(int moveNum) const;
- int move_count() const;
+ inline Move get_move_pv(int moveNum, int i) const;
+ inline int64_t get_move_cumulative_nodes(int moveNum) const;
+ inline int move_count() const;
Move scan_for_easy_move() const;
Move scan_for_easy_move() const;
void sort_multipv(int n);
private:
void sort_multipv(int n);
private:
int myTime = time[side_to_move];
int myIncrement = increment[side_to_move];
int oppTime = time[1 - side_to_move];
int myTime = time[side_to_move];
int myIncrement = increment[side_to_move];
int oppTime = time[1 - side_to_move];
TimeAdvantage = myTime - oppTime;
if(!movesToGo) { // Sudden death time control
TimeAdvantage = myTime - oppTime;
if(!movesToGo) { // Sudden death time control
bool overTime = t > AbsoluteMaxSearchTime
|| (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime)
bool overTime = t > AbsoluteMaxSearchTime
|| (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime)
- || ( !FailHigh && !fail_high_ply_1() && !Problem
+ || ( !FailHigh && !fail_high_ply_1() && !Problem
&& t > 6*(MaxSearchTime + ExtraSearchTime));
if ( (Iteration >= 2 && (!InfiniteSearch && overTime))
&& t > 6*(MaxSearchTime + ExtraSearchTime));
if ( (Iteration >= 2 && (!InfiniteSearch && overTime))
- TTEntry* first_entry(const Position &pos) const;
+ inline TTEntry* first_entry(const Position &pos) const;
unsigned size;
int writes;
unsigned size;
int writes;