-
Notifications
You must be signed in to change notification settings - Fork 0
/
chess_gui.py
719 lines (611 loc) · 27.7 KB
/
chess_gui.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
import asyncio
import base64
import io
import time
import tkinter as tk
import enum
import threading
import traceback
from PIL import ImageTk, Image, ImageGrab # pip install pillow
from typing import Optional
from PIL import ImageDraw
from chess_board import ChessBoard, Position
from pieces import Pawn, Rook, Knight, Bishop, Queen, King
from pieces.chess_piece import PlayerColor
from engine import minimax, get_best_move
from make_ai_move import make_ai_move, VALID_MODELS
FORFEIT_AFTER_K_INVALID_MOVES = 25
DRAW_AFTER_K_MOVES_WITHOUT_PAWN_OR_CAPTURE = 50
class TurnOutcome(enum.Enum):
CONTINUE = "continue"
CHECKMATE = "checkmate"
STALEMATE = "stalemate"
DRAW = "draw"
FORFEIT = "forfeit"
class ChessGUI(tk.Tk):
def __init__(self, board: ChessBoard):
super().__init__()
self.loop = asyncio.new_event_loop()
self.loop_thread = threading.Thread(target=self.start_loop, daemon=True)
self.loop_thread.start()
self.board = board
self.selected_piece: Optional[Position] = None
self.current_player = PlayerColor.WHITE
self.white_player = "HUMAN"
self.black_player = "HUMAN"
self.black_ai_memory = None
self.white_ai_memory = None
self.title("Chess")
self.frame = tk.Frame(self)
self.frame.pack()
self.canvas = tk.Canvas(self.frame, width=640, height=640)
self.canvas.pack(side=tk.LEFT)
self.move_history = tk.Text(self.frame, width=30, height=40)
self.move_history.pack(side=tk.RIGHT, fill=tk.BOTH)
self.pawn_capture_history = []
self.canvas.bind("<Button-1>", self.on_tile_click)
# Player selection menu
self.player_menu_frame = tk.Frame(self)
self.player_menu_frame.pack()
self.white_player_var = tk.StringVar(value="HUMAN")
self.black_player_var = tk.StringVar(value="HUMAN")
tk.Label(self.player_menu_frame, text="White Player:").pack(side=tk.LEFT)
self.white_player_menu = tk.OptionMenu(
self.player_menu_frame, self.white_player_var, "HUMAN", *VALID_MODELS
)
self.white_player_menu.pack(side=tk.LEFT)
tk.Label(self.player_menu_frame, text="Black Player:").pack(side=tk.LEFT)
self.black_player_menu = tk.OptionMenu(
self.player_menu_frame, self.black_player_var, "HUMAN", *VALID_MODELS
)
self.black_player_menu.pack(side=tk.LEFT)
# Buttons
self.buttons_frame = tk.Frame(self)
self.buttons_frame.pack()
self.start_button = tk.Button(
self.buttons_frame, text="Start Game", command=self.start_game
)
self.start_button.grid(row=0, column=0, padx=5, pady=5)
self.restart_button = tk.Button(
self.buttons_frame,
text="Restart Game",
command=self.restart_game,
state=tk.DISABLED,
)
self.restart_button.grid(row=0, column=1, padx=5, pady=5)
self.paused = False
self.pause_button = tk.Button(
self.buttons_frame,
text="Pause",
command=self.toggle_pause,
state=tk.DISABLED,
)
self.pause_button.grid(row=0, column=2, padx=5, pady=5)
self.board_states = [self.board.get_board_state()]
self.current_move_index = 0
self.previous_button = tk.Button(
self.buttons_frame, text="<", command=self.previous_move, state=tk.DISABLED
)
self.previous_button.grid(row=0, column=3, padx=5, pady=5)
self.next_button = tk.Button(
self.buttons_frame, text=">", command=self.next_move, state=tk.DISABLED
)
self.next_button.grid(row=0, column=4, padx=5, pady=5)
# Thinking label
self.thinking_label = tk.Label(self, text="")
self.thinking_label.pack()
# Thought strategy text
self.thought_strategy_text = tk.Text(
self.frame, width=30, height=40, wrap=tk.WORD
)
self.thought_strategy_text.pack(side=tk.LEFT, fill=tk.BOTH)
# Player material count
self.material_label = tk.Label(self, text="")
self.material_label.pack()
white_material, black_material = self.board.get_material_count()
self.material_label.config(
text=f"White Material: {white_material}, Black Material: {black_material}"
)
# Game outcome label
self.game_outcome_label = tk.Label(self, text="")
self.game_outcome_label.pack()
# load piece images
self.white_pieces = {
"Pawn": ImageTk.PhotoImage(Image.open("images/white_pieces/pawn.png")),
"Rook": ImageTk.PhotoImage(Image.open("images/white_pieces/rook.png")),
"Knight": ImageTk.PhotoImage(Image.open("images/white_pieces/knight.png")),
"Bishop": ImageTk.PhotoImage(Image.open("images/white_pieces/bishop.png")),
"Queen": ImageTk.PhotoImage(Image.open("images/white_pieces/queen.png")),
"King": ImageTk.PhotoImage(Image.open("images/white_pieces/king.png")),
}
self.black_pieces = {
"Pawn": ImageTk.PhotoImage(Image.open("images/black_pieces/pawn.png")),
"Rook": ImageTk.PhotoImage(Image.open("images/black_pieces/rook.png")),
"Knight": ImageTk.PhotoImage(Image.open("images/black_pieces/knight.png")),
"Bishop": ImageTk.PhotoImage(Image.open("images/black_pieces/bishop.png")),
"Queen": ImageTk.PhotoImage(Image.open("images/black_pieces/queen.png")),
"King": ImageTk.PhotoImage(Image.open("images/black_pieces/king.png")),
}
self.draw_board()
self.place_pieces()
def toggle_pause(self):
self.paused = not self.paused
if self.paused:
self.pause_button.config(text="Resume")
if len(self.board_states) == 1:
self.previous_button.config(state=tk.DISABLED)
self.next_button.config(state=tk.DISABLED)
else:
self.previous_button.config(state=tk.NORMAL)
self.next_button.config(state=tk.NORMAL)
if self.current_move_index == 0:
self.previous_button.config(state=tk.DISABLED)
if self.current_move_index == len(self.board_states) - 1:
self.next_button.config(state=tk.DISABLED)
else:
self.pause_button.config(text="Pause")
self.previous_button.config(state=tk.DISABLED)
self.next_button.config(state=tk.DISABLED)
self.current_move_index = len(self.board_states) - 1
self.current_player = (
PlayerColor.WHITE
if self.current_move_index % 2 == 0
else PlayerColor.BLACK
)
self.board.set_board_state(self.board_states[self.current_move_index])
self.refresh_board()
def previous_move(self):
if self.current_move_index > 0:
self.current_move_index -= 1
board_state = self.board_states[self.current_move_index]
self.board.set_board_state(board_state)
self.refresh_board()
self.current_player = (
PlayerColor.WHITE
if self.current_move_index % 2 == 0
else PlayerColor.BLACK
)
if self.current_move_index == 0:
self.previous_button.config(state=tk.DISABLED)
if self.current_move_index < len(self.board_states) - 1:
self.next_button.config(state=tk.NORMAL)
def next_move(self):
if self.current_move_index < len(self.board_states) - 1:
self.current_move_index += 1
board_state = self.board_states[self.current_move_index]
self.board.set_board_state(board_state)
self.refresh_board()
self.current_player = (
PlayerColor.WHITE
if self.current_move_index % 2 == 0
else PlayerColor.BLACK
)
if self.current_move_index == len(self.board_states) - 1:
self.next_button.config(state=tk.DISABLED)
if self.current_move_index > 0:
self.previous_button.config(state=tk.NORMAL)
def refresh_board(self):
self.draw_board()
self.place_pieces()
def start_loop(self):
asyncio.set_event_loop(self.loop)
self.loop.run_forever()
def start_game(self):
self.white_player_menu.config(state=tk.DISABLED)
self.black_player_menu.config(state=tk.DISABLED)
self.start_button.config(state=tk.DISABLED)
self.pause_button.config(state=tk.NORMAL)
self.restart_button.config(state=tk.NORMAL)
asyncio.run_coroutine_threadsafe(self.start_game_coro(), self.loop)
async def start_game_coro(self):
self.white_player = self.white_player_var.get()
self.black_player = self.black_player_var.get()
if self.white_player != "HUMAN" and self.black_player != "HUMAN":
await self.play_ai_vs_ai()
else:
while True:
if not self.paused:
if (
self.current_player == PlayerColor.WHITE
and self.white_player != "HUMAN"
) or (
self.current_player == PlayerColor.BLACK
and self.black_player != "HUMAN"
):
ai_model = (
self.white_player
if self.current_player == PlayerColor.WHITE
else self.black_player
)
turn_outcome = await self.play_ai_move(ai_model)
curr_player = self.current_player.name
await self.refresh_board_and_switch_player()
if turn_outcome == TurnOutcome.CHECKMATE:
self.game_outcome_label.config(
text=f"Checkmate! {curr_player} wins!"
)
break
elif turn_outcome == TurnOutcome.STALEMATE:
self.game_outcome_label.config(
text="Stalemate! The game is a draw."
)
break
elif turn_outcome == TurnOutcome.DRAW:
self.game_outcome_label.config(
text="50 moves without a pawn capture. Stalemate!"
)
break
elif turn_outcome == TurnOutcome.FORFEIT:
self.game_outcome_label.config(
text=f"Player {curr_player} forfeits after more than {FORFEIT_AFTER_K_INVALID_MOVES} invalid moves."
)
break
await asyncio.sleep(1)
def restart_game(self):
# Reset the chess board
self.board = ChessBoard()
# Reset the current player
self.current_player = PlayerColor.WHITE
# Reset the selected piece
self.selected_piece = None
# Reset the board states
self.board_states = [self.board.get_board_state()]
# Reset the current move index
self.current_move_index = 0
# Refresh the board
self.refresh_board()
# Clear the move history
self.move_history.delete("1.0", tk.END)
# Clear the pawn capture history
self.pawn_capture_history.clear()
# Clear the game outcome label
self.game_outcome_label.config(text="")
# Reset the material count
white_material, black_material = self.board.get_material_count()
self.material_label.config(
text=f"White Material: {white_material}, Black Material: {black_material}"
)
# Reset the player selection
self.white_player_var.set("HUMAN")
self.black_player_var.set("HUMAN")
# Re-enable the player selection menus
self.white_player_menu.config(state=tk.NORMAL)
self.black_player_menu.config(state=tk.NORMAL)
# Re-enable the start button
self.start_button.config(state=tk.NORMAL, text="Start Game")
# Disable the pause button
self.paused = False
self.pause_button.config(text="Pause")
self.pause_button.config(state=tk.DISABLED)
# Disable the previous and next buttons
self.previous_button.config(state=tk.DISABLED)
self.next_button.config(state=tk.DISABLED)
# Clear the thinking label
self.thinking_label.config(text="")
self.thought_strategy_text.delete("1.0", tk.END)
# Disable the restart button
self.restart_button.config(state=tk.DISABLED)
async def play_ai_vs_ai(self):
while True:
if not self.paused:
if self.current_player == PlayerColor.WHITE:
ai_model = self.white_player
else:
ai_model = self.black_player
try:
turn_outcome = await self.play_ai_move(ai_model)
except Exception as e:
print(f"Error: {e}")
print(traceback.format_exc())
break
curr_player = self.current_player.name
await self.refresh_board_and_switch_player()
if turn_outcome == TurnOutcome.CHECKMATE:
print(f"Checkmate! {curr_player} wins!")
self.game_outcome_label.config(
text=f"Checkmate! {curr_player} wins!"
)
break
elif turn_outcome == TurnOutcome.STALEMATE:
print("Stalemate! The game is a draw.")
self.game_outcome_label.config(
text="Stalemate! The game is a draw."
)
break
elif turn_outcome == TurnOutcome.DRAW:
print("50 moves without a pawn capture. Stalemate!")
self.game_outcome_label.config(
text="50 moves without a pawn capture. Stalemate!"
)
break
elif turn_outcome == TurnOutcome.FORFEIT:
self.game_outcome_label.config(
text=f"Player {curr_player} forfeits after more than {FORFEIT_AFTER_K_INVALID_MOVES} invalid moves."
)
break
await asyncio.sleep(1)
async def play_ai_move(self, ai_model) -> TurnOutcome:
prev_invalid_moves = []
while True:
if len(prev_invalid_moves) >= FORFEIT_AFTER_K_INVALID_MOVES:
print(
f"Player {self.current_player.name} forfeits after {FORFEIT_AFTER_K_INVALID_MOVES} invalid moves."
)
return TurnOutcome.FORFEIT
if not self.paused:
self.thinking_label.config(text=f"{ai_model} is thinking...")
self.update()
memory = (
self.white_ai_memory
if self.current_player == PlayerColor.WHITE
else self.black_ai_memory
)
board_image_base64 = self.render_board_to_image()
print(f"Getting {self.current_player.name} move using {ai_model}...")
ai_move = await make_ai_move(
board=self.board,
current_player=self.current_player,
ai_model=ai_model,
prev_invalid_moves=prev_invalid_moves,
memory=memory,
move_history=self.move_history.get("1.0", tk.END),
last_k_move_history=5,
board_image=board_image_base64,
)
print(f"{ai_model}'s move: {ai_move}")
if self.paused:
continue
else:
continue
self.thinking_label.config(text="")
self.update()
piece_name = ai_move["piece"]
source_str = ai_move["source"]
destination_str = ai_move["destination"]
memory = ai_move["memory"]
self.thought_strategy_text.delete("1.0", tk.END)
self.thought_strategy_text.insert(tk.END, f"{ai_model.upper()}:\n{memory}")
try:
source = self.board.get_position_tuple(source_str)
destination = self.board.get_position_tuple(destination_str)
except Exception as e:
source = None
destination = None
pieces = self.board.get_pieces(self.current_player)
piece = (
next(
(
p
for p in pieces
if p.__class__.__name__ == piece_name and p.position == source
),
None,
)
if source
else None
)
if piece and destination:
valid_move, was_pawn_or_capture = self.board.move_piece(
piece, destination
)
if valid_move:
self.board_states.append(self.board.get_board_state())
self.current_move_index = len(self.board_states) - 1
if self.current_player == PlayerColor.WHITE:
self.white_ai_memory = memory
else:
self.black_ai_memory = memory
# Clear the previous invalid moves list
prev_invalid_moves.clear()
# Store the current player's color before switching
current_player_color = self.current_player
# Update move history using the stored player color
move_text = f"{current_player_color.name.capitalize()}: {piece_name} - {self.board.get_position_string(source)} -> {self.board.get_position_string(destination)}\n"
self.move_history.insert(tk.END, move_text)
self.pawn_capture_history.append(was_pawn_or_capture)
k_moves = DRAW_AFTER_K_MOVES_WITHOUT_PAWN_OR_CAPTURE
if len(self.pawn_capture_history) >= k_moves and all(
[not x for x in self.pawn_capture_history[-k_moves:]]
):
print(f"{k_moves} moves without a pawn capture. Stalemate!")
return TurnOutcome.DRAW
# Check for checkmate and stalemate using the opposite player
opposite_player = (
PlayerColor.BLACK
if current_player_color == PlayerColor.WHITE
else PlayerColor.WHITE
)
if self.board.is_checkmate(opposite_player):
print(f"Checkmate! {current_player_color.name} wins!")
return TurnOutcome.CHECKMATE
elif self.board.is_stalemate(opposite_player):
print("Stalemate! The game is a draw.")
return TurnOutcome.STALEMATE
else:
print("Continuing the game...")
return TurnOutcome.CONTINUE
else:
print("Invalid move returned by the AI.", ai_move)
if source and destination:
if all(
[
x in range(8)
for x in [
source[0],
source[1],
destination[0],
destination[1],
]
]
):
self.highlight_square(source[0], source[1], "red")
self.highlight_square(destination[0], destination[1], "red")
# Add the invalid move to the list
prev_invalid_moves.append(ai_move)
continue
else:
print("Invalid move returned by the AI.")
if source and destination:
if all(
[
x in range(8)
for x in [
source[0],
source[1],
destination[0],
destination[1],
]
]
):
self.highlight_square(source[0], source[1], "red")
self.highlight_square(destination[0], destination[1], "red")
# Add the invalid move to the list
prev_invalid_moves.append(ai_move)
continue
async def switch_player(self):
if self.current_player == PlayerColor.WHITE:
self.current_player = PlayerColor.BLACK
else:
self.current_player = PlayerColor.WHITE
white_material, black_material = self.board.get_material_count()
self.material_label.config(
text=f"White Material: {white_material}, Black Material: {black_material}"
)
async def refresh_board_and_switch_player(self):
self.refresh_board()
await self.switch_player()
def place_image(self, row, col):
piece = self.board.get_piece((row, col))
if piece:
if piece.color == PlayerColor.WHITE:
piece_image = self.white_pieces[piece.__class__.__name__]
else:
piece_image = self.black_pieces[piece.__class__.__name__]
self.canvas.create_image(
col * 80 + 40,
row * 80 + 40,
image=piece_image,
tags=("piece", f"{row},{col}"),
)
self.canvas.create_image(
col * 80 + 40,
row * 80 + 40,
image=piece_image,
tags=("piece", f"{row},{col}"),
)
def highlight_square(self, row, col, color: str):
x1, y1 = col * 80, row * 80
x2, y2 = x1 + 80, y1 + 80
self.canvas.create_rectangle(
x1, y1, x2, y2, fill=color, tags="highlight", stipple="gray12"
)
self.place_image(row, col)
if color == "red":
self.after(1000, self.remove_square_highlight, row, col)
def remove_square_highlight(self, row, col):
x1, y1 = col * 80, row * 80
x2, y2 = x1 + 80, y1 + 80
color = "lemon chiffon" if (row + col) % 2 == 0 else "sienna4"
self.canvas.create_rectangle(x1, y1, x2, y2, fill=color)
self.place_image(row, col)
def draw_board(self):
self.canvas.delete("highlight")
self.canvas.delete("piece")
for row in range(8):
for col in range(8):
x1, y1 = col * 80, row * 80
x2, y2 = x1 + 80, y1 + 80
color = "lemon chiffon" if (row + col) % 2 == 0 else "sienna4"
self.canvas.create_rectangle(x1, y1, x2, y2, fill=color)
def on_tile_click(self, event):
col, row = event.x // 80, event.y // 80
clicked_position = (row, col)
clicked_piece = self.board.get_piece(clicked_position)
if (
self.current_player == PlayerColor.WHITE and self.white_player == "HUMAN"
) or (
self.current_player == PlayerColor.BLACK and self.black_player == "HUMAN"
):
if not self.selected_piece:
if clicked_piece and clicked_piece.color == self.current_player:
self.selected_piece = clicked_piece
self.highlight_square(row, col, "blue")
else:
if clicked_piece and clicked_piece.color == self.selected_piece.color:
# Deselect the previously selected piece and select the new piece
self.remove_square_highlight(
self.selected_piece.position[0], self.selected_piece.position[1]
)
self.selected_piece = clicked_piece
self.highlight_square(row, col, "blue")
else:
valid_move, was_pawn_or_capture = self.board.move_piece(
self.selected_piece, clicked_position
)
if valid_move:
# add to board states
self.board_states.append(self.board.get_board_state())
self.remove_square_highlight(
self.selected_piece.position[0],
self.selected_piece.position[1],
)
self.selected_piece = None
self.refresh_board()
asyncio.run_coroutine_threadsafe(
self.switch_player(), self.loop
)
piece_name = self.board.moves[-1][0]
source = self.board.get_position_string(self.board.moves[-1][1])
destination = self.board.get_position_string(
self.board.moves[-1][2]
)
# Update move history
move_text = f"{self.current_player.name.capitalize()}: {piece_name} - {source} -> {destination}\n"
self.move_history.insert(tk.END, move_text)
self.pawn_capture_history.append(was_pawn_or_capture)
else:
# Invalid move
self.highlight_square(row, col, "red")
def place_pieces(self):
for row in range(8):
for col in range(8):
self.place_image(row, col)
def render_board_to_image(self):
# Create a new image with the same dimensions as the canvas
width = self.canvas.winfo_width()
height = self.canvas.winfo_height()
image = Image.new('RGB', (width, height), color='white')
draw = ImageDraw.Draw(image)
# Define colors using RGB values
light_square = (255, 250, 205) # RGB for "lemon chiffon"
dark_square = (139, 69, 19) # RGB for "sienna4"
# Draw the chess board
for row in range(8):
for col in range(8):
x1, y1 = col * 80, row * 80
x2, y2 = x1 + 80, y1 + 80
color = light_square if (row + col) % 2 == 0 else dark_square
draw.rectangle([x1, y1, x2, y2], fill=color)
# Place the pieces
for row in range(8):
for col in range(8):
piece = self.board.get_piece((row, col))
if piece:
if piece.color == PlayerColor.WHITE:
piece_image = self.white_pieces[piece.__class__.__name__]
else:
piece_image = self.black_pieces[piece.__class__.__name__]
# Convert PhotoImage to PIL Image
pil_image = ImageTk.getimage(piece_image)
image.paste(pil_image, (col * 80, row * 80), pil_image)
# Convert the image to base64
buffered = io.BytesIO()
image.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue()).decode()
return img_str
def run(self):
self.mainloop()
if __name__ == "__main__":
chess_board = ChessBoard()
gui = ChessGUI(chess_board)
gui.run()