-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.go
163 lines (148 loc) · 1.92 KB
/
constants.go
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package chessgo
// constants for ranks and files
const (
Rank1 = bitBoard(0xff)
Rank2 = bitBoard(0xff00)
Rank3 = bitBoard(0xff0000)
Rank4 = bitBoard(0xff000000)
Rank5 = bitBoard(0xff00000000)
Rank6 = bitBoard(0xff0000000000)
Rank7 = bitBoard(0xff000000000000)
Rank8 = bitBoard(0xff00000000000000)
FileA = bitBoard(0x0101010101010101)
FileB = bitBoard(0x0202020202020202)
FileC = bitBoard(0x0404040404040404)
FileD = bitBoard(0x0808080808080808)
FileE = bitBoard(0x1010101010101010)
FileF = bitBoard(0x2020202020202020)
FileG = bitBoard(0x4040404040404040)
FileH = bitBoard(0x8080808080808080)
)
// constants for square names
const (
A1 = iota
B1
C1
D1
E1
F1
G1
H1
A2
B2
C2
D2
E2
F2
G2
H2
A3
B3
C3
D3
E3
F3
G3
H3
A4
B4
C4
D4
E4
F4
G4
H4
A5
B5
C5
D5
E5
F5
G5
H5
A6
B6
C6
D6
E6
F6
G6
H6
A7
B7
C7
D7
E7
F7
G7
H7
A8
B8
C8
D8
E8
F8
G8
H8
)
// piece12 = (piece6+1) * +-1
// constants for pieces(6)
const (
Pawn = iota
Knight
Bishop
Rook
Queen
King
)
// piece6 = abs(piece12)-1
// constants for pieces(12)
const (
Empty = iota
WPawn
WKnight
WBishop
WRook
WQueen
WKing
BPawn = -WPawn
BKnight = -WKnight
BBishop = -WBishop
BRook = -WRook
BQueen = -WQueen
BKing = -WKing
)
// constants for colors
const (
WHITE = color(0)
BLACK = color(1)
)
/*
constants for directions
*/
// directions for peices excluding knights
const (
N = 8
S = -8
E = 1
W = -1
NE = N + E
NW = N + W
SE = S + E
SW = S + W
)
// directions for knights
const (
NEN = N + E + N
NEE = N + E + E
NWN = N + W + N
NWW = N + W + W
SES = S + E + S
SEE = S + E + E
SWS = S + W + S
SWW = S + W + W
)
// StartPos starting Position of standard chess fen
const StartPos = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
const funnyPos = "r2q2k1/1bp1nppp/p7/1p2r3/8/P3n1Q1/1P2NPPP/3RKB1R w K - 0 1"
const funnyPos2 = "3rk3/2P5/8/8/8/8/1PPPPPP1/RNBQKBNR w KQ - 0 1"