repetition table

This commit is contained in:
2024-09-23 21:51:22 +02:00
parent 6c5ef0586f
commit 2c3d1bc021
6 changed files with 71 additions and 48 deletions

View File

@ -25,7 +25,7 @@ uint_least8_t validMoves(struct gameState_t gameState, 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);
void undoMove(uint_least64_t *board, struct move_t move, bool color);
void undoMove(struct gameState_t gameState, struct move_t move, bool color);
struct gameState_t makeMove(struct gameState_t gameState, const struct move_t move);
void initMagicTable();
bool kingInCheck(const uint_least64_t *board, const bool color);

View File

@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#define BOARD_SIZE 8
#define TOTAL_BOARD_SIZE (BOARD_SIZE * BOARD_SIZE)
@ -35,6 +36,16 @@ enum directions {
NORTH, NORTHWEST, WEST, SOUTHWEST, SOUTH, SOUTHEAST, EAST, NORTHEAST, DIRECTION_LENGTH
};
struct zobristTableElement {
uint_least64_t hash;
int_least16_t value;
};
struct zobristTable {
struct zobristTableElement *arr;
size_t length;
};
struct moveDst_t {
uint_least8_t length;
uint_least8_t dst[8];
@ -54,7 +65,7 @@ struct castle_t {
struct gameState_t {
uint_least64_t *board;
uint_least64_t zobrist;
uint_least8_t *repetitionTable;
struct zobristTable repetitionTable;
bool color; // color to move
struct castle_t canCastle[2];

View File

@ -1,24 +1,18 @@
#ifndef CHESS_UTIL_H
#define CHESS_UTIL_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <chess/types.h>
struct zobristTableElement {
uint_least64_t hash;
int_least16_t value;
};
struct zobristTable {
struct zobristTableElement *arr;
size_t length;
};
struct zobristTableResult {
bool success;
int_least16_t value;
};
uint_least64_t rand_64();
uint_least64_t zobristPieceI(struct piece_t piece, uint_least8_t field);
uint_least8_t getFile(const uint_least8_t field);
uint_least8_t getRank(const uint_least8_t field);
struct zobristTable initZobirstTable(size_t length);
void zobristTableIter(const struct zobristTable table, const uint_least64_t key, void *result,
void (*foreach)(struct zobristTableElement *element, const uint_least64_t key, void *result));
#endif