1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Even more spelling fixes

No functional change.
This commit is contained in:
Arjun Temurnikar 2013-12-05 07:18:12 +01:00 committed by Marco Costalba
parent 190aea4cdc
commit 431c3ac485
18 changed files with 109 additions and 113 deletions

View file

@ -33,7 +33,7 @@ enum BitCountType {
}; };
/// Determine at compile time the best popcount<> specialization according to /// Determine at compile time the best popcount<> specialization according to
/// whether the platform is 32 or 64 bits, to the maximum number of non-zero /// whether the platform is 32 or 64 bit, the maximum number of non-zero
/// bits to count and if the hardware popcnt instruction is available. /// bits to count and if the hardware popcnt instruction is available.
const BitCountType Full = HasPopCnt ? CNT_HW_POPCNT : Is64Bit ? CNT_64 : CNT_32; const BitCountType Full = HasPopCnt ? CNT_HW_POPCNT : Is64Bit ? CNT_64 : CNT_32;
const BitCountType Max15 = HasPopCnt ? CNT_HW_POPCNT : Is64Bit ? CNT_64_MAX15 : CNT_32_MAX15; const BitCountType Max15 = HasPopCnt ? CNT_HW_POPCNT : Is64Bit ? CNT_64_MAX15 : CNT_32_MAX15;

View file

@ -35,8 +35,8 @@ using namespace std;
namespace { namespace {
// A Polyglot book is a series of "entries" of 16 bytes. All integers are // A Polyglot book is a series of "entries" of 16 bytes. All integers are
// stored in big-endian format, with highest byte first (regardless of size). // stored in big-endian format, with the highest byte first (regardless of
// The entries are ordered according to the key in ascending order. // size). The entries are ordered according to the key in ascending order.
struct Entry { struct Entry {
uint64_t key; uint64_t key;
uint16_t move; uint16_t move;
@ -410,9 +410,9 @@ Move PolyglotBook::probe(const Position& pos, const string& fName, bool pickBest
best = max(best, e.count); best = max(best, e.count);
sum += e.count; sum += e.count;
// Choose book move according to its score. If a move has a very // Choose book move according to its score. If a move has a very high
// high score it has higher probability to be choosen than a move // score it has a higher probability of being choosen than a move with
// with lower score. Note that first entry is always chosen. // a lower score. Note that first entry is always chosen.
if ( (!pickBest && sum && rkiss.rand<unsigned>() % sum < e.count) if ( (!pickBest && sum && rkiss.rand<unsigned>() % sum < e.count)
|| (pickBest && e.count == best)) || (pickBest && e.count == best))
move = Move(e.move); move = Move(e.move);

View file

@ -80,10 +80,10 @@ namespace {
return sq; return sq;
} }
// Get the material key of a Position out of the given endgame key code // Get the material key of Position out of the given endgame key code
// like "KBPKN". The trick here is to first forge an ad-hoc fen string // like "KBPKN". The trick here is to first forge an ad-hoc FEN string
// and then let a Position object to do the work for us. Note that the // and then let a Position object do the work for us. Note that the
// fen string could correspond to an illegal position. // FEN string could correspond to an illegal position.
Key key(const string& code, Color c) { Key key(const string& code, Color c) {
assert(code.length() > 0 && code.length() < 8); assert(code.length() > 0 && code.length() < 8);
@ -187,8 +187,8 @@ Value Endgame<KBNK>::operator()(const Position& pos) const {
Square loserKSq = pos.king_square(weakSide); Square loserKSq = pos.king_square(weakSide);
Square bishopSq = pos.list<BISHOP>(strongSide)[0]; Square bishopSq = pos.list<BISHOP>(strongSide)[0];
// kbnk_mate_table() tries to drive toward corners A1 or H8, if we have a // kbnk_mate_table() tries to drive toward corners A1 or H8. If we have a
// bishop that cannot reach the above squares we flip the kings in order // bishop that cannot reach the above squares, we flip the kings in order
// to drive the enemy toward corners A8 or H1. // to drive the enemy toward corners A8 or H1.
if (opposite_colors(bishopSq, SQ_A1)) if (opposite_colors(bishopSq, SQ_A1))
{ {
@ -286,7 +286,7 @@ Value Endgame<KRKB>::operator()(const Position& pos) const {
} }
/// KR vs KN. The attacking side has slightly better winning chances than /// KR vs KN. The attacking side has slightly better winning chances than
/// in KR vs KB, particularly if the king and the knight are far apart. /// in KR vs KB, particularly if the king and the knight are far apart.
template<> template<>
Value Endgame<KRKN>::operator()(const Position& pos) const { Value Endgame<KRKN>::operator()(const Position& pos) const {
@ -328,9 +328,8 @@ Value Endgame<KQKP>::operator()(const Position& pos) const {
/// KQ vs KR. This is almost identical to KX vs K: We give the attacking /// KQ vs KR. This is almost identical to KX vs K: We give the attacking
/// king a bonus for having the kings close together, and for forcing the /// king a bonus for having the kings close together, and for forcing the
/// defending king towards the edge. If we also take care to avoid null move /// defending king towards the edge. If we also take care to avoid null move for
/// for the defending side in the search, this is usually sufficient to be /// the defending side in the search, this is usually sufficient to win KQ vs KR.
/// able to win KQ vs KR.
template<> template<>
Value Endgame<KQKR>::operator()(const Position& pos) const { Value Endgame<KQKR>::operator()(const Position& pos) const {
@ -349,7 +348,7 @@ Value Endgame<KQKR>::operator()(const Position& pos) const {
} }
/// KBB vs KN. This is almost always a win. We try to push enemy king to a corner /// KBB vs KN. This is almost always a win. We try to push the enemy king to a corner
/// and away from his knight. For a reference of this difficult endgame see: /// and away from his knight. For a reference of this difficult endgame see:
/// en.wikipedia.org/wiki/Chess_endgame#Effect_of_tablebases_on_endgame_theory /// en.wikipedia.org/wiki/Chess_endgame#Effect_of_tablebases_on_endgame_theory
@ -377,7 +376,7 @@ template<> Value Endgame<KNNK>::operator()(const Position&) const { return VALUE
template<> Value Endgame<KmmKm>::operator()(const Position&) const { return VALUE_DRAW; } template<> Value Endgame<KmmKm>::operator()(const Position&) const { return VALUE_DRAW; }
/// K, bishop and one or more pawns vs K. It checks for draws with rook pawns and /// KB and one or more pawns vs K. It checks for draws with rook pawns and
/// a bishop of the wrong color. If such a draw is detected, SCALE_FACTOR_DRAW /// a bishop of the wrong color. If such a draw is detected, SCALE_FACTOR_DRAW
/// is returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling /// is returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling
/// will be used. /// will be used.
@ -419,7 +418,7 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
Square weakKingSq = pos.king_square(weakSide); Square weakKingSq = pos.king_square(weakSide);
Square bishopSq = pos.list<BISHOP>(strongSide)[0]; Square bishopSq = pos.list<BISHOP>(strongSide)[0];
// There's potential for a draw if our pawn is blocked on the 7th rank // There's potential for a draw if our pawn is blocked on the 7th rank,
// the bishop cannot attack it or they only have one pawn left // the bishop cannot attack it or they only have one pawn left
if ( relative_rank(strongSide, weakPawnSq) == RANK_7 if ( relative_rank(strongSide, weakPawnSq) == RANK_7
&& (pos.pieces(strongSide, PAWN) & (weakPawnSq + pawn_push(weakSide))) && (pos.pieces(strongSide, PAWN) & (weakPawnSq + pawn_push(weakSide)))
@ -445,8 +444,8 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
} }
/// K and queen vs K, rook and one or more pawns. It tests for fortress draws with /// KQ vs KR and one or more pawns. It tests for fortress draws with a rook on
/// a rook on the third rank defended by a pawn. /// the third rank defended by a pawn.
template<> template<>
ScaleFactor Endgame<KQKRPs>::operator()(const Position& pos) const { ScaleFactor Endgame<KQKRPs>::operator()(const Position& pos) const {
@ -469,9 +468,9 @@ ScaleFactor Endgame<KQKRPs>::operator()(const Position& pos) const {
} }
/// K, rook and one pawn vs K and a rook. This function knows a handful of the /// KRP vs KR. This function knows a handful of the most important classes of
/// most important classes of drawn positions, but is far from perfect. It would /// drawn positions, but is far from perfect. It would probably be a good idea
/// probably be a good idea to add more knowledge in the future. /// to add more knowledge in the future.
/// ///
/// It would also be nice to rewrite the actual code for this function, /// It would also be nice to rewrite the actual code for this function,
/// which is mostly copied from Glaurung 1.x, and isn't very pretty. /// which is mostly copied from Glaurung 1.x, and isn't very pretty.
@ -556,7 +555,7 @@ ScaleFactor Endgame<KRPKR>::operator()(const Position& pos) const {
- 8 * square_distance(wpsq, queeningSq) - 8 * square_distance(wpsq, queeningSq)
- 2 * square_distance(wksq, queeningSq)); - 2 * square_distance(wksq, queeningSq));
// If the pawn is not far advanced, and the defending king is somewhere in // If the pawn is not far advanced and the defending king is somewhere in
// the pawn's path, it's probably a draw. // the pawn's path, it's probably a draw.
if (r <= RANK_4 && bksq > wpsq) if (r <= RANK_4 && bksq > wpsq)
{ {
@ -613,9 +612,8 @@ ScaleFactor Endgame<KRPKB>::operator()(const Position& pos) const {
return SCALE_FACTOR_NONE; return SCALE_FACTOR_NONE;
} }
/// K, rook and two pawns vs K, rook and one pawn. There is only a single /// KRPP vs KRP. There is just a single rule: if the stronger side has no passed
/// pattern: If the stronger side has no passed pawns and the defending king /// pawns and the defending king is actively placed, the position is drawish.
/// is actively placed, the position is drawish.
template<> template<>
ScaleFactor Endgame<KRPPKRP>::operator()(const Position& pos) const { ScaleFactor Endgame<KRPPKRP>::operator()(const Position& pos) const {
@ -662,8 +660,8 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
Bitboard pawns = pos.pieces(strongSide, PAWN); Bitboard pawns = pos.pieces(strongSide, PAWN);
Square psq = pos.list<PAWN>(strongSide)[0]; Square psq = pos.list<PAWN>(strongSide)[0];
// If all pawns are ahead of the king, all pawns are on a single // If all pawns are ahead of the king, on a single rook file and
// rook file and the king is within one file of the pawns then draw. // the king is within one file of the pawns, it's a draw.
if ( !(pawns & ~in_front_bb(weakSide, rank_of(ksq))) if ( !(pawns & ~in_front_bb(weakSide, rank_of(ksq)))
&& !((pawns & ~FileABB) && (pawns & ~FileHBB)) && !((pawns & ~FileABB) && (pawns & ~FileHBB))
&& file_distance(ksq, psq) <= 1) && file_distance(ksq, psq) <= 1)
@ -673,10 +671,10 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
} }
/// K, bishop and a pawn vs K and a bishop. There are two rules: If the defending /// KBP vs KB. There are two rules: if the defending king is somewhere along the
/// king is somewhere along the path of the pawn, and the square of the king is /// path of the pawn, and the square of the king is not of the same color as the
/// not of the same color as the stronger side's bishop, it's a draw. If the two /// stronger side's bishop, it's a draw. If the two bishops have opposite color,
/// bishops have opposite color, it's almost always a draw. /// it's almost always a draw.
template<> template<>
ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const { ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const {
@ -726,8 +724,7 @@ ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const {
} }
/// K, bishop and two pawns vs K and bishop. It detects a few basic draws with /// KBPP vs KB. It detects a few basic draws with opposite-colored bishops
/// opposite-colored bishops.
template<> template<>
ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const { ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const {
@ -796,9 +793,9 @@ ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const {
} }
/// K, bisop and a pawn vs K and knight. There is a single rule: If the defending /// KBP vs KN. There is a single rule: If the defending king is somewhere along
/// king is somewhere along the path of the pawn, and the square of the king is /// the path of the pawn, and the square of the king is not of the same color as
/// not of the same color as the stronger side's bishop, it's a draw. /// the stronger side's bishop, it's a draw.
template<> template<>
ScaleFactor Endgame<KBPKN>::operator()(const Position& pos) const { ScaleFactor Endgame<KBPKN>::operator()(const Position& pos) const {
@ -819,9 +816,8 @@ ScaleFactor Endgame<KBPKN>::operator()(const Position& pos) const {
} }
/// K, knight and a pawn vs K. There is a single rule: If the pawn is a rook pawn /// KNP vs K. There is a single rule: if the pawn is a rook pawn on the 7th rank
/// on the 7th rank and the defending king prevents the pawn from advancing, the /// and the defending king prevents the pawn from advancing the position is drawn.
/// position is drawn.
template<> template<>
ScaleFactor Endgame<KNPK>::operator()(const Position& pos) const { ScaleFactor Endgame<KNPK>::operator()(const Position& pos) const {
@ -839,8 +835,8 @@ ScaleFactor Endgame<KNPK>::operator()(const Position& pos) const {
} }
/// K, knight and a pawn vs K and bishop. If knight can block bishop from taking /// KNP vs KB. If knight can block bishop from taking pawn, it's a win.
/// pawn, it's a win. Otherwise, drawn. /// Otherwise the position is drawn.
template<> template<>
ScaleFactor Endgame<KNPKB>::operator()(const Position& pos) const { ScaleFactor Endgame<KNPKB>::operator()(const Position& pos) const {
@ -857,11 +853,11 @@ ScaleFactor Endgame<KNPKB>::operator()(const Position& pos) const {
} }
/// K and a pawn vs K and a pawn. This is done by removing the weakest side's /// KP vs KP. This is done by removing the weakest side's pawn and probing the
/// pawn and probing the KP vs K bitbase: If the weakest side has a draw without /// KP vs K bitbase: If the weakest side has a draw without the pawn, it probably
/// the pawn, she probably has at least a draw with the pawn as well. The exception /// has at least a draw with the pawn as well. The exception is when the stronger
/// is when the stronger side's pawn is far advanced and not on a rook file; in /// side's pawn is far advanced and not on a rook file; in this case it is often
/// this case it is often possible to win (e.g. 8/4k3/3p4/3P4/6K1/8/8/8 w - - 0 1). /// possible to win (e.g. 8/4k3/3p4/3P4/6K1/8/8/8 w - - 0 1).
template<> template<>
ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const { ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const {

View file

@ -49,12 +49,12 @@ enum EndgameType {
// Scaling functions // Scaling functions
SCALE_FUNS, SCALE_FUNS,
KBPsK, // KB+pawns vs K KBPsK, // KB and pawns vs K
KQKRPs, // KQ vs KR+pawns KQKRPs, // KQ vs KR and pawns
KRPKR, // KRP vs KR KRPKR, // KRP vs KR
KRPKB, // KRP vs KB KRPKB, // KRP vs KB
KRPPKRP, // KRPP vs KRP KRPPKRP, // KRPP vs KRP
KPsK, // King and pawns vs king KPsK, // K and pawns vs K
KBPKB, // KBP vs KB KBPKB, // KBP vs KB
KBPPKB, // KBPP vs KB KBPPKB, // KBPP vs KB
KBPKN, // KBP vs KN KBPKN, // KBP vs KN

View file

@ -185,8 +185,8 @@ namespace {
// happen in Chess960 games. // happen in Chess960 games.
const Score TrappedBishopA1H1 = make_score(50, 50); const Score TrappedBishopA1H1 = make_score(50, 50);
// The SpaceMask[Color] contains the area of the board which is considered // SpaceMask[Color] contains the area of the board which is considered
// by the space evaluation. In the middle game, each side is given a bonus // by the space evaluation. In the middlegame, each side is given a bonus
// based on how many squares inside this area are safe and available for // based on how many squares inside this area are safe and available for
// friendly minor pieces. // friendly minor pieces.
const Bitboard SpaceMask[] = { const Bitboard SpaceMask[] = {
@ -195,9 +195,9 @@ namespace {
}; };
// King danger constants and variables. The king danger scores are taken // King danger constants and variables. The king danger scores are taken
// from the KingDanger[]. Various little "meta-bonuses" measuring // from KingDanger[]. Various little "meta-bonuses" measuring the strength
// the strength of the enemy attack are added up into an integer, which // of the enemy attack are added up into an integer, which is used as an
// is used as an index to KingDanger[]. // index to KingDanger[].
// //
// KingAttackWeights[PieceType] contains king attack weights by piece type // KingAttackWeights[PieceType] contains king attack weights by piece type
const int KingAttackWeights[] = { 0, 0, 2, 2, 3, 5 }; const int KingAttackWeights[] = { 0, 0, 2, 2, 3, 5 };
@ -261,7 +261,7 @@ namespace {
namespace Eval { namespace Eval {
/// evaluate() is the main evaluation function. It always computes two /// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates /// values, an endgame score and a middlegame score, and interpolates
/// between them based on the remaining material. /// between them based on the remaining material.
Value evaluate(const Position& pos) { Value evaluate(const Position& pos) {
@ -362,14 +362,14 @@ Value do_evaluate(const Position& pos) {
score += evaluate_unstoppable_pawns(pos, WHITE, ei) score += evaluate_unstoppable_pawns(pos, WHITE, ei)
- evaluate_unstoppable_pawns(pos, BLACK, ei); - evaluate_unstoppable_pawns(pos, BLACK, ei);
// Evaluate space for both sides, only in middle-game. // Evaluate space for both sides, only in middlegame
if (ei.mi->space_weight()) if (ei.mi->space_weight())
{ {
int s = evaluate_space<WHITE>(pos, ei) - evaluate_space<BLACK>(pos, ei); int s = evaluate_space<WHITE>(pos, ei) - evaluate_space<BLACK>(pos, ei);
score += apply_weight(s * ei.mi->space_weight(), Weights[Space]); score += apply_weight(s * ei.mi->space_weight(), Weights[Space]);
} }
// Scale winning side if position is more drawish that what it appears // Scale winning side if position is more drawish than it appears
ScaleFactor sf = eg_value(score) > VALUE_DRAW ? ei.mi->scale_factor(pos, WHITE) ScaleFactor sf = eg_value(score) > VALUE_DRAW ? ei.mi->scale_factor(pos, WHITE)
: ei.mi->scale_factor(pos, BLACK); : ei.mi->scale_factor(pos, BLACK);
@ -380,7 +380,7 @@ Value do_evaluate(const Position& pos) {
&& sf == SCALE_FACTOR_NORMAL) && sf == SCALE_FACTOR_NORMAL)
{ {
// Ignoring any pawns, do both sides only have a single bishop and no // Ignoring any pawns, do both sides only have a single bishop and no
// other pieces ? // other pieces?
if ( pos.non_pawn_material(WHITE) == BishopValueMg if ( pos.non_pawn_material(WHITE) == BishopValueMg
&& pos.non_pawn_material(BLACK) == BishopValueMg) && pos.non_pawn_material(BLACK) == BishopValueMg)
{ {
@ -458,7 +458,7 @@ Value do_evaluate(const Position& pos) {
Value bonus = Outpost[Piece == BISHOP][relative_square(Us, s)]; Value bonus = Outpost[Piece == BISHOP][relative_square(Us, s)];
// Increase bonus if supported by pawn, especially if the opponent has // Increase bonus if supported by pawn, especially if the opponent has
// no minor piece which can exchange the outpost piece. // no minor piece which can trade with the outpost piece.
if (bonus && (ei.attackedBy[Us][PAWN] & s)) if (bonus && (ei.attackedBy[Us][PAWN] & s))
{ {
if ( !pos.pieces(Them, KNIGHT) if ( !pos.pieces(Them, KNIGHT)
@ -891,7 +891,7 @@ Value do_evaluate(const Position& pos) {
if (Trace) if (Trace)
Tracing::scores[Us][PASSED] = apply_weight(score, Weights[PassedPawns]); Tracing::scores[Us][PASSED] = apply_weight(score, Weights[PassedPawns]);
// Add the scores to the middle game and endgame eval // Add the scores to the middlegame and endgame eval
return apply_weight(score, Weights[PassedPawns]); return apply_weight(score, Weights[PassedPawns]);
} }
@ -943,7 +943,7 @@ Value do_evaluate(const Position& pos) {
} }
// interpolate() interpolates between a middle game and an endgame score, // interpolate() interpolates between a middlegame and an endgame score,
// based on game phase. It also scales the return value by a ScaleFactor array. // based on game phase. It also scales the return value by a ScaleFactor array.
Value interpolate(const Score& v, Phase ph, ScaleFactor sf) { Value interpolate(const Score& v, Phase ph, ScaleFactor sf) {

View file

@ -62,7 +62,7 @@ Phase game_phase(const Position& pos);
/// Material::scale_factor takes a position and a color as input, and /// Material::scale_factor takes a position and a color as input, and
/// returns a scale factor for the given color. We have to provide the /// returns a scale factor for the given color. We have to provide the
/// position in addition to the color, because the scale factor need not /// position in addition to the color, because the scale factor need not
/// to be a constant: It can also be a function which should be applied to /// be a constant: It can also be a function which should be applied to
/// the position. For instance, in KBP vs K endgames, a scaling function /// the position. For instance, in KBP vs K endgames, a scaling function
/// which checks for draws with rook pawns and wrong-colored bishops. /// which checks for draws with rook pawns and wrong-colored bishops.

View file

@ -26,8 +26,8 @@
using namespace std; using namespace std;
/// Version number. If Version is left empty, then compile date, in the /// Version number. If Version is left empty, then compile date in the format
/// format DD-MM-YY, is shown in engine_info. /// DD-MM-YY and show in engine_info.
static const string Version = ""; static const string Version = "";
@ -82,7 +82,7 @@ void dbg_print() {
/// Our fancy logging facility. The trick here is to replace cin.rdbuf() and /// Our fancy logging facility. The trick here is to replace cin.rdbuf() and
/// cout.rdbuf() with two Tie objects that tie cin and cout to a file stream. We /// cout.rdbuf() with two Tie objects that tie cin and cout to a file stream. We
/// can toggle the logging of std::cout and std:cin at runtime whilst preserving /// can toggle the logging of std::cout and std:cin at runtime whilst preserving
/// usual i/o functionality and without changing a single line of code! /// usual i/o functionality, all without changing a single line of code!
/// Idea from http://groups.google.com/group/comp.lang.c++/msg/1d941c0f26ea0d81 /// Idea from http://groups.google.com/group/comp.lang.c++/msg/1d941c0f26ea0d81
struct Tie: public streambuf { // MSVC requires splitted streambuf for cin and cout struct Tie: public streambuf { // MSVC requires splitted streambuf for cin and cout

View file

@ -22,7 +22,7 @@
#include "movegen.h" #include "movegen.h"
#include "position.h" #include "position.h"
/// Simple macro to wrap a very common while loop, no facny, no flexibility, /// Simple macro to wrap a very common while loop, no fancy, no flexibility,
/// hardcoded names 'mlist' and 'from'. /// hardcoded names 'mlist' and 'from'.
#define SERIALIZE(b) while (b) (mlist++)->move = make_move(from, pop_lsb(&b)) #define SERIALIZE(b) while (b) (mlist++)->move = make_move(from, pop_lsb(&b))
@ -325,7 +325,7 @@ ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* mlist) {
PieceType pt = type_of(pos.piece_on(from)); PieceType pt = type_of(pos.piece_on(from));
if (pt == PAWN) if (pt == PAWN)
continue; // Will be generated togheter with direct checks continue; // Will be generated together with direct checks
Bitboard b = pos.attacks_from(Piece(pt), from) & ~pos.pieces(); Bitboard b = pos.attacks_from(Piece(pt), from) & ~pos.pieces();

View file

@ -50,7 +50,7 @@ namespace {
} }
// Unary predicate used by std::partition to split positive scores from remaining // Unary predicate used by std::partition to split positive scores from remaining
// ones so to sort separately the two sets, and with the second sort delayed. // ones so as to sort the two sets separately, with the second sort delayed.
inline bool has_positive_score(const ExtMove& ms) { return ms.score > 0; } inline bool has_positive_score(const ExtMove& ms) { return ms.score > 0; }
// Picks the best move in the range (begin, end) and moves it to the front. // Picks the best move in the range (begin, end) and moves it to the front.
@ -65,10 +65,10 @@ namespace {
/// Constructors of the MovePicker class. As arguments we pass information /// Constructors of the MovePicker class. As arguments we pass information
/// to help it to return the presumably good moves first, to decide which /// to help it to return the (presumably) good moves first, to decide which
/// moves to return (in the quiescence search, for instance, we only want to /// moves to return (in the quiescence search, for instance, we only want to
/// search captures, promotions and some checks) and about how important good /// search captures, promotions and some checks) and how important good move
/// move ordering is at the current node. /// ordering is at the current node.
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
Move* cm, Search::Stack* s) : pos(p), history(h), depth(d) { Move* cm, Search::Stack* s) : pos(p), history(h), depth(d) {
@ -286,7 +286,7 @@ void MovePicker::generate_next() {
/// next_move() is the most important method of the MovePicker class. It returns /// next_move() is the most important method of the MovePicker class. It returns
/// a new pseudo legal move every time it is called, until there are no more moves /// a new pseudo legal move every time it is called, until there are no more moves
/// left. It picks the move with the biggest score from a list of generated moves /// left. It picks the move with the biggest score from a list of generated moves
/// taking care not returning the ttMove if has already been searched previously. /// taking care not returning the ttMove if it has already been searched previously.
template<> template<>
Move MovePicker::next_move<false>() { Move MovePicker::next_move<false>() {

View file

@ -124,7 +124,7 @@ namespace {
// Test for backward pawn. // Test for backward pawn.
// If the pawn is passed, isolated, or member of a pawn chain it cannot // If the pawn is passed, isolated, or member of a pawn chain it cannot
// be backward. If there are friendly pawns behind on adjacent files // be backward. If there are friendly pawns behind on adjacent files
// or if can capture an enemy pawn it cannot be backward either. // or if it can capture an enemy pawn it cannot be backward either.
if ( (passed | isolated | chain) if ( (passed | isolated | chain)
|| (ourPawns & pawn_attack_span(Them, s)) || (ourPawns & pawn_attack_span(Them, s))
|| (pos.attacks_from<PAWN>(s, Us) & theirPawns)) || (pos.attacks_from<PAWN>(s, Us) & theirPawns))
@ -145,9 +145,9 @@ namespace {
assert(opposed | passed | (pawn_attack_span(Us, s) & theirPawns)); assert(opposed | passed | (pawn_attack_span(Us, s) & theirPawns));
// A not passed pawn is a candidate to become passed, if it is free to // A not-passed pawn is a candidate to become passed, if it is free to
// advance and if the number of friendly pawns beside or behind this // advance and if the number of friendly pawns beside or behind this
// pawn on adjacent files is higher or equal than the number of // pawn on adjacent files is higher than or equal to the number of
// enemy pawns in the forward direction on the adjacent files. // enemy pawns in the forward direction on the adjacent files.
candidate = !(opposed | passed | backward | isolated) candidate = !(opposed | passed | backward | isolated)
&& (b = pawn_attack_span(Them, s + pawn_push(Us)) & ourPawns) != 0 && (b = pawn_attack_span(Them, s + pawn_push(Us)) & ourPawns) != 0

View file

@ -27,7 +27,7 @@
namespace Pawns { namespace Pawns {
/// Pawns::Entry contains various information about a pawn structure. Currently, /// Pawns::Entry contains various information about a pawn structure. Currently,
/// it only includes a middle game and end game pawn structure evaluation, and a /// it only includes a middlegame and endgame pawn structure evaluation, and a
/// bitboard of passed pawns. We may want to add further information in the future. /// bitboard of passed pawns. We may want to add further information in the future.
/// A lookup to the pawn hash table (performed by calling the probe function) /// A lookup to the pawn hash table (performed by calling the probe function)
/// returns a pointer to an Entry object. /// returns a pointer to an Entry object.

View file

@ -515,7 +515,7 @@ bool Position::pseudo_legal(const Move m) const {
if (promotion_type(m) - 2 != NO_PIECE_TYPE) if (promotion_type(m) - 2 != NO_PIECE_TYPE)
return false; return false;
// If the from square is not occupied by a piece belonging to the side to // If the 'from' square is not occupied by a piece belonging to the side to
// move, the move is obviously not legal. // move, the move is obviously not legal.
if (pc == NO_PIECE || color_of(pc) != us) if (pc == NO_PIECE || color_of(pc) != us)
return false; return false;
@ -604,8 +604,8 @@ bool Position::pseudo_legal(const Move m) const {
if (!((between_bb(lsb(checkers()), king_square(us)) | checkers()) & to)) if (!((between_bb(lsb(checkers()), king_square(us)) | checkers()) & to))
return false; return false;
} }
// In case of king moves under check we have to remove king so to catch // In case of king moves under check we have to remove king so as to catch
// as invalid moves like b1a1 when opposite queen is on c1. // invalid moves like b1a1 when opposite queen is on c1.
else if (attackers_to(to, pieces() ^ from) & pieces(~us)) else if (attackers_to(to, pieces() ^ from) & pieces(~us))
return false; return false;
} }
@ -626,17 +626,17 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
Square to = to_sq(m); Square to = to_sq(m);
PieceType pt = type_of(piece_on(from)); PieceType pt = type_of(piece_on(from));
// Is there a direct check ? // Is there a direct check?
if (ci.checkSq[pt] & to) if (ci.checkSq[pt] & to)
return true; return true;
// Is there a discovered check ? // Is there a discovered check?
if ( unlikely(ci.dcCandidates) if ( unlikely(ci.dcCandidates)
&& (ci.dcCandidates & from) && (ci.dcCandidates & from)
&& !aligned(from, to, king_square(~sideToMove))) && !aligned(from, to, king_square(~sideToMove)))
return true; return true;
// Can we skip the ugly special cases ? // Can we skip the ugly special cases?
if (type_of(m) == NORMAL) if (type_of(m) == NORMAL)
return false; return false;
@ -648,7 +648,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
case PROMOTION: case PROMOTION:
return attacks_bb(Piece(promotion_type(m)), to, pieces() ^ from) & ksq; return attacks_bb(Piece(promotion_type(m)), to, pieces() ^ from) & ksq;
// En passant capture with check ? We have already handled the case // En passant capture with check? We have already handled the case
// of direct checks and ordinary discovered check, so the only case we // of direct checks and ordinary discovered check, so the only case we
// need to handle is the unusual case of a discovered check through // need to handle is the unusual case of a discovered check through
// the captured pawn. // the captured pawn.
@ -695,9 +695,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
++nodes; ++nodes;
Key k = st->key; Key k = st->key;
// Copy some fields of old state to our new StateInfo object except the ones // Copy some fields of the old state to our new StateInfo object except the
// which are going to be recalculated from scratch anyway, then switch our state // ones which are going to be recalculated from scratch anyway and then switch
// pointer to point to the new (ready to be updated) state. // our state pointer to point to the new (ready to be updated) state.
std::memcpy(&newSt, st, StateCopySize64 * sizeof(uint64_t)); std::memcpy(&newSt, st, StateCopySize64 * sizeof(uint64_t));
newSt.previous = st; newSt.previous = st;
@ -706,7 +706,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
// Update side to move // Update side to move
k ^= Zobrist::side; k ^= Zobrist::side;
// Increment ply counters.In particular rule50 will be reset to zero later on // Increment ply counters. In particular, rule50 will be reset to zero later on
// in case of a capture or a pawn move. // in case of a capture or a pawn move.
++gamePly; ++gamePly;
++st->rule50; ++st->rule50;
@ -1097,7 +1097,7 @@ int Position::see(Move m, int asymmThreshold) const {
} while (stmAttackers); } while (stmAttackers);
// If we are doing asymmetric SEE evaluation and the same side does the first // If we are doing asymmetric SEE evaluation and the same side does the first
// and the last capture, he loses a tempo and gain must be at least worth // and the last capture, it loses a tempo and gain must be at least worth
// 'asymmThreshold', otherwise we replace the score with a very low value, // 'asymmThreshold', otherwise we replace the score with a very low value,
// before negamaxing. // before negamaxing.
if (asymmThreshold) if (asymmThreshold)
@ -1193,9 +1193,9 @@ Key Position::compute_material_key() const {
} }
/// Position::compute_psq_score() computes the incremental scores for the middle /// Position::compute_psq_score() computes the incremental scores for the middlegame
/// game and the endgame. These functions are used to initialize the incremental /// and the endgame. These functions are used to initialize the incremental scores
/// scores when a new position is set up, and to verify that the scores are correctly /// when a new position is set up, and to verify that the scores are correctly
/// updated by do_move and undo_move when the program is running in debug mode. /// updated by do_move and undo_move when the program is running in debug mode.
Score Position::compute_psq_score() const { Score Position::compute_psq_score() const {
@ -1213,10 +1213,10 @@ Score Position::compute_psq_score() const {
} }
/// Position::compute_non_pawn_material() computes the total non-pawn middle /// Position::compute_non_pawn_material() computes the total non-pawn middlegame
/// game material value for the given side. Material values are updated /// material value for the given side. Material values are updated incrementally
/// incrementally during the search. This function is only used when /// during the search. This function is only used when initializing a new Position
/// initializing a new Position object. /// object.
Value Position::compute_non_pawn_material(Color c) const { Value Position::compute_non_pawn_material(Color c) const {

View file

@ -26,7 +26,7 @@
/// PSQT[PieceType][Square] contains Piece-Square scores. For each piece type on /// PSQT[PieceType][Square] contains Piece-Square scores. For each piece type on
/// a given square a (midgame, endgame) score pair is assigned. PSQT is defined /// a given square a (middlegame, endgame) score pair is assigned. PSQT is defined
/// for the white side and the tables are symmetric for the black side. /// for the white side and the tables are symmetric for the black side.
static const Score PSQT[][SQUARE_NB] = { static const Score PSQT[][SQUARE_NB] = {

View file

@ -229,7 +229,7 @@ void Search::think() {
<< std::endl; << std::endl;
} }
// Reset the threads, still sleeping: will be wake up at split time // Reset the threads, still sleeping: will wake up at split time
for (size_t i = 0; i < Threads.size(); ++i) for (size_t i = 0; i < Threads.size(); ++i)
Threads[i]->maxPly = 0; Threads[i]->maxPly = 0;
@ -348,9 +348,9 @@ namespace {
// Bring the best move to the front. It is critical that sorting // Bring the best move to the front. It is critical that sorting
// is done with a stable algorithm because all the values but the // is done with a stable algorithm because all the values but the
// first and eventually the new best one are set to -VALUE_INFINITE // first and eventually the new best one are set to -VALUE_INFINITE
// and we want to keep the same order for all the moves but the new // and we want to keep the same order for all the moves except the
// PV that goes to the front. Note that in case of MultiPV search // new PV that goes to the front. Note that in case of MultiPV
// the already searched PV lines are preserved. // search the already searched PV lines are preserved.
std::stable_sort(RootMoves.begin() + PVIdx, RootMoves.end()); std::stable_sort(RootMoves.begin() + PVIdx, RootMoves.end());
// Write PV back to transposition table in case the relevant // Write PV back to transposition table in case the relevant
@ -776,7 +776,7 @@ moves_loop: // When in check and at SpNode search starts from here
continue; continue;
// At root obey the "searchmoves" option and skip moves not listed in Root // At root obey the "searchmoves" option and skip moves not listed in Root
// Move List, as a consequence any illegal move is also skipped. In MultiPV // Move List. As a consequence any illegal move is also skipped. In MultiPV
// mode we also skip PV moves which have been already searched. // mode we also skip PV moves which have been already searched.
if (RootNode && !std::count(RootMoves.begin() + PVIdx, RootMoves.end(), move)) if (RootNode && !std::count(RootMoves.begin() + PVIdx, RootMoves.end(), move))
continue; continue;
@ -907,7 +907,7 @@ moves_loop: // When in check and at SpNode search starts from here
// Step 14. Make the move // Step 14. Make the move
pos.do_move(move, st, ci, givesCheck); pos.do_move(move, st, ci, givesCheck);
// Step 15. Reduced depth search (LMR). If the move fails high will be // Step 15. Reduced depth search (LMR). If the move fails high it will be
// re-searched at full depth. // re-searched at full depth.
if ( depth >= 3 * ONE_PLY if ( depth >= 3 * ONE_PLY
&& !pvMove && !pvMove
@ -1401,7 +1401,7 @@ moves_loop: // When in check and at SpNode search starts from here
Bitboard xray = (attacks_bb< ROOK>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, ROOK)) Bitboard xray = (attacks_bb< ROOK>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, ROOK))
| (attacks_bb<BISHOP>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, BISHOP)); | (attacks_bb<BISHOP>(m2to, occ) & pos.pieces(color_of(pc), QUEEN, BISHOP));
// Verify attackers are triggered by our move and not already exist // Verify attackers are triggered by our move and not already existing
if (unlikely(xray) && (xray & ~pos.attacks_from<QUEEN>(m2to))) if (unlikely(xray) && (xray & ~pos.attacks_from<QUEEN>(m2to)))
return true; return true;
} }

View file

@ -73,7 +73,7 @@ struct RootMove {
/// The LimitsType struct stores information sent by GUI about available time /// The LimitsType struct stores information sent by GUI about available time
/// to search the current move, maximum depth/time, if we are in analysis mode /// to search the current move, maximum depth/time, if we are in analysis mode
/// or if we have to ponder while is our opponent's side to move. /// or if we have to ponder while it's our opponent's turn to move.
struct LimitsType { struct LimitsType {

View file

@ -91,7 +91,7 @@ Thread::Thread() /* : splitPoints() */ { // Value-initialization bug in MSVC
// TimerThread::idle_loop() is where the timer thread waits msec milliseconds // TimerThread::idle_loop() is where the timer thread waits msec milliseconds
// and then calls check_time(). If msec is 0 thread sleeps until is woken up. // and then calls check_time(). If msec is 0 thread sleeps until it's woken up.
extern void check_time(); extern void check_time();
void TimerThread::idle_loop() { void TimerThread::idle_loop() {
@ -169,7 +169,7 @@ bool Thread::available_to(const Thread* master) const {
if (searching) if (searching)
return false; return false;
// Make a local copy to be sure doesn't become zero under our feet while // Make a local copy to be sure it doesn't become zero under our feet while
// testing next condition and so leading to an out of bounds access. // testing next condition and so leading to an out of bounds access.
int size = splitPointsSize; int size = splitPointsSize;

View file

@ -236,10 +236,10 @@ enum Rank {
}; };
/// The Score enum stores a midgame and an endgame value in a single integer /// The Score enum stores a middlegame and an endgame value in a single integer
/// (enum). The least significant 16 bits are used to store the endgame value /// (enum). The least significant 16 bits are used to store the endgame value
/// and the upper 16 bits are used to store the midgame value. The compiler is /// and the upper 16 bits are used to store the middlegame value. The compiler
/// free to choose the enum type as long as it can store the data, so we /// is free to choose the enum type as long as it can store the data, so we
/// ensure that Score is an integer type by assigning some big int values. /// ensure that Score is an integer type by assigning some big int values.
enum Score { enum Score {
SCORE_ZERO, SCORE_ZERO,

View file

@ -129,7 +129,7 @@ void UCI::loop(const string& args) {
namespace { namespace {
// position() is called when engine receives the "position" UCI command. // position() is called when engine receives the "position" UCI command.
// The function sets up the position described in the given fen string ("fen") // The function sets up the position described in the given FEN string ("fen")
// or the starting position ("startpos") and then makes the moves given in the // or the starting position ("startpos") and then makes the moves given in the
// following move list ("moves"). // following move list ("moves").