mirror of
https://github.com/sockspls/badfish
synced 2025-05-03 01:59:36 +00:00
syzygy clean-up + unit test
This commit is contained in:
parent
ee7a68ea5f
commit
9173d29c41
4 changed files with 4181 additions and 1897 deletions
2016
src/syzygy/syzygy.epd
Normal file
2016
src/syzygy/syzygy.epd
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -5,30 +5,20 @@
|
||||||
#ifndef TBCORE_H
|
#ifndef TBCORE_H
|
||||||
#define TBCORE_H
|
#define TBCORE_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pthread.h>
|
|
||||||
#define SEP_CHAR ':'
|
#define SEP_CHAR ':'
|
||||||
#define FD int
|
#define FD int
|
||||||
#define FD_ERR -1
|
#define FD_ERR -1
|
||||||
#else
|
#else
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define SEP_CHAR ';'
|
#define SEP_CHAR ';'
|
||||||
#define FD HANDLE
|
#define FD HANDLE
|
||||||
#define FD_ERR INVALID_HANDLE_VALUE
|
#define FD_ERR INVALID_HANDLE_VALUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#define LOCK_T pthread_mutex_t
|
|
||||||
#define LOCK_INIT(x) pthread_mutex_init(&(x), NULL)
|
|
||||||
#define LOCK(x) pthread_mutex_lock(&(x))
|
|
||||||
#define UNLOCK(x) pthread_mutex_unlock(&(x))
|
|
||||||
#else
|
|
||||||
#define LOCK_T HANDLE
|
|
||||||
#define LOCK_INIT(x) do { x = CreateMutex(NULL, FALSE, NULL); } while (0)
|
|
||||||
#define LOCK(x) WaitForSingleObject(x, INFINITE)
|
|
||||||
#define UNLOCK(x) ReleaseMutex(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define BSWAP32(v) __builtin_bswap32(v)
|
#define BSWAP32(v) __builtin_bswap32(v)
|
||||||
#define BSWAP64(v) __builtin_bswap64(v)
|
#define BSWAP64(v) __builtin_bswap64(v)
|
||||||
|
@ -43,41 +33,36 @@
|
||||||
#define DTZDIR "RTBZDIR"
|
#define DTZDIR "RTBZDIR"
|
||||||
#define TBPIECES 6
|
#define TBPIECES 6
|
||||||
|
|
||||||
typedef unsigned long long uint64;
|
const uint8_t WDL_MAGIC[4] = { 0x71, 0xe8, 0x23, 0x5d };
|
||||||
typedef unsigned int uint32;
|
const uint8_t DTZ_MAGIC[4] = { 0xd7, 0x66, 0x0c, 0xa5 };
|
||||||
typedef unsigned char ubyte;
|
|
||||||
typedef unsigned short ushort;
|
|
||||||
|
|
||||||
const ubyte WDL_MAGIC[4] = { 0x71, 0xe8, 0x23, 0x5d };
|
|
||||||
const ubyte DTZ_MAGIC[4] = { 0xd7, 0x66, 0x0c, 0xa5 };
|
|
||||||
|
|
||||||
#define TBHASHBITS 10
|
#define TBHASHBITS 10
|
||||||
|
|
||||||
struct TBHashEntry;
|
struct TBHashEntry;
|
||||||
|
|
||||||
typedef uint64 base_t;
|
typedef uint64_t base_t;
|
||||||
|
|
||||||
struct PairsData {
|
struct PairsData {
|
||||||
char *indextable;
|
char *indextable;
|
||||||
ushort *sizetable;
|
uint16_t *sizetable;
|
||||||
ubyte *data;
|
uint8_t *data;
|
||||||
ushort *offset;
|
uint16_t *offset;
|
||||||
ubyte *symlen;
|
uint8_t *symlen;
|
||||||
ubyte *sympat;
|
uint8_t *sympat;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
int idxbits;
|
int idxbits;
|
||||||
int min_len;
|
int min_len;
|
||||||
base_t base[1]; // C++ complains about base[]...
|
base_t base[1]; // C++ complains about base[]...
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TBEntry {
|
struct TBEntry {
|
||||||
char *data;
|
char *data;
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
uint64 mapping;
|
uint64_t mapping;
|
||||||
ubyte ready;
|
uint8_t ready;
|
||||||
ubyte num;
|
uint8_t num;
|
||||||
ubyte symmetric;
|
uint8_t symmetric;
|
||||||
ubyte has_pawns;
|
uint8_t has_pawns;
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
__attribute__((__may_alias__))
|
__attribute__((__may_alias__))
|
||||||
|
@ -85,84 +70,84 @@ __attribute__((__may_alias__))
|
||||||
;
|
;
|
||||||
|
|
||||||
struct TBEntry_piece {
|
struct TBEntry_piece {
|
||||||
char *data;
|
char *data;
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
uint64 mapping;
|
uint64_t mapping;
|
||||||
ubyte ready;
|
uint8_t ready;
|
||||||
ubyte num;
|
uint8_t num;
|
||||||
ubyte symmetric;
|
uint8_t symmetric;
|
||||||
ubyte has_pawns;
|
uint8_t has_pawns;
|
||||||
ubyte enc_type;
|
uint8_t enc_type;
|
||||||
struct PairsData *precomp[2];
|
struct PairsData *precomp[2];
|
||||||
int factor[2][TBPIECES];
|
int factor[2][TBPIECES];
|
||||||
ubyte pieces[2][TBPIECES];
|
uint8_t pieces[2][TBPIECES];
|
||||||
ubyte norm[2][TBPIECES];
|
uint8_t norm[2][TBPIECES];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TBEntry_pawn {
|
struct TBEntry_pawn {
|
||||||
char *data;
|
char *data;
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
uint64 mapping;
|
uint64_t mapping;
|
||||||
ubyte ready;
|
uint8_t ready;
|
||||||
ubyte num;
|
uint8_t num;
|
||||||
ubyte symmetric;
|
uint8_t symmetric;
|
||||||
ubyte has_pawns;
|
uint8_t has_pawns;
|
||||||
ubyte pawns[2];
|
uint8_t pawns[2];
|
||||||
struct {
|
struct {
|
||||||
struct PairsData *precomp[2];
|
struct PairsData *precomp[2];
|
||||||
int factor[2][TBPIECES];
|
int factor[2][TBPIECES];
|
||||||
ubyte pieces[2][TBPIECES];
|
uint8_t pieces[2][TBPIECES];
|
||||||
ubyte norm[2][TBPIECES];
|
uint8_t norm[2][TBPIECES];
|
||||||
} file[4];
|
} file[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DTZEntry_piece {
|
struct DTZEntry_piece {
|
||||||
char *data;
|
char *data;
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
uint64 mapping;
|
uint64_t mapping;
|
||||||
ubyte ready;
|
uint8_t ready;
|
||||||
ubyte num;
|
uint8_t num;
|
||||||
ubyte symmetric;
|
uint8_t symmetric;
|
||||||
ubyte has_pawns;
|
uint8_t has_pawns;
|
||||||
ubyte enc_type;
|
uint8_t enc_type;
|
||||||
struct PairsData *precomp;
|
struct PairsData *precomp;
|
||||||
int factor[TBPIECES];
|
int factor[TBPIECES];
|
||||||
ubyte pieces[TBPIECES];
|
uint8_t pieces[TBPIECES];
|
||||||
ubyte norm[TBPIECES];
|
uint8_t norm[TBPIECES];
|
||||||
ubyte flags; // accurate, mapped, side
|
uint8_t flags; // accurate, mapped, side
|
||||||
ushort map_idx[4];
|
uint16_t map_idx[4];
|
||||||
ubyte *map;
|
uint8_t *map;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DTZEntry_pawn {
|
struct DTZEntry_pawn {
|
||||||
char *data;
|
char *data;
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
uint64 mapping;
|
uint64_t mapping;
|
||||||
ubyte ready;
|
uint8_t ready;
|
||||||
ubyte num;
|
uint8_t num;
|
||||||
ubyte symmetric;
|
uint8_t symmetric;
|
||||||
ubyte has_pawns;
|
uint8_t has_pawns;
|
||||||
ubyte pawns[2];
|
uint8_t pawns[2];
|
||||||
struct {
|
struct {
|
||||||
struct PairsData *precomp;
|
struct PairsData *precomp;
|
||||||
int factor[TBPIECES];
|
int factor[TBPIECES];
|
||||||
ubyte pieces[TBPIECES];
|
uint8_t pieces[TBPIECES];
|
||||||
ubyte norm[TBPIECES];
|
uint8_t norm[TBPIECES];
|
||||||
} file[4];
|
} file[4];
|
||||||
ubyte flags[4];
|
uint8_t flags[4];
|
||||||
ushort map_idx[4][4];
|
uint16_t map_idx[4][4];
|
||||||
ubyte *map;
|
uint8_t *map;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TBHashEntry {
|
struct TBHashEntry {
|
||||||
uint64 key;
|
uint64_t key;
|
||||||
struct TBEntry *ptr;
|
struct TBEntry *ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DTZTableEntry {
|
struct DTZTableEntry {
|
||||||
uint64 key1;
|
uint64_t key1;
|
||||||
uint64 key2;
|
uint64_t key2;
|
||||||
struct TBEntry *entry;
|
struct TBEntry *entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue