mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2695 No functional change
This commit is contained in:
parent
bc3c215490
commit
6f15e7fab2
14 changed files with 50 additions and 61 deletions
|
@ -336,7 +336,7 @@ ifeq ($(pext),yes)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
|
### 3.8 Link Time Optimization
|
||||||
### This is a mix of compile and link time options because the lto link phase
|
### This is a mix of compile and link time options because the lto link phase
|
||||||
### needs access to the optimization flags.
|
### needs access to the optimization flags.
|
||||||
ifeq ($(optimize),yes)
|
ifeq ($(optimize),yes)
|
||||||
|
|
|
@ -108,25 +108,25 @@ namespace {
|
||||||
stm = Color ((idx >> 12) & 0x01);
|
stm = Color ((idx >> 12) & 0x01);
|
||||||
psq = make_square(File((idx >> 13) & 0x3), Rank(RANK_7 - ((idx >> 15) & 0x7)));
|
psq = make_square(File((idx >> 13) & 0x3), Rank(RANK_7 - ((idx >> 15) & 0x7)));
|
||||||
|
|
||||||
// Check if two pieces are on the same square or if a king can be captured
|
// Invalid if two pieces are on the same square or if a king can be captured
|
||||||
if ( distance(ksq[WHITE], ksq[BLACK]) <= 1
|
if ( distance(ksq[WHITE], ksq[BLACK]) <= 1
|
||||||
|| ksq[WHITE] == psq
|
|| ksq[WHITE] == psq
|
||||||
|| ksq[BLACK] == psq
|
|| ksq[BLACK] == psq
|
||||||
|| (stm == WHITE && (pawn_attacks_bb(WHITE, psq) & ksq[BLACK])))
|
|| (stm == WHITE && (pawn_attacks_bb(WHITE, psq) & ksq[BLACK])))
|
||||||
result = INVALID;
|
result = INVALID;
|
||||||
|
|
||||||
// Immediate win if a pawn can be promoted without getting captured
|
// Win if the pawn can be promoted without getting captured
|
||||||
else if ( stm == WHITE
|
else if ( stm == WHITE
|
||||||
&& rank_of(psq) == RANK_7
|
&& rank_of(psq) == RANK_7
|
||||||
&& ksq[stm] != psq + NORTH
|
&& ksq[WHITE] != psq + NORTH
|
||||||
&& ( distance(ksq[~stm], psq + NORTH) > 1
|
&& ( distance(ksq[BLACK], psq + NORTH) > 1
|
||||||
|| (attacks_bb<KING>(ksq[stm]) & (psq + NORTH))))
|
|| (distance(ksq[WHITE], psq + NORTH) == 1)))
|
||||||
result = WIN;
|
result = WIN;
|
||||||
|
|
||||||
// Immediate draw if it is a stalemate or a king captures undefended pawn
|
// Draw if it is stalemate or the black king can capture the pawn
|
||||||
else if ( stm == BLACK
|
else if ( stm == BLACK
|
||||||
&& ( !(attacks_bb<KING>(ksq[stm]) & ~(attacks_bb<KING>(ksq[~stm]) | pawn_attacks_bb(~stm, psq)))
|
&& ( !(attacks_bb<KING>(ksq[BLACK]) & ~(attacks_bb<KING>(ksq[WHITE]) | pawn_attacks_bb(WHITE, psq)))
|
||||||
|| (attacks_bb<KING>(ksq[stm]) & psq & ~attacks_bb<KING>(ksq[~stm]))))
|
|| (attacks_bb<KING>(ksq[BLACK]) & ~attacks_bb<KING>(ksq[WHITE]) & psq)))
|
||||||
result = DRAW;
|
result = DRAW;
|
||||||
|
|
||||||
// Position will be classified later
|
// Position will be classified later
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace {
|
||||||
Bitboard RookTable[0x19000]; // To store rook attacks
|
Bitboard RookTable[0x19000]; // To store rook attacks
|
||||||
Bitboard BishopTable[0x1480]; // To store bishop attacks
|
Bitboard BishopTable[0x1480]; // To store bishop attacks
|
||||||
|
|
||||||
void init_magics(Bitboard table[], Magic magics[], Direction directions[]);
|
void init_magics(PieceType pt, Bitboard table[], Magic magics[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,11 +79,8 @@ void Bitboards::init() {
|
||||||
for (Square s2 = SQ_A1; s2 <= SQ_H8; ++s2)
|
for (Square s2 = SQ_A1; s2 <= SQ_H8; ++s2)
|
||||||
SquareDistance[s1][s2] = std::max(distance<File>(s1, s2), distance<Rank>(s1, s2));
|
SquareDistance[s1][s2] = std::max(distance<File>(s1, s2), distance<Rank>(s1, s2));
|
||||||
|
|
||||||
Direction RookDirections[] = { NORTH, EAST, SOUTH, WEST };
|
init_magics(ROOK, RookTable, RookMagics);
|
||||||
Direction BishopDirections[] = { NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST };
|
init_magics(BISHOP, BishopTable, BishopMagics);
|
||||||
|
|
||||||
init_magics(RookTable, RookMagics, RookDirections);
|
|
||||||
init_magics(BishopTable, BishopMagics, BishopDirections);
|
|
||||||
|
|
||||||
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
|
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
|
||||||
{
|
{
|
||||||
|
@ -109,15 +106,17 @@ void Bitboards::init() {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Bitboard sliding_attack(Direction directions[], Square sq, Bitboard occupied) {
|
Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) {
|
||||||
|
|
||||||
Bitboard attacks = 0;
|
Bitboard attacks = 0;
|
||||||
|
Direction RookDirections[4] = {NORTH, SOUTH, EAST, WEST};
|
||||||
|
Direction BishopDirections[4] = {NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST};
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for(Direction d : (pt == ROOK ? RookDirections : BishopDirections))
|
||||||
{
|
{
|
||||||
Square s = sq;
|
Square s = sq;
|
||||||
while(safe_destination(s, directions[i]) && !(occupied & s))
|
while(safe_destination(s, d) && !(occupied & s))
|
||||||
attacks |= (s += directions[i]);
|
attacks |= (s += d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attacks;
|
return attacks;
|
||||||
|
@ -129,7 +128,7 @@ namespace {
|
||||||
// www.chessprogramming.org/Magic_Bitboards. In particular, here we use the so
|
// www.chessprogramming.org/Magic_Bitboards. In particular, here we use the so
|
||||||
// called "fancy" approach.
|
// called "fancy" approach.
|
||||||
|
|
||||||
void init_magics(Bitboard table[], Magic magics[], Direction directions[]) {
|
void init_magics(PieceType pt, Bitboard table[], Magic magics[]) {
|
||||||
|
|
||||||
// Optimal PRNG seeds to pick the correct magics in the shortest time
|
// Optimal PRNG seeds to pick the correct magics in the shortest time
|
||||||
int seeds[][RANK_NB] = { { 8977, 44560, 54343, 38998, 5731, 95205, 104912, 17020 },
|
int seeds[][RANK_NB] = { { 8977, 44560, 54343, 38998, 5731, 95205, 104912, 17020 },
|
||||||
|
@ -149,7 +148,7 @@ namespace {
|
||||||
// the number of 1s of the mask. Hence we deduce the size of the shift to
|
// the number of 1s of the mask. Hence we deduce the size of the shift to
|
||||||
// apply to the 64 or 32 bits word to get the index.
|
// apply to the 64 or 32 bits word to get the index.
|
||||||
Magic& m = magics[s];
|
Magic& m = magics[s];
|
||||||
m.mask = sliding_attack(directions, s, 0) & ~edges;
|
m.mask = sliding_attack(pt, s, 0) & ~edges;
|
||||||
m.shift = (Is64Bit ? 64 : 32) - popcount(m.mask);
|
m.shift = (Is64Bit ? 64 : 32) - popcount(m.mask);
|
||||||
|
|
||||||
// Set the offset for the attacks table of the square. We have individual
|
// Set the offset for the attacks table of the square. We have individual
|
||||||
|
@ -161,7 +160,7 @@ namespace {
|
||||||
b = size = 0;
|
b = size = 0;
|
||||||
do {
|
do {
|
||||||
occupancy[size] = b;
|
occupancy[size] = b;
|
||||||
reference[size] = sliding_attack(directions, s, b);
|
reference[size] = sliding_attack(pt, s, b);
|
||||||
|
|
||||||
if (HasPext)
|
if (HasPext)
|
||||||
m.attacks[pext(b, m.mask)] = reference[size];
|
m.attacks[pext(b, m.mask)] = reference[size];
|
||||||
|
|
|
@ -253,7 +253,7 @@ inline Bitboard pawn_attack_span(Color c, Square s) {
|
||||||
/// the given color and on the given square is a passed pawn.
|
/// the given color and on the given square is a passed pawn.
|
||||||
|
|
||||||
inline Bitboard passed_pawn_span(Color c, Square s) {
|
inline Bitboard passed_pawn_span(Color c, Square s) {
|
||||||
return forward_ranks_bb(c, s) & (adjacent_files_bb(s) | file_bb(s));
|
return pawn_attack_span(c, s) | forward_file_bb(c, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -676,16 +676,15 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Evaluation::space() computes the space evaluation for a given side. The
|
// Evaluation::space() computes a space evaluation for a given side, aiming to improve game
|
||||||
// space evaluation is a simple bonus based on the number of safe squares
|
// play in the opening. It is based on the number of safe squares on the 4 central files
|
||||||
// available for minor pieces on the central four files on ranks 2--4. Safe
|
// on ranks 2 to 4. Completely safe squares behind a friendly pawn are counted twice.
|
||||||
// squares one, two or three squares behind a friendly pawn are counted
|
// Finally, the space bonus is multiplied by a weight which decreases according to occupancy.
|
||||||
// twice. Finally, the space bonus is multiplied by a weight. The aim is to
|
|
||||||
// improve play on game opening.
|
|
||||||
|
|
||||||
template<Tracing T> template<Color Us>
|
template<Tracing T> template<Color Us>
|
||||||
Score Evaluation<T>::space() const {
|
Score Evaluation<T>::space() const {
|
||||||
|
|
||||||
|
// Early exit if, for example, both queens or 6 minor pieces have been exchanged
|
||||||
if (pos.non_pawn_material() < SpaceThreshold)
|
if (pos.non_pawn_material() < SpaceThreshold)
|
||||||
return SCORE_ZERO;
|
return SCORE_ZERO;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace {
|
||||||
|
|
||||||
/// MovePicker constructor for the main search
|
/// MovePicker constructor for the main search
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
||||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, Move* killers, int pl)
|
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, const Move* killers, int pl)
|
||||||
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
||||||
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,9 @@ enum StatsType { NoCaptures, Captures };
|
||||||
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
|
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
|
||||||
typedef Stats<int16_t, 10692, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
|
typedef Stats<int16_t, 10692, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
|
||||||
|
|
||||||
/// LowPlyHistory at higher depths records successful quiet moves on plies 0 to 3
|
/// At higher depths LowPlyHistory records successful quiet moves near the root and quiet
|
||||||
/// and quiet moves which are/were in the PV (ttPv)
|
/// moves which are/were in the PV (ttPv)
|
||||||
/// It get cleared with each new search and get filled during iterative deepening
|
/// It is cleared with each new search and filled during iterative deepening
|
||||||
constexpr int MAX_LPH = 4;
|
constexpr int MAX_LPH = 4;
|
||||||
typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB) * int(SQUARE_NB)> LowPlyHistory;
|
typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB) * int(SQUARE_NB)> LowPlyHistory;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
const CapturePieceToHistory*,
|
const CapturePieceToHistory*,
|
||||||
const PieceToHistory**,
|
const PieceToHistory**,
|
||||||
Move,
|
Move,
|
||||||
Move*,
|
const Move*,
|
||||||
int);
|
int);
|
||||||
Move next_move(bool skipQuiets = false);
|
Move next_move(bool skipQuiets = false);
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ Entry* probe(const Position& pos) {
|
||||||
/// penalty for a king, looking at the king file and the two closest files.
|
/// penalty for a king, looking at the king file and the two closest files.
|
||||||
|
|
||||||
template<Color Us>
|
template<Color Us>
|
||||||
Score Entry::evaluate_shelter(const Position& pos, Square ksq) {
|
Score Entry::evaluate_shelter(const Position& pos, Square ksq) const {
|
||||||
|
|
||||||
constexpr Color Them = ~Us;
|
constexpr Color Them = ~Us;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct Entry {
|
||||||
Score do_king_safety(const Position& pos);
|
Score do_king_safety(const Position& pos);
|
||||||
|
|
||||||
template<Color Us>
|
template<Color Us>
|
||||||
Score evaluate_shelter(const Position& pos, Square ksq);
|
Score evaluate_shelter(const Position& pos, Square ksq) const;
|
||||||
|
|
||||||
Key key;
|
Key key;
|
||||||
Score scores[COLOR_NB];
|
Score scores[COLOR_NB];
|
||||||
|
|
|
@ -106,7 +106,7 @@ Score psq[PIECE_NB][SQUARE_NB];
|
||||||
// tables are initialized by flipping and changing the sign of the white scores.
|
// tables are initialized by flipping and changing the sign of the white scores.
|
||||||
void init() {
|
void init() {
|
||||||
|
|
||||||
for (Piece pc = W_PAWN; pc <= W_KING; ++pc)
|
for (Piece pc : {W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING})
|
||||||
{
|
{
|
||||||
Score score = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
|
Score score = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,7 @@ namespace {
|
||||||
ttPv = PvNode || (ttHit && tte->is_pv());
|
ttPv = PvNode || (ttHit && tte->is_pv());
|
||||||
formerPv = ttPv && !PvNode;
|
formerPv = ttPv && !PvNode;
|
||||||
|
|
||||||
if (ttPv && depth > 12 && ss->ply - 1 < MAX_LPH && !pos.captured_piece() && is_ok((ss-1)->currentMove))
|
if (ttPv && depth > 12 && ss->ply - 1 < MAX_LPH && !priorCapture && is_ok((ss-1)->currentMove))
|
||||||
thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
|
thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
|
||||||
|
|
||||||
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
|
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
|
||||||
|
|
|
@ -1200,7 +1200,7 @@ WDLScore search(Position& pos, ProbeState* result) {
|
||||||
auto moveList = MoveList<LEGAL>(pos);
|
auto moveList = MoveList<LEGAL>(pos);
|
||||||
size_t totalCount = moveList.size(), moveCount = 0;
|
size_t totalCount = moveList.size(), moveCount = 0;
|
||||||
|
|
||||||
for (const Move& move : moveList)
|
for (const Move move : moveList)
|
||||||
{
|
{
|
||||||
if ( !pos.capture(move)
|
if ( !pos.capture(move)
|
||||||
&& (!CheckZeroingMoves || type_of(pos.moved_piece(move)) != PAWN))
|
&& (!CheckZeroingMoves || type_of(pos.moved_piece(move)) != PAWN))
|
||||||
|
@ -1362,7 +1362,7 @@ void Tablebases::init(const std::string& paths) {
|
||||||
LeadPawnsSize[leadPawnsCnt][f] = idx;
|
LeadPawnsSize[leadPawnsCnt][f] = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add entries in TB tables if the corresponding ".rtbw" file exsists
|
// Add entries in TB tables if the corresponding ".rtbw" file exists
|
||||||
for (PieceType p1 = PAWN; p1 < KING; ++p1) {
|
for (PieceType p1 = PAWN; p1 < KING; ++p1) {
|
||||||
TBTables.add({KING, p1, KING});
|
TBTables.add({KING, p1, KING});
|
||||||
|
|
||||||
|
@ -1469,7 +1469,7 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result) {
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
int minDTZ = 0xFFFF;
|
int minDTZ = 0xFFFF;
|
||||||
|
|
||||||
for (const Move& move : MoveList<LEGAL>(pos))
|
for (const Move move : MoveList<LEGAL>(pos))
|
||||||
{
|
{
|
||||||
bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
|
bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
|
||||||
{
|
{
|
||||||
opt_scale = std::min(0.008 + std::pow(ply + 3.0, 0.5) / 250.0,
|
opt_scale = std::min(0.008 + std::pow(ply + 3.0, 0.5) / 250.0,
|
||||||
0.2 * limits.time[us] / double(timeLeft));
|
0.2 * limits.time[us] / double(timeLeft));
|
||||||
max_scale = 4 + std::min(36, ply) / 12.0;
|
max_scale = std::min(7.0, 4.0 + ply / 12.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// x moves in y seconds (+ z increment)
|
// x moves in y seconds (+ z increment)
|
||||||
|
|
17
src/types.h
17
src/types.h
|
@ -40,7 +40,6 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <climits>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -214,7 +213,6 @@ constexpr Value PieceValue[PHASE_NB][PIECE_NB] = {
|
||||||
typedef int Depth;
|
typedef int Depth;
|
||||||
|
|
||||||
enum : int {
|
enum : int {
|
||||||
|
|
||||||
DEPTH_QS_CHECKS = 0,
|
DEPTH_QS_CHECKS = 0,
|
||||||
DEPTH_QS_NO_CHECKS = -1,
|
DEPTH_QS_NO_CHECKS = -1,
|
||||||
DEPTH_QS_RECAPTURES = -5,
|
DEPTH_QS_RECAPTURES = -5,
|
||||||
|
@ -282,11 +280,11 @@ inline Value mg_value(Score s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ENABLE_BASE_OPERATORS_ON(T) \
|
#define ENABLE_BASE_OPERATORS_ON(T) \
|
||||||
constexpr T operator+(T d1, T d2) { return T(int(d1) + int(d2)); } \
|
constexpr T operator+(T d1, int d2) { return T(int(d1) + d2); } \
|
||||||
constexpr T operator-(T d1, T d2) { return T(int(d1) - int(d2)); } \
|
constexpr T operator-(T d1, int d2) { return T(int(d1) - d2); } \
|
||||||
constexpr T operator-(T d) { return T(-int(d)); } \
|
constexpr T operator-(T d) { return T(-int(d)); } \
|
||||||
inline T& operator+=(T& d1, T d2) { return d1 = d1 + d2; } \
|
inline T& operator+=(T& d1, int d2) { return d1 = d1 + d2; } \
|
||||||
inline T& operator-=(T& d1, T d2) { return d1 = d1 - d2; }
|
inline T& operator-=(T& d1, int d2) { return d1 = d1 - d2; }
|
||||||
|
|
||||||
#define ENABLE_INCR_OPERATORS_ON(T) \
|
#define ENABLE_INCR_OPERATORS_ON(T) \
|
||||||
inline T& operator++(T& d) { return d = T(int(d) + 1); } \
|
inline T& operator++(T& d) { return d = T(int(d) + 1); } \
|
||||||
|
@ -305,7 +303,6 @@ ENABLE_FULL_OPERATORS_ON(Value)
|
||||||
ENABLE_FULL_OPERATORS_ON(Direction)
|
ENABLE_FULL_OPERATORS_ON(Direction)
|
||||||
|
|
||||||
ENABLE_INCR_OPERATORS_ON(PieceType)
|
ENABLE_INCR_OPERATORS_ON(PieceType)
|
||||||
ENABLE_INCR_OPERATORS_ON(Piece)
|
|
||||||
ENABLE_INCR_OPERATORS_ON(Square)
|
ENABLE_INCR_OPERATORS_ON(Square)
|
||||||
ENABLE_INCR_OPERATORS_ON(File)
|
ENABLE_INCR_OPERATORS_ON(File)
|
||||||
ENABLE_INCR_OPERATORS_ON(Rank)
|
ENABLE_INCR_OPERATORS_ON(Rank)
|
||||||
|
@ -316,12 +313,6 @@ ENABLE_BASE_OPERATORS_ON(Score)
|
||||||
#undef ENABLE_INCR_OPERATORS_ON
|
#undef ENABLE_INCR_OPERATORS_ON
|
||||||
#undef ENABLE_BASE_OPERATORS_ON
|
#undef ENABLE_BASE_OPERATORS_ON
|
||||||
|
|
||||||
/// Additional operators to add integers to a Value
|
|
||||||
constexpr Value operator+(Value v, int i) { return Value(int(v) + i); }
|
|
||||||
constexpr Value operator-(Value v, int i) { return Value(int(v) - i); }
|
|
||||||
inline Value& operator+=(Value& v, int i) { return v = v + i; }
|
|
||||||
inline Value& operator-=(Value& v, int i) { return v = v - i; }
|
|
||||||
|
|
||||||
/// Additional operators to add a Direction to a Square
|
/// Additional operators to add a Direction to a Square
|
||||||
constexpr Square operator+(Square s, Direction d) { return Square(int(s) + int(d)); }
|
constexpr Square operator+(Square s, Direction d) { return Square(int(s) + int(d)); }
|
||||||
constexpr Square operator-(Square s, Direction d) { return Square(int(s) - int(d)); }
|
constexpr Square operator-(Square s, Direction d) { return Square(int(s) - int(d)); }
|
||||||
|
|
Loading…
Add table
Reference in a new issue