This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
variants.py
144 lines (98 loc) · 4 KB
/
variants.py
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
# -*- coding: utf-8 -*-
class SimpleBoard:
def __init__(self, initial_fen=None, chess960=False):
self.initial_fen = initial_fen
self.move_stack = []
self.color = True if initial_fen.split()[1] == "w" else False
self.chess960 = chess960
def push(self, move):
self.move_stack.append(move)
self.color = not self.color
def pop(self):
del self.move_stack[-1]
self.color = not self.color
def is_game_over(self):
return False
def fen(self):
if self.initial_fen is None:
return self.starting_fen
else:
return self.initial_fen
class StandardBoard(SimpleBoard):
uci_variant = "chess"
starting_fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
class CrazyhouseBoard(SimpleBoard):
uci_variant = "crazyhouse"
starting_fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[] w KQkq - 0 1"
class MakrukBoard(SimpleBoard):
uci_variant = "makruk"
starting_fen = "rnsmksnr/8/pppppppp/8/8/PPPPPPPP/8/RNSKMSNR w - - 0 1"
class CambodianBoard(SimpleBoard):
uci_variant = "cambodian"
starting_fen = "rnsmksnr/8/pppppppp/8/8/PPPPPPPP/8/RNSKMSNR w DEde - 0 1"
class SittuyinBoard(SimpleBoard):
uci_variant = "sittuyin"
starting_fen = "8/8/4pppp/pppp4/4PPPP/PPPP4/8/8[rrnnssfkRRNNSSFK] w - - 0 1"
class ShogiBoard(SimpleBoard):
uci_variant = "shogi"
starting_fen = "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL[] b - 1"
class XiangqiBoard(SimpleBoard):
uci_variant = "xiangqi"
starting_fen = "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1"
class PlacementBoard(SimpleBoard):
uci_variant = "placement"
starting_fen = "8/pppppppp/8/8/8/8/PPPPPPPP/8[nnbbrrqkNNBBRRQK] w - - 0 1"
class CapablancaBoard(SimpleBoard):
uci_variant = "capablanca"
starting_fen = "rnabqkbcnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBCNR w - - 0 1"
class CapahouseBoard(SimpleBoard):
uci_variant = "capahouse"
starting_fen = "rnabqkbcnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBCNR[] w - - 0 1"
class SeirawanBoard(SimpleBoard):
uci_variant = "seirawan"
starting_fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[HEhe] w KQBCDFGkqbcdfg - 0 1"
class ShouseBoard(SimpleBoard):
uci_variant = "shouse"
starting_fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[HEhe] w KQBCDFGkqbcdfg - 0 1"
class GrandBoard(SimpleBoard):
uci_variant = "grand"
starting_fen = "r8r/1nbqkcabn1/pppppppppp/10/10/10/10/PPPPPPPPPP/1NBQKCABN1/R8R w - - 0 1"
class GrandhouseBoard(SimpleBoard):
uci_variant = "grandhouse"
starting_fen = "r8r/1nbqkcabn1/pppppppppp/10/10/10/10/PPPPPPPPPP/1NBQKCABN1/R8R[] w - - 0 1"
class GothicBoard(SimpleBoard):
uci_variant = "gothic"
starting_fen = "rnbqckabnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNBQCKABNR w KQkq - 0 1"
class GothhouseBoard(SimpleBoard):
uci_variant = "gothhouse"
starting_fen = "rnbqckabnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNBQCKABNR[] w KQkq - 0 1"
class MiniShogiBoard(SimpleBoard):
uci_variant = "minishogi"
starting_fen = "rbsgk/4p/5/P4/KGSBR[-] b - 1"
class MiniXiangqiBoard(SimpleBoard):
uci_variant = "minixiangqi"
starting_fen = "rcnkncr/p1ppp1p/7/7/7/P1PPP1P/RCNKNCR w - - 0 1"
class ShakoBoard(SimpleBoard):
uci_variant = "shako"
starting_fen = "c8c/ernbqkbnre/pppppppppp/10/10/10/10/PPPPPPPPPP/ERNBQKBNRE/C8C w KQkq - 0 1"
VARIANT2BOARD = {
"chess": StandardBoard,
"crazyhouse": CrazyhouseBoard,
"makruk": MakrukBoard,
"sittuyin": SittuyinBoard,
"shogi": ShogiBoard,
"xiangqi": XiangqiBoard,
"placement": PlacementBoard,
"capablanca": CapablancaBoard,
"capahouse": CapahouseBoard,
"seirawan": SeirawanBoard,
"shouse": ShouseBoard,
"grand": GrandBoard,
"grandhouse": GrandhouseBoard,
"gothic": GothicBoard,
"gothhouse": GothhouseBoard,
"minishogi": MiniShogiBoard,
"cambodian": CambodianBoard,
"minixiangqi": MiniXiangqiBoard,
"shako": ShakoBoard,
}