-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.h
145 lines (103 loc) · 2.81 KB
/
defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// defs.h
#ifndef DEFS_H
#define DEFS_H
#include <stdlib.h>
#define DEBUG
#ifndef DEBUG
#define ASSERT(n)
#else
#define ASSERT(n) \
if(!(n)) { \
printf("%s - Failed", #n); \
printf("On %s ", __DATE__); \
printf("At %s ", __TIME__); \
printf("In File %s ", __FILE__); \
printf("At Line %d\n", __LINE__); \
exit(1); }
#endif
typedef unsigned long long U64;
#define NAME "Aoki 1.0"
#define BRD_SQ_NUM 64
#define MAXGAMEMOVES 2048
#define START_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
enum { EMPTY, wP, wN, wB, wR, wQ, wK, bP, bN, bB, bR, bQ, bK };
enum { FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H, FILE_NONE };
enum { RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8, RANK_NONE };
enum { WHITE, BLACK, BOTH };
enum {
A1 = 0, B1, C1, D1, E1, F1, G1, H1,
A2 = 8, B2, C2, D2, E2, F2, G2, H2,
A3 = 16, B3, C3, D3, E3, F3, G3, H3,
A4 = 24, B4, C4, D4, E4, F4, G4, H4,
A5 = 32, B5, C5, D5, E5, F5, G5, H5,
A6 = 40, B6, C6, D6, E6, F6, G6, H6,
A7 = 48, B7, C7, D7, E7, F7, G7, H7,
A8 = 56, B8, C8, D8, E8, F8, G8, H8, NO_SQ
};
enum { FALSE, TRUE };
// DEFINE IN 4 BITS ONLY
enum { WKCA = 1, WQCA = 2, BKCA = 4, BQCA = 8 };
typedef struct {
int move;
int castlePerm;
int enPas;
int fiftyMove;
U64 poskey;
} S_UNDO;
typedef struct {
int pieces[BRD_SQ_NUM];
U64 pawns[3];
int KingSq[2];
int side;
int enPas;
int fiftyMove;
int ply;
int hisPly;
int castlePerm;
U64 posKey;
int pceNum[13];
int bigPce[2];
int majPce[2];
int minPce[2];
int material[2];
S_UNDO history[MAXGAMEMOVES];
// piece list
int pList[13][10];
} S_BOARD;
/* MACROS */
#define FR2SQ(f,r) ((f) + ((r) * 8))
#define SQ64(sq) (sq)
#define POP(b) PopBit(b)
#define CNT(b) CountBits(b)
#define CLRBIT(bb,sq) ((bb) &= ClearMask[(sq)])
#define SETBIT(bb,sq) ((bb) |= SetMask[(sq)])
/* GLOBALS */
extern U64 SetMask[64];
extern U64 ClearMask[64];
extern U64 PieceKeys[13][64];
extern U64 SideKey;
extern U64 CastleKeys[16];
extern char PceChar[];
extern char SideChar[];
extern char RankChar[];
extern char FileChar[];
extern int PieceBig[13];
extern int PieceMaj[13];
extern int PieceMin[13];
extern int PieceVal[13];
extern int PieceCol[13];
/* FUNCTIONS */
// init.c
extern void AllInit();
// bitboards.c
extern void PrintBitBoard(U64 bb);
extern int PopBit(U64 *bb);
extern int CountBits(U64 b);
// hashkeys.c
extern U64 GeneratePosKey(const S_BOARD *pos);
// board.c
extern void ResetBoard(S_BOARD *pos);
extern int ParseFen(char *fen, S_BOARD *pos);
extern void PrintBoard(const S_BOARD *pos);
extern void UpdateListMaterial(S_BOARD *pos);
#endif