Skip to content

Commit fbb5352

Browse files
hximglinscott
authored andcommitted
Rename some variables for more clarity.
No functional change. Resolves #131
1 parent ba14647 commit fbb5352

File tree

14 files changed

+161
-161
lines changed

14 files changed

+161
-161
lines changed

src/bitboard.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
#include "bitcount.h"
2525
#include "rkiss.h"
2626

27-
Bitboard RMasks[SQUARE_NB];
28-
Bitboard RMagics[SQUARE_NB];
29-
Bitboard* RAttacks[SQUARE_NB];
30-
unsigned RShifts[SQUARE_NB];
27+
Bitboard RookMasks[SQUARE_NB];
28+
Bitboard RookMagics[SQUARE_NB];
29+
Bitboard* RookAttacks[SQUARE_NB];
30+
unsigned RookShifts[SQUARE_NB];
3131

32-
Bitboard BMasks[SQUARE_NB];
33-
Bitboard BMagics[SQUARE_NB];
34-
Bitboard* BAttacks[SQUARE_NB];
35-
unsigned BShifts[SQUARE_NB];
32+
Bitboard BishopMasks[SQUARE_NB];
33+
Bitboard BishopMagics[SQUARE_NB];
34+
Bitboard* BishopAttacks[SQUARE_NB];
35+
unsigned BishopShifts[SQUARE_NB];
3636

3737
Bitboard SquareBB[SQUARE_NB];
3838
Bitboard FileBB[FILE_NB];
@@ -58,8 +58,8 @@ namespace {
5858

5959
int MS1BTable[256];
6060
Square BSFTable[SQUARE_NB];
61-
Bitboard RTable[0x19000]; // Storage space for rook attacks
62-
Bitboard BTable[0x1480]; // Storage space for bishop attacks
61+
Bitboard RookTable[0x19000]; // Storage space for rook attacks
62+
Bitboard BishopTable[0x1480]; // Storage space for bishop attacks
6363

6464
typedef unsigned (Fn)(Square, Bitboard);
6565

@@ -195,11 +195,11 @@ void Bitboards::init() {
195195
StepAttacksBB[make_piece(c, pt)][s] |= to;
196196
}
197197

198-
Square RDeltas[] = { DELTA_N, DELTA_E, DELTA_S, DELTA_W };
199-
Square BDeltas[] = { DELTA_NE, DELTA_SE, DELTA_SW, DELTA_NW };
198+
Square RookDeltas[] = { DELTA_N, DELTA_E, DELTA_S, DELTA_W };
199+
Square BishopDeltas[] = { DELTA_NE, DELTA_SE, DELTA_SW, DELTA_NW };
200200

201-
init_magics(RTable, RAttacks, RMagics, RMasks, RShifts, RDeltas, magic_index<ROOK>);
202-
init_magics(BTable, BAttacks, BMagics, BMasks, BShifts, BDeltas, magic_index<BISHOP>);
201+
init_magics(RookTable, RookAttacks, RookMagics, RookMasks, RookShifts, RookDeltas, magic_index<ROOK>);
202+
init_magics(BishopTable, BishopAttacks, BishopMagics, BishopMasks, BishopShifts, BishopDeltas, magic_index<BISHOP>);
203203

204204
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
205205
{

src/bitboard.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ const Bitboard Rank6BB = Rank1BB << (8 * 5);
5757
const Bitboard Rank7BB = Rank1BB << (8 * 6);
5858
const Bitboard Rank8BB = Rank1BB << (8 * 7);
5959

60-
extern Bitboard RMasks[SQUARE_NB];
61-
extern Bitboard RMagics[SQUARE_NB];
62-
extern Bitboard* RAttacks[SQUARE_NB];
63-
extern unsigned RShifts[SQUARE_NB];
60+
extern Bitboard RookMasks[SQUARE_NB];
61+
extern Bitboard RookMagics[SQUARE_NB];
62+
extern Bitboard* RookAttacks[SQUARE_NB];
63+
extern unsigned RookShifts[SQUARE_NB];
6464

65-
extern Bitboard BMasks[SQUARE_NB];
66-
extern Bitboard BMagics[SQUARE_NB];
67-
extern Bitboard* BAttacks[SQUARE_NB];
68-
extern unsigned BShifts[SQUARE_NB];
65+
extern Bitboard BishopMasks[SQUARE_NB];
66+
extern Bitboard BishopMagics[SQUARE_NB];
67+
extern Bitboard* BishopAttacks[SQUARE_NB];
68+
extern unsigned BishopShifts[SQUARE_NB];
6969

7070
extern Bitboard SquareBB[SQUARE_NB];
7171
extern Bitboard FileBB[FILE_NB];
@@ -230,35 +230,35 @@ inline bool aligned(Square s1, Square s2, Square s3) {
230230
/// a square and a bitboard of occupied squares as input, and returns a bitboard
231231
/// representing all squares attacked by Pt (bishop or rook) on the given square.
232232
template<PieceType Pt>
233-
FORCE_INLINE unsigned magic_index(Square s, Bitboard occ) {
233+
FORCE_INLINE unsigned magic_index(Square s, Bitboard occupied) {
234234

235-
Bitboard* const Masks = Pt == ROOK ? RMasks : BMasks;
236-
Bitboard* const Magics = Pt == ROOK ? RMagics : BMagics;
237-
unsigned* const Shifts = Pt == ROOK ? RShifts : BShifts;
235+
Bitboard* const Masks = Pt == ROOK ? RookMasks : BishopMasks;
236+
Bitboard* const Magics = Pt == ROOK ? RookMagics : BishopMagics;
237+
unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts;
238238

239239
if (HasPext)
240-
return unsigned(_pext_u64(occ, Masks[s]));
240+
return unsigned(_pext_u64(occupied, Masks[s]));
241241

242242
if (Is64Bit)
243-
return unsigned(((occ & Masks[s]) * Magics[s]) >> Shifts[s]);
243+
return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]);
244244

245-
unsigned lo = unsigned(occ) & unsigned(Masks[s]);
246-
unsigned hi = unsigned(occ >> 32) & unsigned(Masks[s] >> 32);
245+
unsigned lo = unsigned(occupied) & unsigned(Masks[s]);
246+
unsigned hi = unsigned(occupied >> 32) & unsigned(Masks[s] >> 32);
247247
return (lo * unsigned(Magics[s]) ^ hi * unsigned(Magics[s] >> 32)) >> Shifts[s];
248248
}
249249

250250
template<PieceType Pt>
251-
inline Bitboard attacks_bb(Square s, Bitboard occ) {
252-
return (Pt == ROOK ? RAttacks : BAttacks)[s][magic_index<Pt>(s, occ)];
251+
inline Bitboard attacks_bb(Square s, Bitboard occupied) {
252+
return (Pt == ROOK ? RookAttacks : BishopAttacks)[s][magic_index<Pt>(s, occupied)];
253253
}
254254

255-
inline Bitboard attacks_bb(Piece pc, Square s, Bitboard occ) {
255+
inline Bitboard attacks_bb(Piece pc, Square s, Bitboard occupied) {
256256

257257
switch (type_of(pc))
258258
{
259-
case BISHOP: return attacks_bb<BISHOP>(s, occ);
260-
case ROOK : return attacks_bb<ROOK>(s, occ);
261-
case QUEEN : return attacks_bb<BISHOP>(s, occ) | attacks_bb<ROOK>(s, occ);
259+
case BISHOP: return attacks_bb<BISHOP>(s, occupied);
260+
case ROOK : return attacks_bb<ROOK>(s, occupied);
261+
case QUEEN : return attacks_bb<BISHOP>(s, occupied) | attacks_bb<ROOK>(s, occupied);
262262
default : return StepAttacksBB[pc][s];
263263
}
264264
}

src/endgame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ namespace {
6060
const int PushAway [8] = { 0, 5, 20, 40, 60, 80, 90, 100 };
6161

6262
#ifndef NDEBUG
63-
bool verify_material(const Position& pos, Color c, Value npm, int num_pawns) {
64-
return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == num_pawns;
63+
bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) {
64+
return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == pawnsCnt;
6565
}
6666
#endif
6767

src/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace Time {
4646
template<class Entry, int Size>
4747
struct HashTable {
4848
HashTable() : table(Size, Entry()) {}
49-
Entry* operator[](Key k) { return &table[(uint32_t)k & (Size - 1)]; }
49+
Entry* operator[](Key key) { return &table[(uint32_t)key & (Size - 1)]; }
5050

5151
private:
5252
std::vector<Entry> table;

0 commit comments

Comments
 (0)