gen magic Number
This commit is contained in:
15
include/chess/bitboard.h
Normal file
15
include/chess/bitboard.h
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <chess/types.h>
|
||||
|
||||
bool bitsetGet(uint_least64_t bitset, uint_least8_t i);
|
||||
uint_least64_t bitsetClear(uint_least64_t bitset, uint_least8_t i);
|
||||
uint_least64_t bitsetSet(uint_least64_t bitset, uint_least8_t i);
|
||||
bool bitboardGet(const uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
||||
uint_least64_t bitboardGetMask(const uint_least64_t *board, struct piece_t piece);
|
||||
void bitboardSetMask(uint_least64_t *board, struct piece_t piece, uint_least64_t value);
|
||||
bool bitboardGetAllPieces(const uint_least64_t *board, uint_least8_t i);
|
||||
uint_least64_t bitboardMaskAllPieces(const uint_least64_t *board);
|
||||
void bitboardClear(uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
||||
void bitboardSet(uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
||||
struct piece_t pieceAtField(const uint_least64_t *board, uint_least8_t i);
|
||||
25
include/chess/print.h
Normal file
25
include/chess/print.h
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define fprintArray(file, printer, arr) \
|
||||
do { \
|
||||
fprintf(file, "{"); \
|
||||
for(size_t i = 0; i < LENGTH(arr); ++i) { \
|
||||
printer(file, arr[i]); \
|
||||
if (i < LENGTH(arr) - 1) { \
|
||||
fprintf(file, ", "); \
|
||||
} \
|
||||
} \
|
||||
fprintf(file, " }"); \
|
||||
} while(0)
|
||||
|
||||
#define fdefineArray(file, declaration, printer, arr) \
|
||||
do { \
|
||||
fprintf(file, "%s[%zu] = ", declaration, LENGTH(arr)); \
|
||||
fprintArray(file, printer, arr); \
|
||||
fprintf(file, ";\n"); \
|
||||
} while(0)
|
||||
|
||||
#define defineArray(declaration, printer, arr) fdefineArray(stdout, declaration, printer, arr)
|
||||
|
||||
void printerll(FILE *file, long long num);
|
||||
void printerull(FILE *file, unsigned long long num);
|
||||
@ -34,4 +34,16 @@ enum directions {
|
||||
NORTH, NORTHWEST, WEST, SOUTHWEST, SOUTH, SOUTHEAST, EAST, NORTHEAST, DIRECTION_LENGTH
|
||||
};
|
||||
|
||||
struct moveDst_t {
|
||||
uint_least8_t length;
|
||||
uint_least8_t dst[8];
|
||||
};
|
||||
|
||||
struct magic_t {
|
||||
uint_least64_t *attackTable;
|
||||
uint_least64_t mask; // mask for relvant squares
|
||||
uint_least64_t magicNumber;
|
||||
uint_least8_t shift;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user