-
Notifications
You must be signed in to change notification settings - Fork 0
/
Goose Chess.py
527 lines (527 loc) · 30.4 KB
/
Goose Chess.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
#for Python 3.12.6
import tkinter
import copy
root=tkinter.Tk()
root.title("Goose Chess")
white_pieces="♔♕🩏♖♗♘♙" #King, Queen, Chancellor, Rook, Bishop, Knight, Pawn
black_pieces="♚♛🩒♜♝♞♟" #same as above
goose="\U0001316c"
egg="\U0001f95a"
player="White"
state="accepting starting Square for Piece"
starting_square=None
en_passant_square=None
moves_left_until_draw=100
castling_rights={"White":{"queenside":True,"kingside":True},"Black":{"queenside":True,"kingside":True}}
def rangers_blocked_by(square):
if squares[square].cget("text") in " "+goose:
return False
if square[1]!="8" and squares[square[0]+str(int(square[1])+1)].cget("text")==egg:
return False
if square[0]!="h" and squares[chr(ord(square[0])+1)+square[1]].cget("text")==egg:
return False
if square[1]!="1" and squares[square[0]+str(int(square[1])-1)].cget("text")==egg:
return False
if square[0]!="a" and squares[chr(ord(square[0])-1)+square[1]].cget("text")==egg:
return False
return True
def rook_can_range_over(starting_square,ending_square):
if starting_square[0]!=ending_square[0] and starting_square[1]!=ending_square[1]:
return False
if int(ending_square[1])-int(starting_square[1])==1 or ord(ending_square[0])-ord(starting_square[0])==1 or int(starting_square[1])-int(ending_square[1])==1 or ord(starting_square[0])-ord(ending_square[0])==1:
return True
if int(ending_square[1])>int(starting_square[1]):
if rook_can_range_over(starting_square,ending_square[0]+str(int(ending_square[1])-1)) and not rangers_blocked_by(ending_square[0]+str(int(ending_square[1])-1)):
return True
return False
if ord(ending_square[0])>ord(starting_square[0]):
if rook_can_range_over(starting_square,chr(ord(ending_square[0])-1)+ending_square[1]) and not rangers_blocked_by(chr(ord(ending_square[0])-1)+ending_square[1]):
return True
return False
if int(starting_square[1])>int(ending_square[1]):
if rook_can_range_over(starting_square,ending_square[0]+str(int(ending_square[1])+1)) and not rangers_blocked_by(ending_square[0]+str(int(ending_square[1])+1)):
return True
return False
if ord(starting_square[0])>ord(ending_square[0]):
if rook_can_range_over(starting_square,chr(ord(ending_square[0])+1)+ending_square[1]) and not rangers_blocked_by(chr(ord(ending_square[0])+1)+ending_square[1]):
return True
return False
return False
def bishop_can_range_over(starting_square,ending_square):
if (ord(ending_square[0])-ord(starting_square[0]))**2!=(int(ending_square[1])-int(starting_square[1]))**2:
return False
if int(ending_square[1])-int(starting_square[1])==1 or int(starting_square[1])-int(ending_square[1])==1:
return True
if ord(ending_square[0])>ord(starting_square[0]) and int(ending_square[1])>int(starting_square[1]):
if bishop_can_range_over(starting_square,chr(ord(ending_square[0])-1)+str(int(ending_square[1])-1)) and not rangers_blocked_by(chr(ord(ending_square[0])-1)+str(int(ending_square[1])-1)):
return True
return False
if ord(ending_square[0])>ord(starting_square[0]):
if bishop_can_range_over(starting_square,chr(ord(ending_square[0])-1)+str(int(ending_square[1])+1)) and not rangers_blocked_by(chr(ord(ending_square[0])-1)+str(int(ending_square[1])+1)):
return True
return False
if int(starting_square[1])>int(ending_square[1]):
if bishop_can_range_over(starting_square,chr(ord(ending_square[0])+1)+str(int(ending_square[1])+1)) and not rangers_blocked_by(chr(ord(ending_square[0])+1)+str(int(ending_square[1])+1)):
return True
return False
if bishop_can_range_over(starting_square,chr(ord(ending_square[0])+1)+str(int(ending_square[1])-1)) and not rangers_blocked_by(chr(ord(ending_square[0])+1)+str(int(ending_square[1])-1)):
return True
return False
def move_is_legal(starting_square,ending_square):
match squares[starting_square].cget("text"):
case "♘":
if squares[ending_square].cget("text") in " "+black_pieces and (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2==5:
return True
return False
case "♞":
if squares[ending_square].cget("text") in " "+white_pieces and (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2==5:
return True
return False
case "♙":
if starting_square[0]==ending_square[0]:
if int(ending_square[1])-int(starting_square[1])==2:
if squares[ending_square].cget("text")==" " and not rangers_blocked_by(ending_square[0]+"3") and starting_square[1]=="2":
return True
if int(ending_square[1])-int(starting_square[1])==1:
if squares[ending_square].cget("text")==" ":
return True
if int(ending_square[1])-int(starting_square[1])==1 and (ord(ending_square[0])-ord(starting_square[0])==1 or ord(starting_square[0])-ord(ending_square[0])==1):
if squares[ending_square].cget("text") in black_pieces or (squares[ending_square].cget("text")==" " and ending_square==en_passant_square):
return True
return False
case "♟":
if starting_square[0]==ending_square[0]:
if int(starting_square[1])-int(ending_square[1])==2:
if squares[ending_square].cget("text")==" " and not rangers_blocked_by(ending_square[0]+"6") and starting_square[1]=="7":
return True
if int(starting_square[1])-int(ending_square[1])==1:
if squares[ending_square].cget("text")==" ":
return True
if int(starting_square[1])-int(ending_square[1])==1 and (ord(ending_square[0])-ord(starting_square[0])==1 or ord(starting_square[0])-ord(ending_square[0])==1):
if squares[ending_square].cget("text") in white_pieces or (squares[ending_square].cget("text")==" " and ending_square==en_passant_square):
return True
return False
case "♖":
if squares[ending_square].cget("text") in " "+black_pieces and rook_can_range_over(starting_square,ending_square):
return True
return False
case "♜":
if squares[ending_square].cget("text") in " "+white_pieces and rook_can_range_over(starting_square,ending_square):
return True
return False
case "🩏":
if squares[ending_square].cget("text") in " "+black_pieces and (rook_can_range_over(starting_square,ending_square) or (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2==5):
return True
return False
case "🩒":
if squares[ending_square].cget("text") in " "+white_pieces and (rook_can_range_over(starting_square,ending_square) or (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2==5):
return True
return False
case "♗":
if squares[ending_square].cget("text") in " "+black_pieces and bishop_can_range_over(starting_square,ending_square):
return True
return False
case "♝":
if squares[ending_square].cget("text") in " "+white_pieces and bishop_can_range_over(starting_square,ending_square):
return True
return False
case "♕":
if squares[ending_square].cget("text") in " "+black_pieces and (rook_can_range_over(starting_square,ending_square) or bishop_can_range_over(starting_square,ending_square)):
return True
return False
case "♛":
if squares[ending_square].cget("text") in " "+white_pieces and (rook_can_range_over(starting_square,ending_square) or bishop_can_range_over(starting_square,ending_square)):
return True
return False
case "♔":
if squares[ending_square].cget("text") in " "+black_pieces and (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2 in {1,2}:
return True
if starting_square=="e1" and ending_square=="g1" and squares["f1"].cget("text")==" " and castling_rights["White"]["kingside"]:
return True
if starting_square=="e1" and ending_square=="c1" and squares["d1"].cget("text")==" " and castling_rights["White"]["queenside"] and not rangers_blocked_by("b1"):
return True
return False
case "♚":
if squares[ending_square].cget("text") in " "+white_pieces and (ord(ending_square[0])-ord(starting_square[0]))**2+(int(ending_square[1])-int(starting_square[1]))**2 in {1,2}:
return True
if starting_square=="e8" and ending_square=="g8" and squares["f8"].cget("text")==" " and castling_rights["Black"]["kingside"]:
return True
if starting_square=="e8" and ending_square=="c8" and squares["d8"].cget("text")==" " and castling_rights["Black"]["queenside"] and not rangers_blocked_by("b8"):
return True
return False
def square_clicked(square):
global player
global state
global starting_square
global goose_ending_square
global en_passant_square
global moves_left_until_draw
if state=="accepting starting Square for Piece":
if (squares[square].cget("text") in white_pieces and player=="White") or (squares[square].cget("text") in black_pieces and player=="Black"):
starting_square=square
state="accepting ending Square for Piece"
information_label.config(text=f"It is {player}'s turn. Click the same Square to cancel your Move or click another Square to Move to.")
else:
information_label.config(text=f"{player}, please click a Square with one of your own Pieces on it.")
elif state=="accepting ending Square for Piece":
if square==starting_square:
state="accepting starting Square for Piece"
information_label.config(text=f"It is {player}'s turn. Click a square to pick up the Piece on it.")
starting_square=None
else:
if move_is_legal(starting_square,square):
if squares[square].cget("text") in "♔♚":
state="game over"
if squares[starting_square].cget("text") in "♙♟" and abs(int(square[1])-int(starting_square[1]))==2:
if player=="White":
next_en_passant_square=square[0]+"3"
else:
next_en_passant_square=square[0]+"6"
else:
next_en_passant_square=None
if squares[starting_square].cget("text") in "♙♟" or squares[square].cget("text")!=" ":
moves_left_until_draw-=1
squares[square].config(text=squares[starting_square].cget("text"))
squares[starting_square].config(text=" ")
if square==en_passant_square and squares[square].cget("text") in "♙♟":
if player=="White":
squares[square[0]+"5"].config(text=" ")
else:
squares[square[0]+"4"].config(text=" ")
elif squares[square].cget("text") in "♔♚" and abs(ord(square[0])-ord(starting_square[0]))==2:
match square:
case "c1":
squares["d1"].config(text="♖")
squares["a1"].config(text=" ")
case "g1":
squares["f1"].config(text="♖")
squares["h1"].config(text=" ")
case "c8":
squares["d8"].config(text="♜")
squares["a8"].config(text=" ")
case "g8":
squares["f8"].config(text="♜")
squares["h8"].config(text=" ")
en_passant_square=next_en_passant_square
match starting_square:
case "e1":
castling_rights["White"]={"queenside":False,"kingside":False}
case "e8":
castling_rights["Black"]={"queenside":False,"kingside":False}
case "a1":
castling_rights["White"]["queenside"]=False
case "h1":
castling_rights["White"]["kingside"]=False
case "a8":
castling_rights["Black"]["queenside"]=False
case "h8":
castling_rights["Black"]["kingside"]=False
match square:
case "e1":
castling_rights["White"]={"queenside":False,"kingside":False}
case "e8":
castling_rights["Black"]={"queenside":False,"kingside":False}
case "a1":
castling_rights["White"]["queenside"]=False
case "h1":
castling_rights["White"]["kingside"]=False
case "a8":
castling_rights["Black"]["queenside"]=False
case "h8":
castling_rights["Black"]["kingside"]=False
if squares[square].cget("text") in "♙♟" and square[1] in "18":
information_label.config(text=f"It is {player}'s turn. Click which Piece you would like to promote to.")
queen_promotion_button.config(state="normal")
chancellor_promotion_button.config(state="normal")
rook_promotion_button.config(state="normal")
bishop_promotion_button.config(state="normal")
knight_promotion_button.config(state="normal")
if state=="game over":
state="waiting for Promotion choice to end game"
else:
state="waiting for Promotion choice"
return
if state=="game over":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
else:
information_label.config(text=f"That move is illegal! {player}, please click a Square you can legally move to!")
elif state=="accepting ending Square for Goose":
if squares[square].cget("text")==" ":
for goose_square in squares:
if squares[goose_square].cget("text")==goose:
squares[goose_square].config(text=" ")
break
squares[square].config(text=goose)
for egg_square in squares:
if squares[egg_square].cget("text")==egg:
squares[egg_square].config(text=" ")
break
squares[goose_square].config(text=egg)
move_found=False
for opponent_piece_square in squares:
if player=="White":
if squares[opponent_piece_square].cget("text") in black_pieces:
for square_to_move_to in squares:
if move_is_legal(opponent_piece_square,square_to_move_to):
move_found=True
break
else:
if squares[opponent_piece_square].cget("text") in white_pieces:
for square_to_move_to in squares:
if move_is_legal(opponent_piece_square,square_to_move_to):
move_found=True
break
if move_found==False:
if player=="White":
player="Black"
queen_promotion_button.config(text="♛")
chancellor_promotion_button.config(text="🩒")
rook_promotion_button.config(text="♜")
bishop_promotion_button.config(text="♝")
knight_promotion_button.config(text="♞")
else:
player="White"
queen_promotion_button.config(text="♕")
chancellor_promotion_button.config(text="🩏")
rook_promotion_button.config(text="♖")
bishop_promotion_button.config(text="♗")
knight_promotion_button.config(text="♘")
state="game over"
information_label.config(text=f"{player} wins by being Fowled!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
return
repetitions=0
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
for position in history:
if compressed_board_state==position:
repetitions+=1
history.append(copy.deepcopy(compressed_board_state))
if moves_left_until_draw==0 or repetitions==3:
state="game over"
information_label.config(text="The game is drawn!")
else:
state="accepting starting Square for Piece"
if player=="White":
player="Black"
queen_promotion_button.config(text="♛")
chancellor_promotion_button.config(text="🩒")
rook_promotion_button.config(text="♜")
bishop_promotion_button.config(text="♝")
knight_promotion_button.config(text="♞")
else:
player="White"
queen_promotion_button.config(text="♕")
chancellor_promotion_button.config(text="🩏")
rook_promotion_button.config(text="♖")
bishop_promotion_button.config(text="♗")
knight_promotion_button.config(text="♘")
information_label.config(text=f"It is {player}'s turn. Click a square to pick up the Piece on it.")
else:
information_label.config(text=f"{player}, you cannot Move the Goose to an occupied Square! Please select an unoccupied Square.")
elif state=="waiting for Promotion choice to end game" or state=="waiting for Promotion choice":
information_label.config(text=f"{player}, please click which Piece you would like to promote to.")
squares={}
square_image=tkinter.PhotoImage()
for file_number in range(97,105):
for rank in range(1,9):
exec(f"def click():\n square_clicked(chr({file_number})+str({rank}))")
if (file_number+rank)%2==0:
squares[chr(file_number)+str(rank)]=tkinter.Button(root,command=click,bg="green",activebackground="green",image=square_image,width=100,height=100,text=" ",font=("JuliaMono",30),compound="center")
else:
squares[chr(file_number)+str(rank)]=tkinter.Button(root,command=click,bg="white",activebackground="white",image=square_image,width=100,height=100,text=" ",font=("JuliaMono",30),compound="center")
squares[chr(file_number)+str(rank)].grid(row=9-rank,column=file_number)
squares["a1"].config(text="♖")
squares["b1"].config(text="♘")
squares["c1"].config(text="♗")
squares["d1"].config(text="🩏")
squares["e1"].config(text="♔")
squares["f1"].config(text="♗")
squares["g1"].config(text="♘")
squares["h1"].config(text="♖")
squares["a2"].config(text="♙")
squares["b2"].config(text="♙")
squares["c2"].config(text="♙")
squares["d2"].config(text="♙")
squares["e2"].config(text="♙")
squares["f2"].config(text="♙")
squares["g2"].config(text="♙")
squares["h2"].config(text="♙")
squares["d4"].config(text=egg)
squares["e4"].config(text=goose)
squares["a7"].config(text="♟")
squares["b7"].config(text="♟")
squares["c7"].config(text="♟")
squares["d7"].config(text="♟")
squares["e7"].config(text="♟")
squares["f7"].config(text="♟")
squares["g7"].config(text="♟")
squares["h7"].config(text="♟")
squares["a8"].config(text="♜")
squares["b8"].config(text="♞")
squares["c8"].config(text="♝")
squares["d8"].config(text="♛")
squares["e8"].config(text="♚")
squares["f8"].config(text="♝")
squares["g8"].config(text="♞")
squares["h8"].config(text="♜")
information_label=tkinter.Label(root,text="It is White's turn. Click a square to pick up the Piece on it.",fg="red")
information_label.grid(row=9,column=97,columnspan=8)
promotion_label=tkinter.Label(root,text="Promote to:")
promotion_label.grid(row=0,column=98)
def promote_to_queen():
global state
if player=="White":
for file_number in range(97,105):
if squares[chr(file_number)+"8"].cget("text")=="♙":
squares[chr(file_number)+"8"].config(text="♕")
break
else:
for file_number in range(97,105):
if squares[chr(file_number)+"1"].cget("text")=="♟":
squares[chr(file_number)+"1"].config(text="♛")
break
queen_promotion_button.config(state="disabled")
chancellor_promotion_button.config(state="disabled")
rook_promotion_button.config(state="disabled")
bishop_promotion_button.config(state="disabled")
knight_promotion_button.config(state="disabled")
if state=="waiting for Promotion choice to end game":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
queen_promotion_button=tkinter.Button(root,command=promote_to_queen,image=square_image,width=50,height=50,text="♕",font=("JuliaMono",30),compound="center",state="disabled")
queen_promotion_button.grid(row=0,column=99)
def promote_to_chancellor():
global state
if player=="White":
for file_number in range(97,105):
if squares[chr(file_number)+"8"].cget("text")=="♙":
squares[chr(file_number)+"8"].config(text="🩏")
break
else:
for file_number in range(97,105):
if squares[chr(file_number)+"1"].cget("text")=="♟":
squares[chr(file_number)+"1"].config(text="🩒")
break
queen_promotion_button.config(state="disabled")
chancellor_promotion_button.config(state="disabled")
rook_promotion_button.config(state="disabled")
bishop_promotion_button.config(state="disabled")
knight_promotion_button.config(state="disabled")
if state=="waiting for Promotion choice to end game":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
chancellor_promotion_button=tkinter.Button(root,command=promote_to_chancellor,image=square_image,width=50,height=50,text="🩏",font=("JuliaMono",30),compound="center",state="disabled")
chancellor_promotion_button.grid(row=0,column=100)
def promote_to_rook():
global state
if player=="White":
for file_number in range(97,105):
if squares[chr(file_number)+"8"].cget("text")=="♙":
squares[chr(file_number)+"8"].config(text="♖")
break
else:
for file_number in range(97,105):
if squares[chr(file_number)+"1"].cget("text")=="♟":
squares[chr(file_number)+"1"].config(text="♜")
break
queen_promotion_button.config(state="disabled")
chancellor_promotion_button.config(state="disabled")
rook_promotion_button.config(state="disabled")
bishop_promotion_button.config(state="disabled")
knight_promotion_button.config(state="disabled")
if state=="waiting for Promotion choice to end game":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
rook_promotion_button=tkinter.Button(root,command=promote_to_rook,image=square_image,width=50,height=50,text="♖",font=("JuliaMono",30),compound="center",state="disabled")
rook_promotion_button.grid(row=0,column=101)
def promote_to_bishop():
global state
if player=="White":
for file_number in range(97,105):
if squares[chr(file_number)+"8"].cget("text")=="♙":
squares[chr(file_number)+"8"].config(text="♗")
break
else:
for file_number in range(97,105):
if squares[chr(file_number)+"1"].cget("text")=="♟":
squares[chr(file_number)+"1"].config(text="♝")
break
queen_promotion_button.config(state="disabled")
chancellor_promotion_button.config(state="disabled")
rook_promotion_button.config(state="disabled")
bishop_promotion_button.config(state="disabled")
knight_promotion_button.config(state="disabled")
if state=="waiting for Promotion choice to end game":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
bishop_promotion_button=tkinter.Button(root,command=promote_to_bishop,image=square_image,width=50,height=50,text="♗",font=("JuliaMono",30),compound="center",state="disabled")
bishop_promotion_button.grid(row=0,column=102)
def promote_to_knight():
global state
if player=="White":
for file_number in range(97,105):
if squares[chr(file_number)+"8"].cget("text")=="♘":
squares[chr(file_number)+"8"].config(text="♗")
break
else:
for file_number in range(97,105):
if squares[chr(file_number)+"1"].cget("text")=="♞":
squares[chr(file_number)+"1"].config(text="♝")
break
queen_promotion_button.config(state="disabled")
chancellor_promotion_button.config(state="disabled")
rook_promotion_button.config(state="disabled")
bishop_promotion_button.config(state="disabled")
knight_promotion_button.config(state="disabled")
if state=="waiting for Promotion choice to end game":
information_label.config(text=f"{player} wins by capturing their Opponent's King!")
compressed_board_state={square:squares[square].cget("text") for square in squares}
compressed_board_state["castling_rights"]=copy.deepcopy(castling_rights)
compressed_board_state["en_passant_square"]=en_passant_square
history.append(copy.deepcopy(compressed_board_state))
else:
state="accepting ending Square for Goose"
information_label.config(text=f"It is {player}'s turn. Click an empty square to move the Goose there. The Egg will be moved automatically.")
knight_promotion_button=tkinter.Button(root,command=promote_to_knight,image=square_image,width=50,height=50,text="♘",font=("JuliaMono",30),compound="center",state="disabled")
knight_promotion_button.grid(row=0,column=103)
print("Don't close or interrupt this window. The game might crash if you do.")
history=[{square:squares[square].cget("text") for square in squares}]
history[0]["castling_rights"]=copy.deepcopy(castling_rights)
history[0]["en_passant_square"]=en_passant_square
root.mainloop()