1
0
Fork 0
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:
Marco Costalba 2010-10-09 13:05:58 +01:00
parent 9ca4359f36
commit 7733dadfd7
10 changed files with 23 additions and 24 deletions

View file

@ -403,7 +403,7 @@ namespace {
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);
}
@ -511,7 +511,7 @@ namespace {
for (int i = 0, index = 0; i < 64; i++)
{
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)
int j = (1 << (64 - shift[i]));

View file

@ -441,7 +441,7 @@ Move Book::get_move(const Position& pos, bool findBestMove) {
if (!bookMove)
return MOVE_NONE;
MoveStack mlist[256];
MoveStack mlist[MOVES_MAX];
MoveStack* last = generate_moves(pos, mlist);
for (MoveStack* cur = mlist; cur != last; cur++)
if ((int(cur->move) & 07777) == bookMove)
@ -515,7 +515,7 @@ uint64_t Book::read_integer(int size) {
read(buf, size);
// 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++)
n = (n << 8) + (unsigned char)buf[i];
@ -531,7 +531,7 @@ namespace {
uint64_t book_key(const Position& pos) {
uint64_t result = 0ULL;
uint64_t result = 0;
for (Color c = WHITE; c <= BLACK; c++)
{
@ -566,7 +566,7 @@ namespace {
uint64_t book_castle_key(const Position& pos) {
uint64_t result = 0ULL;
uint64_t result = 0;
if (pos.can_castle_kingside(WHITE))
result ^= Random64[RandomCastle+0];
@ -585,11 +585,11 @@ namespace {
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) {
return (pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0ULL);
return pos.side_to_move() == WHITE ? Random64[RandomTurn] : 0;
}
}

View file

@ -31,6 +31,8 @@
#include "piece.h"
#include "square.h"
// Maximum number of allowed moves per position
const int MOVES_MAX = 256;
////
//// Types

View file

@ -308,7 +308,7 @@ MoveStack* generate_moves(const Position& pos, MoveStack* mlist, bool pseudoLega
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);
for (cur = mlist; cur != last; cur++)

View file

@ -75,7 +75,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
int searchTT = ttm;
ttMoves[0].move = ttm;
badCaptureThreshold = 0;
badCaptures = moves + 256;
badCaptures = moves + MOVES_MAX;
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
// them in order to get SEE move ordering.
curMove = badCaptures;
lastMove = moves + 256;
lastMove = moves + MOVES_MAX;
return;
case PH_EVASIONS:

View file

@ -66,7 +66,7 @@ private:
int badCaptureThreshold, phase;
const uint8_t* phasePtr;
MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures;
MoveStack moves[256];
MoveStack moves[MOVES_MAX];
};

View file

@ -382,7 +382,7 @@ const string Position::to_fen() const {
/// 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 {
@ -1561,7 +1561,7 @@ void Position::allow_ooo(Color c) {
Key Position::compute_key() const {
Key result = Key(0ULL);
Key result = 0;
for (Square s = SQ_A1; s <= SQ_H8; s++)
if (square_is_occupied(s))
@ -1586,7 +1586,7 @@ Key Position::compute_key() const {
Key Position::compute_pawn_key() const {
Key result = Key(0ULL);
Key result = 0;
Bitboard b;
Square s;
@ -1611,7 +1611,7 @@ Key Position::compute_pawn_key() const {
Key Position::compute_material_key() const {
Key result = Key(0ULL);
Key result = 0;
for (Color c = WHITE; c <= BLACK; c++)
for (PieceType pt = PAWN; pt <= QUEEN; pt++)
{
@ -1703,7 +1703,7 @@ bool Position::is_draw() const {
bool Position::is_mate() const {
MoveStack moves[256];
MoveStack moves[MOVES_MAX];
return is_check() && (generate_moves(*this, moves) == moves);
}
@ -1713,7 +1713,7 @@ bool Position::is_mate() const {
bool Position::has_mate_threat() {
MoveStack mlist[256], *last, *cur;
MoveStack mlist[MOVES_MAX], *last, *cur;
StateInfo st1, st2;
bool mateFound = false;

View file

@ -52,9 +52,6 @@ using std::endl;
namespace {
// Maximum number of allowed moves per position
const int MOVES_MAX = 256;
// Types
enum NodeType { NonPV, PV };
@ -633,7 +630,7 @@ namespace {
// Add some extra time if the best move has changed during the last two iterations
if (Iteration > 5 && Iteration <= 50)
TimeMgr.pv_unstability(BestMoveChangesByIteration[Iteration],
TimeMgr.pv_instability(BestMoveChangesByIteration[Iteration],
BestMoveChangesByIteration[Iteration-1]);
// Stop search if most of MaxSearchTime is consumed at the end of the

View file

@ -88,7 +88,7 @@ namespace {
//// Functions
////
void TimeManager::pv_unstability(int curChanges, int prevChanges) {
void TimeManager::pv_instability(int curChanges, int prevChanges) {
unstablePVExtraTime = curChanges * (optimumSearchTime / 2)
+ prevChanges * (optimumSearchTime / 3);

View file

@ -29,7 +29,7 @@ class TimeManager {
public:
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 maximum_time() const { return maximumSearchTime; }