Code: Select all
Quote:
Chan Rasjid wrote:
My bitboard basics are these. If anyone sees anything silly, please let me know.
Code:
#define RANK_1 (u64)0xff
//bitboard.h ...
enum {
A8, B8, C8, D8, E8, F8, G8, H8,
A7, B7, C7, D7, E7, F7, G7, H7,
A6, B6, C6, D6, E6, F6, G6, H6,
A5, B5, C5, D5, E5, F5, G5, H5,
A4, B4, C4, D4, E4, F4, G4, H4,
A3, B3, C3, D3, E3, F3, G3, H3,
A2, B2, C2, D2, E2, F2, G2, H2,
A1, B1, C1, D1, E1, F1, G1, H1
};
#define Rank1 (RANK_1)
#define Rank2 (RANK_1 << 8)
#define Rank3 (RANK_1 << 16)
#define Rank4 (RANK_1 << 24)
#define Rank5 (RANK_1 << 32)
#define Rank6 (RANK_1 << 40)
#define Rank7 (RANK_1 << 48)
#define Rank8 (RANK_1 << 56)
Wrong. Your RANK_1 constant maps to A8...H8 rank.
Should be correct. I use RANK1, RANK2 ... RANK8 and not 0 - 7.
#define RANK(sq) ((sq) >> 3)
#define FILE(sq) ((sq) & 3)
The comment "Should be correct. I use RANK1, RANK2 ... RANK8 and not 0 - 7." should be ignored as it is confusing. There is no RANK1, RANK2,...
There are no RANK(sq) or RANK1 definitions in the posted above code. Your macros RANK_1, Rank1 is a source of bug.
Everything in C is a likely source of bugs to me as I simply don't understand C concepts well. Macros can be source of bugs but it seems using #define for constants should be very safe - they just are transformed to C constant expressions on preprocessing. But I may miss something. I need
#define RANK_1 (u64)0xff
because MSVC++ does not accept the suffix ULL which is needed by GCC.
There is a way to introduce bugs. We use conditional compilation to switch evaluation factors on/off :-
in ev.h :-
#define ENABLE_KING_SAFETY 1
in ev.c:-
#if ENABLE_KING_SAFETY
etc...
#endif
and if we have plenty of these in evaluation codes which are changed often, we are in trouble. So I now do this with cut_and_paste:-
#if defined(ENABLE_KING_SAFETY)
#if ENABLE_KING_SAFETY
etc...
#endif
#else
printf("Warning...")
#endif
Rasjid