mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Use 'adjacent' instead of 'neighboring'
It is more correct and specific. Another naming improvement while reading Critter sources. No functional changes. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e1907e349f
commit
3ec94abcdb
5 changed files with 30 additions and 30 deletions
|
@ -40,8 +40,8 @@ Bitboard ClearMaskBB[65];
|
||||||
|
|
||||||
Bitboard FileBB[8];
|
Bitboard FileBB[8];
|
||||||
Bitboard RankBB[8];
|
Bitboard RankBB[8];
|
||||||
Bitboard NeighboringFilesBB[8];
|
Bitboard AdjacentFilesBB[8];
|
||||||
Bitboard ThisAndNeighboringFilesBB[8];
|
Bitboard ThisAndAdjacentFilesBB[8];
|
||||||
Bitboard InFrontBB[2][8];
|
Bitboard InFrontBB[2][8];
|
||||||
Bitboard StepAttacksBB[16][64];
|
Bitboard StepAttacksBB[16][64];
|
||||||
Bitboard BetweenBB[64][64];
|
Bitboard BetweenBB[64][64];
|
||||||
|
@ -173,8 +173,8 @@ void bitboards_init() {
|
||||||
|
|
||||||
for (int f = FILE_A; f <= FILE_H; f++)
|
for (int f = FILE_A; f <= FILE_H; f++)
|
||||||
{
|
{
|
||||||
NeighboringFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
|
AdjacentFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
|
||||||
ThisAndNeighboringFilesBB[f] = FileBB[f] | NeighboringFilesBB[f];
|
ThisAndAdjacentFilesBB[f] = FileBB[f] | AdjacentFilesBB[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int rw = RANK_7, rb = RANK_2; rw >= RANK_1; rw--, rb++)
|
for (int rw = RANK_7, rb = RANK_2; rw >= RANK_1; rw--, rb++)
|
||||||
|
@ -187,8 +187,8 @@ void bitboards_init() {
|
||||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||||
{
|
{
|
||||||
SquaresInFrontMask[c][s] = in_front_bb(c, s) & file_bb(s);
|
SquaresInFrontMask[c][s] = in_front_bb(c, s) & file_bb(s);
|
||||||
PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_neighboring_files_bb(file_of(s));
|
PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_adjacent_files_bb(file_of(s));
|
||||||
AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(file_of(s));
|
AttackSpanMask[c][s] = in_front_bb(c, s) & adjacent_files_bb(file_of(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Square s1 = SQ_A1; s1 <= SQ_H8; s1++)
|
for (Square s1 = SQ_A1; s1 <= SQ_H8; s1++)
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern Bitboard FileBB[8];
|
extern Bitboard FileBB[8];
|
||||||
extern Bitboard NeighboringFilesBB[8];
|
extern Bitboard AdjacentFilesBB[8];
|
||||||
extern Bitboard ThisAndNeighboringFilesBB[8];
|
extern Bitboard ThisAndAdjacentFilesBB[8];
|
||||||
extern Bitboard RankBB[8];
|
extern Bitboard RankBB[8];
|
||||||
extern Bitboard InFrontBB[2][8];
|
extern Bitboard InFrontBB[2][8];
|
||||||
|
|
||||||
|
@ -102,19 +102,19 @@ inline Bitboard file_bb(Square s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// neighboring_files_bb takes a file as input and returns a bitboard representing
|
/// adjacent_files_bb takes a file as input and returns a bitboard representing
|
||||||
/// all squares on the neighboring files.
|
/// all squares on the adjacent files.
|
||||||
|
|
||||||
inline Bitboard neighboring_files_bb(File f) {
|
inline Bitboard adjacent_files_bb(File f) {
|
||||||
return NeighboringFilesBB[f];
|
return AdjacentFilesBB[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// this_and_neighboring_files_bb takes a file as input and returns a bitboard
|
/// this_and_adjacent_files_bb takes a file as input and returns a bitboard
|
||||||
/// representing all squares on the given and neighboring files.
|
/// representing all squares on the given and adjacent files.
|
||||||
|
|
||||||
inline Bitboard this_and_neighboring_files_bb(File f) {
|
inline Bitboard this_and_adjacent_files_bb(File f) {
|
||||||
return ThisAndNeighboringFilesBB[f];
|
return ThisAndAdjacentFilesBB[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ inline Bitboard squares_in_front_of(Color c, Square s) {
|
||||||
/// passed_pawn_mask takes a color and a square as input, and returns a
|
/// passed_pawn_mask takes a color and a square as input, and returns a
|
||||||
/// bitboard mask which can be used to test if a pawn of the given color on
|
/// bitboard mask which can be used to test if a pawn of the given color on
|
||||||
/// the given square is a passed pawn. Definition of the table is:
|
/// the given square is a passed pawn. Definition of the table is:
|
||||||
/// PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_neighboring_files_bb(s)
|
/// PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_adjacent_files_bb(s)
|
||||||
|
|
||||||
inline Bitboard passed_pawn_mask(Color c, Square s) {
|
inline Bitboard passed_pawn_mask(Color c, Square s) {
|
||||||
return PassedPawnMask[c][s];
|
return PassedPawnMask[c][s];
|
||||||
|
@ -207,7 +207,7 @@ inline Bitboard passed_pawn_mask(Color c, Square s) {
|
||||||
/// attack_span_mask takes a color and a square as input, and returns a bitboard
|
/// attack_span_mask takes a color and a square as input, and returns a bitboard
|
||||||
/// representing all squares that can be attacked by a pawn of the given color
|
/// representing all squares that can be attacked by a pawn of the given color
|
||||||
/// when it moves along its file starting from the given square. Definition is:
|
/// when it moves along its file starting from the given square. Definition is:
|
||||||
/// AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
|
/// AttackSpanMask[c][s] = in_front_bb(c, s) & adjacent_files_bb(s);
|
||||||
|
|
||||||
inline Bitboard attack_span_mask(Color c, Square s) {
|
inline Bitboard attack_span_mask(Color c, Square s) {
|
||||||
return AttackSpanMask[c][s];
|
return AttackSpanMask[c][s];
|
||||||
|
|
|
@ -416,7 +416,7 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
|
||||||
&& abs(file_of(kingSq) - pawnFile) <= 1)
|
&& abs(file_of(kingSq) - pawnFile) <= 1)
|
||||||
{
|
{
|
||||||
// The bishop has the wrong color, and the defending king is on the
|
// The bishop has the wrong color, and the defending king is on the
|
||||||
// file of the pawn(s) or the neighboring file. Find the rank of the
|
// file of the pawn(s) or the adjacent file. Find the rank of the
|
||||||
// frontmost pawn.
|
// frontmost pawn.
|
||||||
Rank rank;
|
Rank rank;
|
||||||
if (strongerSide == WHITE)
|
if (strongerSide == WHITE)
|
||||||
|
@ -768,7 +768,7 @@ ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const {
|
||||||
return SCALE_FACTOR_NONE;
|
return SCALE_FACTOR_NONE;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
// Pawns on neighboring files. Draw if defender firmly controls the square
|
// Pawns on adjacent files. Draw if defender firmly controls the square
|
||||||
// in front of the frontmost pawn's path, and the square diagonally behind
|
// in front of the frontmost pawn's path, and the square diagonally behind
|
||||||
// this square on the file of the other pawn.
|
// this square on the file of the other pawn.
|
||||||
if ( ksq == blockSq1
|
if ( ksq == blockSq1
|
||||||
|
|
|
@ -841,7 +841,7 @@ namespace {
|
||||||
|
|
||||||
// Increase the bonus if the passed pawn is supported by a friendly pawn
|
// Increase the bonus if the passed pawn is supported by a friendly pawn
|
||||||
// on the same rank and a bit smaller if it's on the previous rank.
|
// on the same rank and a bit smaller if it's on the previous rank.
|
||||||
supportingPawns = pos.pieces(PAWN, Us) & neighboring_files_bb(file_of(s));
|
supportingPawns = pos.pieces(PAWN, Us) & adjacent_files_bb(file_of(s));
|
||||||
if (supportingPawns & rank_bb(s))
|
if (supportingPawns & rank_bb(s))
|
||||||
ebonus += Value(r * 20);
|
ebonus += Value(r * 20);
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ namespace {
|
||||||
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
|
pliesToGo = 2 * movesToGo - int(loserSide == pos.side_to_move());
|
||||||
|
|
||||||
// Generate list of blocking pawns and supporters
|
// Generate list of blocking pawns and supporters
|
||||||
supporters = neighboring_files_bb(file_of(s)) & candidates;
|
supporters = adjacent_files_bb(file_of(s)) & candidates;
|
||||||
opposed = squares_in_front_of(loserSide, s) & pos.pieces(PAWN, winnerSide);
|
opposed = squares_in_front_of(loserSide, s) & pos.pieces(PAWN, winnerSide);
|
||||||
blockers = passed_pawn_mask(loserSide, s) & pos.pieces(PAWN, winnerSide);
|
blockers = passed_pawn_mask(loserSide, s) & pos.pieces(PAWN, winnerSide);
|
||||||
|
|
||||||
|
|
|
@ -145,22 +145,22 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
|
||||||
passed = !(theirPawns & passed_pawn_mask(Us, s));
|
passed = !(theirPawns & passed_pawn_mask(Us, s));
|
||||||
doubled = ourPawns & squares_in_front_of(Us, s);
|
doubled = ourPawns & squares_in_front_of(Us, s);
|
||||||
opposed = theirPawns & squares_in_front_of(Us, s);
|
opposed = theirPawns & squares_in_front_of(Us, s);
|
||||||
isolated = !(ourPawns & neighboring_files_bb(f));
|
isolated = !(ourPawns & adjacent_files_bb(f));
|
||||||
chain = ourPawns & neighboring_files_bb(f) & b;
|
chain = ourPawns & adjacent_files_bb(f) & b;
|
||||||
|
|
||||||
// Test for backward pawn
|
// Test for backward pawn
|
||||||
backward = false;
|
backward = false;
|
||||||
|
|
||||||
// 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 neighboring 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 can capture an enemy pawn it cannot be backward either.
|
||||||
if ( !(passed | isolated | chain)
|
if ( !(passed | isolated | chain)
|
||||||
&& !(ourPawns & attack_span_mask(Them, s))
|
&& !(ourPawns & attack_span_mask(Them, s))
|
||||||
&& !(pos.attacks_from<PAWN>(s, Us) & theirPawns))
|
&& !(pos.attacks_from<PAWN>(s, Us) & theirPawns))
|
||||||
{
|
{
|
||||||
// We now know that there are no friendly pawns beside or behind this
|
// We now know that there are no friendly pawns beside or behind this
|
||||||
// pawn on neighboring files. We now check whether the pawn is
|
// pawn on adjacent files. We now check whether the pawn is
|
||||||
// backward by looking in the forward direction on the neighboring
|
// backward by looking in the forward direction on the adjacent
|
||||||
// files, and seeing whether we meet a friendly or an enemy pawn first.
|
// files, and seeing whether we meet a friendly or an enemy pawn first.
|
||||||
b = pos.attacks_from<PAWN>(s, Us);
|
b = pos.attacks_from<PAWN>(s, Us);
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
|
||||||
|
|
||||||
// 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 neighboring files is higher or equal than the number of
|
// pawn on adjacent files is higher or equal than the number of
|
||||||
// enemy pawns in the forward direction on the neighboring files.
|
// enemy pawns in the forward direction on the adjacent files.
|
||||||
candidate = !(opposed | passed | backward | isolated)
|
candidate = !(opposed | passed | backward | isolated)
|
||||||
&& (b = attack_span_mask(Them, s + pawn_push(Us)) & ourPawns) != 0
|
&& (b = attack_span_mask(Them, s + pawn_push(Us)) & ourPawns) != 0
|
||||||
&& popcount<Max15>(b) >= popcount<Max15>(attack_span_mask(Us, s) & theirPawns);
|
&& popcount<Max15>(b) >= popcount<Max15>(attack_span_mask(Us, s) & theirPawns);
|
||||||
|
@ -222,7 +222,7 @@ Score PawnInfo::updateShelter(const Position& pos, Square ksq) {
|
||||||
|
|
||||||
if (relative_rank(Us, ksq) <= RANK_4)
|
if (relative_rank(Us, ksq) <= RANK_4)
|
||||||
{
|
{
|
||||||
pawns = pos.pieces(PAWN, Us) & this_and_neighboring_files_bb(file_of(ksq));
|
pawns = pos.pieces(PAWN, Us) & this_and_adjacent_files_bb(file_of(ksq));
|
||||||
r = ksq & (7 << 3);
|
r = ksq & (7 << 3);
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue