mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Reduce
This commit is contained in:
parent
aefabaa70f
commit
81498ecce4
3 changed files with 6 additions and 36 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "bitboard.h"
|
||||
|
||||
Bitboard FileBB[8];
|
||||
Bitboard AdjacentFilesBB[8];
|
||||
Bitboard A[8];
|
||||
Bitboard B[8];
|
||||
Bitboard C;
|
||||
|
||||
/// Bitboards::init() initializes various bitboard tables. It is called at
|
||||
|
@ -10,11 +10,11 @@ Bitboard C;
|
|||
void Bitboards::init() {
|
||||
|
||||
for (int f = 0; f <= 7; ++f)
|
||||
FileBB[f] = f > 0 ? FileBB[f - 1] << 1 : 0x01010101;
|
||||
A[f] = f > 0 ? A[f - 1] << 1 : 0x01010101;
|
||||
|
||||
for (int f = 0; f <= 7; ++f)
|
||||
AdjacentFilesBB[f] = (f > 0 ? FileBB[f - 1] : 0) | (f < 7 ? FileBB[f + 1] : 0);
|
||||
B[f] = (f > 0 ? A[f - 1] : 0) | (f < 7 ? A[f + 1] : 0);
|
||||
|
||||
C = AdjacentFilesBB[7];
|
||||
C = B[7];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,36 +5,6 @@
|
|||
|
||||
typedef uint64_t Bitboard;
|
||||
|
||||
enum File {
|
||||
FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H, FILE_NB
|
||||
};
|
||||
|
||||
#define ENABLE_BASE_OPERATORS_ON(T) \
|
||||
inline T operator+(T d1, T d2) { return T(int(d1) + int(d2)); } \
|
||||
inline T operator-(T d1, T d2) { return T(int(d1) - int(d2)); } \
|
||||
inline T operator*(int i, T d) { return T(i * int(d)); } \
|
||||
inline T operator*(T d, int i) { return T(int(d) * i); } \
|
||||
inline T operator-(T d) { return T(-int(d)); } \
|
||||
inline T& operator+=(T& d1, T d2) { return d1 = d1 + d2; } \
|
||||
inline T& operator-=(T& d1, T d2) { return d1 = d1 - d2; } \
|
||||
inline T& operator*=(T& d, int i) { return d = T(int(d) * i); }
|
||||
|
||||
#define ENABLE_FULL_OPERATORS_ON(T) \
|
||||
ENABLE_BASE_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); } \
|
||||
inline T operator/(T d, int i) { return T(int(d) / i); } \
|
||||
inline int operator/(T d1, T d2) { return int(d1) / int(d2); } \
|
||||
inline T& operator/=(T& d, int i) { return d = T(int(d) / i); }
|
||||
|
||||
ENABLE_FULL_OPERATORS_ON(File)
|
||||
|
||||
namespace Bitboards { void init(); }
|
||||
|
||||
extern Bitboard AdjacentFilesBB[FILE_NB];
|
||||
|
||||
inline Bitboard adjacent_files_bb(File f) {
|
||||
return AdjacentFilesBB[f];
|
||||
}
|
||||
|
||||
#endif // #ifndef BITBOARD_H_INCLUDED
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "bitboard.h"
|
||||
namespace Bitboards { void init(); }
|
||||
int main() { Bitboards::init(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue