mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Small codestyle touches
Mostly suggested by Justin (UncombedCoconut), the 0ULL -> 0 conversion is mine. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9ca4359f36
commit
7733dadfd7
10 changed files with 23 additions and 24 deletions
|
@ -403,7 +403,7 @@ namespace {
|
||||||
AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
|
AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Bitboard b = 0ULL; b < 256ULL; b++)
|
for (Bitboard b = 0; b < 256; b++)
|
||||||
BitCount8Bit[b] = (uint8_t)count_1s<CNT32>(b);
|
BitCount8Bit[b] = (uint8_t)count_1s<CNT32>(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ namespace {
|
||||||
for (int i = 0, index = 0; i < 64; i++)
|
for (int i = 0, index = 0; i < 64; i++)
|
||||||
{
|
{
|
||||||
attackIndex[i] = index;
|
attackIndex[i] = index;
|
||||||
mask[i] = sliding_attacks(i, 0ULL, 4, deltas, 1, 6, 1, 6);
|
mask[i] = sliding_attacks(i, 0, 4, deltas, 1, 6, 1, 6);
|
||||||
|
|
||||||
#if defined(IS_64BIT)
|
#if defined(IS_64BIT)
|
||||||
int j = (1 << (64 - shift[i]));
|
int j = (1 << (64 - shift[i]));
|
||||||
|
|
12
src/book.cpp
12
src/book.cpp
|
@ -441,7 +441,7 @@ Move Book::get_move(const Position& pos, bool findBestMove) {
|
||||||
if (!bookMove)
|
if (!bookMove)
|
||||||
return MOVE_NONE;
|
return MOVE_NONE;
|
||||||
|
|
||||||
MoveStack mlist[256];
|
MoveStack mlist[MOVES_MAX];
|
||||||
MoveStack* last = generate_moves(pos, mlist);
|
MoveStack* last = generate_moves(pos, mlist);
|
||||||
for (MoveStack* cur = mlist; cur != last; cur++)
|
for (MoveStack* cur = mlist; cur != last; cur++)
|
||||||
if ((int(cur->move) & 07777) == bookMove)
|
if ((int(cur->move) & 07777) == bookMove)
|
||||||
|
@ -515,7 +515,7 @@ uint64_t Book::read_integer(int size) {
|
||||||
read(buf, size);
|
read(buf, size);
|
||||||
|
|
||||||
// Numbers are stored on disk as a binary byte stream
|
// Numbers are stored on disk as a binary byte stream
|
||||||
uint64_t n = 0ULL;
|
uint64_t n = 0;
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
n = (n << 8) + (unsigned char)buf[i];
|
n = (n << 8) + (unsigned char)buf[i];
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ namespace {
|
||||||
|
|
||||||
uint64_t book_key(const Position& pos) {
|
uint64_t book_key(const Position& pos) {
|
||||||
|
|
||||||
uint64_t result = 0ULL;
|
uint64_t result = 0;
|
||||||
|
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
{
|
{
|
||||||
|
@ -566,7 +566,7 @@ namespace {
|
||||||
|
|
||||||
uint64_t book_castle_key(const Position& pos) {
|
uint64_t book_castle_key(const Position& pos) {
|
||||||
|
|
||||||
uint64_t result = 0ULL;
|
uint64_t result = 0;
|
||||||
|
|
||||||
if (pos.can_castle_kingside(WHITE))
|
if (pos.can_castle_kingside(WHITE))
|
||||||
result ^= Random64[RandomCastle+0];
|
result ^= Random64[RandomCastle+0];
|
||||||
|
@ -585,11 +585,11 @@ namespace {
|
||||||
|
|
||||||
|
|
||||||
uint64_t book_ep_key(const Position& pos) {
|
uint64_t book_ep_key(const Position& pos) {
|
||||||
return (pos.ep_square() == SQ_NONE ? 0ULL : Random64[RandomEnPassant + square_file(pos.ep_square())]);
|
return pos.ep_square() == SQ_NONE ? 0 : Random64[RandomEnPassant + square_file(pos.ep_square())];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t book_color_key(const Position& pos) {
|
uint64_t book_color_key(const Position& pos) {
|
||||||
return (pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0ULL);
|
return pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "piece.h"
|
#include "piece.h"
|
||||||
#include "square.h"
|
#include "square.h"
|
||||||
|
|
||||||
|
// Maximum number of allowed moves per position
|
||||||
|
const int MOVES_MAX = 256;
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Types
|
//// Types
|
||||||
|
|
|
@ -308,7 +308,7 @@ MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLega
|
||||||
|
|
||||||
bool move_is_legal(const Position& pos, const Move m) {
|
bool move_is_legal(const Position& pos, const Move m) {
|
||||||
|
|
||||||
MoveStack mlist[256];
|
MoveStack mlist[MOVES_MAX];
|
||||||
MoveStack *cur, *last = generate_moves(pos, mlist, true);
|
MoveStack *cur, *last = generate_moves(pos, mlist, true);
|
||||||
|
|
||||||
for (cur = mlist; cur != last; cur++)
|
for (cur = mlist; cur != last; cur++)
|
||||||
|
|
|
@ -75,7 +75,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||||
int searchTT = ttm;
|
int searchTT = ttm;
|
||||||
ttMoves[0].move = ttm;
|
ttMoves[0].move = ttm;
|
||||||
badCaptureThreshold = 0;
|
badCaptureThreshold = 0;
|
||||||
badCaptures = moves + 256;
|
badCaptures = moves + MOVES_MAX;
|
||||||
|
|
||||||
pinned = p.pinned_pieces(pos.side_to_move());
|
pinned = p.pinned_pieces(pos.side_to_move());
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void MovePicker::go_next_phase() {
|
||||||
// Bad captures SEE value is already calculated so just pick
|
// Bad captures SEE value is already calculated so just pick
|
||||||
// them in order to get SEE move ordering.
|
// them in order to get SEE move ordering.
|
||||||
curMove = badCaptures;
|
curMove = badCaptures;
|
||||||
lastMove = moves + 256;
|
lastMove = moves + MOVES_MAX;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case PH_EVASIONS:
|
case PH_EVASIONS:
|
||||||
|
|
|
@ -66,7 +66,7 @@ private:
|
||||||
int badCaptureThreshold, phase;
|
int badCaptureThreshold, phase;
|
||||||
const uint8_t* phasePtr;
|
const uint8_t* phasePtr;
|
||||||
MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures;
|
MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures;
|
||||||
MoveStack moves[256];
|
MoveStack moves[MOVES_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -382,7 +382,7 @@ const string Position::to_fen() const {
|
||||||
|
|
||||||
|
|
||||||
/// Position::print() prints an ASCII representation of the position to
|
/// Position::print() prints an ASCII representation of the position to
|
||||||
/// the standard output. If a move is given then also the san is print.
|
/// the standard output. If a move is given then also the san is printed.
|
||||||
|
|
||||||
void Position::print(Move move) const {
|
void Position::print(Move move) const {
|
||||||
|
|
||||||
|
@ -1561,7 +1561,7 @@ void Position::allow_ooo(Color c) {
|
||||||
|
|
||||||
Key Position::compute_key() const {
|
Key Position::compute_key() const {
|
||||||
|
|
||||||
Key result = Key(0ULL);
|
Key result = 0;
|
||||||
|
|
||||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||||
if (square_is_occupied(s))
|
if (square_is_occupied(s))
|
||||||
|
@ -1586,7 +1586,7 @@ Key Position::compute_key() const {
|
||||||
|
|
||||||
Key Position::compute_pawn_key() const {
|
Key Position::compute_pawn_key() const {
|
||||||
|
|
||||||
Key result = Key(0ULL);
|
Key result = 0;
|
||||||
Bitboard b;
|
Bitboard b;
|
||||||
Square s;
|
Square s;
|
||||||
|
|
||||||
|
@ -1611,7 +1611,7 @@ Key Position::compute_pawn_key() const {
|
||||||
|
|
||||||
Key Position::compute_material_key() const {
|
Key Position::compute_material_key() const {
|
||||||
|
|
||||||
Key result = Key(0ULL);
|
Key result = 0;
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
for (PieceType pt = PAWN; pt <= QUEEN; pt++)
|
for (PieceType pt = PAWN; pt <= QUEEN; pt++)
|
||||||
{
|
{
|
||||||
|
@ -1703,7 +1703,7 @@ bool Position::is_draw() const {
|
||||||
|
|
||||||
bool Position::is_mate() const {
|
bool Position::is_mate() const {
|
||||||
|
|
||||||
MoveStack moves[256];
|
MoveStack moves[MOVES_MAX];
|
||||||
return is_check() && (generate_moves(*this, moves) == moves);
|
return is_check() && (generate_moves(*this, moves) == moves);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1713,7 +1713,7 @@ bool Position::is_mate() const {
|
||||||
|
|
||||||
bool Position::has_mate_threat() {
|
bool Position::has_mate_threat() {
|
||||||
|
|
||||||
MoveStack mlist[256], *last, *cur;
|
MoveStack mlist[MOVES_MAX], *last, *cur;
|
||||||
StateInfo st1, st2;
|
StateInfo st1, st2;
|
||||||
bool mateFound = false;
|
bool mateFound = false;
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,6 @@ using std::endl;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Maximum number of allowed moves per position
|
|
||||||
const int MOVES_MAX = 256;
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
enum NodeType { NonPV, PV };
|
enum NodeType { NonPV, PV };
|
||||||
|
|
||||||
|
@ -633,7 +630,7 @@ namespace {
|
||||||
|
|
||||||
// Add some extra time if the best move has changed during the last two iterations
|
// Add some extra time if the best move has changed during the last two iterations
|
||||||
if (Iteration > 5 && Iteration <= 50)
|
if (Iteration > 5 && Iteration <= 50)
|
||||||
TimeMgr.pv_unstability(BestMoveChangesByIteration[Iteration],
|
TimeMgr.pv_instability(BestMoveChangesByIteration[Iteration],
|
||||||
BestMoveChangesByIteration[Iteration-1]);
|
BestMoveChangesByIteration[Iteration-1]);
|
||||||
|
|
||||||
// Stop search if most of MaxSearchTime is consumed at the end of the
|
// Stop search if most of MaxSearchTime is consumed at the end of the
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace {
|
||||||
//// Functions
|
//// Functions
|
||||||
////
|
////
|
||||||
|
|
||||||
void TimeManager::pv_unstability(int curChanges, int prevChanges) {
|
void TimeManager::pv_instability(int curChanges, int prevChanges) {
|
||||||
|
|
||||||
unstablePVExtraTime = curChanges * (optimumSearchTime / 2)
|
unstablePVExtraTime = curChanges * (optimumSearchTime / 2)
|
||||||
+ prevChanges * (optimumSearchTime / 3);
|
+ prevChanges * (optimumSearchTime / 3);
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TimeManager {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void init(int myTime, int myInc, int movesToGo, int currentPly);
|
void init(int myTime, int myInc, int movesToGo, int currentPly);
|
||||||
void pv_unstability(int curChanges, int prevChanges);
|
void pv_instability(int curChanges, int prevChanges);
|
||||||
int available_time() const { return optimumSearchTime + unstablePVExtraTime; }
|
int available_time() const { return optimumSearchTime + unstablePVExtraTime; }
|
||||||
int maximum_time() const { return maximumSearchTime; }
|
int maximum_time() const { return maximumSearchTime; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue