working move gen
This commit is contained in:
@ -13,3 +13,4 @@ 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);
|
||||
struct gameState_t newGameState(uint_least64_t *board, char *FEN);
|
||||
|
||||
31
include/chess/move.h
Normal file
31
include/chess/move.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef CHESS_MOVE_H
|
||||
#define CHESS_MOVE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <chess/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAX_VALID_MOVES 218
|
||||
|
||||
enum spezialMoves {
|
||||
EN_PASSANT = 1,
|
||||
FUTURE_EN_PASSANT,
|
||||
SHORT_CASTLE,
|
||||
LONG_CASTLE,
|
||||
};
|
||||
|
||||
struct move_t {
|
||||
uint_least8_t src, dst, spezialMove;
|
||||
uint_least8_t srcPiece, dstPiece, capturedPiece;
|
||||
};
|
||||
|
||||
void genDirectionConsts();
|
||||
uint_least8_t validMoves(struct gameState_t gameState, bool color, struct move_t *moves);
|
||||
uint_least8_t pieceValidMoves(struct gameState_t gameState, struct piece_t piece, uint_least8_t src,
|
||||
struct move_t *moves, bool promotion);
|
||||
|
||||
struct gameState_t makeMove(struct gameState_t gameState, struct move_t move);
|
||||
struct gameState_t computerMove(struct gameState_t gameState);
|
||||
void initMagicTable();
|
||||
|
||||
#endif
|
||||
@ -8,6 +8,7 @@
|
||||
#define TOTAL_BOARD_SIZE (BOARD_SIZE * BOARD_SIZE)
|
||||
#define LENGTH(array) (sizeof array / sizeof *array)
|
||||
#define NOT_SELECTED UINT_LEAST8_MAX
|
||||
#define BITBOARD_LENGTH 2 * PIECES_LENGTH
|
||||
|
||||
enum pieces {
|
||||
ALL_PIECES,
|
||||
@ -46,4 +47,18 @@ struct magic_t {
|
||||
uint_least8_t shift;
|
||||
};
|
||||
|
||||
struct castle_t {
|
||||
bool shortCastle, longCastle;
|
||||
};
|
||||
|
||||
struct gameState_t {
|
||||
uint_least64_t *board;
|
||||
bool color; // color to move
|
||||
struct castle_t canCastle[2];
|
||||
|
||||
// The number of halfmoves since the last capture or pawn advance, used for the fifty-move rule.
|
||||
uint_least8_t halfMoveCounter;
|
||||
uint_least8_t enPassantTo; // index of the destination for a possible en passant capture
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user