-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogicx.py
777 lines (746 loc) · 33.9 KB
/
logicx.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
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
piece_val = [100, 375, 475, 600, 1275, 26000]
pawn_start_keys = [ 52, 53, 54, 55, 56, 57, 58, 59, 82, 98, 114, 130, 146, 162, 178, 194, 93, 109, 125, 141, 157, 173, 189, 205, 228, 229, 230, 231, 232, 233, 234, 235]
castle_req_keys = {
129 : { 97 : 81, 161 : 193}, 248 : { 250 : 151, 246 : 244},
39 : { 37 : 36, 41 : 43}, 158 : { 190 : 206, 126 : 94}
}
castle_rep_keys = {
129 : { 97 : 113, 161 : 145}, 248 : { 250 : 249, 246 : 247},
39 : { 37 : 38, 41 : 40}, 158 : { 190 : 174, 126 : 142}
}
valid_promotion_codes = [1, 2, 3, 4]
promotion_keys = [
[81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94], [43, 59, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 251],
[193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206], [36, 52, 68, 84, 100, 116, 132, 148, 164, 180, 196, 212, 228, 244]
]
directions = [-16, 16, -1, 1, -15, -17, 15, 17]
valid_keys = [
36, 37, 38, 39, 40, 41, 42, 43,
52, 53, 54, 55, 56, 57, 58, 59,
68, 69, 70, 71, 72, 73, 74, 75,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
212, 213, 214, 215, 216, 217, 218, 219,
228, 229, 230, 231, 232, 233, 234, 235,
244, 245, 246, 247, 248, 249, 250, 251
]
def is_threat(from_key, to_key, board):
""" Detects Piece Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if data != 0:
if data[1] == 0:
return bool(is_pawn_threat(from_key, to_key, board))
elif data[1] == 1:
return bool(is_knight_threat(from_key, to_key, board))
elif data[1] == 2:
return bool(is_bishop_threat(from_key, to_key, board))
elif data[1] == 3:
return bool(is_rook_threat(from_key, to_key, board))
elif data[1] == 4:
return bool(is_queen_threat(from_key, to_key, board))
else:
return bool(is_king_threat(from_key, to_key, board))
return bool(False)
def is_pawn_threat(from_key, to_key, board):
""" Detects Pawn Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if data != 0 and data[1] == 0:
if data[0] == 0:
direction_one = directions[4]
direction_two = directions[5]
elif data[0] == 1:
direction_one = directions[4]
direction_two = directions[7]
elif data[0] == 2:
direction_one = directions[6]
direction_two = directions[7]
else:
direction_one = directions[5]
direction_two = directions[6]
actual_to_key_one = from_key + direction_one
actual_to_key_two = from_key + direction_two
if actual_to_key_one == to_key or actual_to_key_two == to_key:
return bool(True)
return bool(False)
def is_knight_threat(from_key, to_key, board):
""" Detects Knight Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if data != 0 and data[1] == 1:
direction_check = [
directions[0] + directions[5],
directions[0] + directions[4],
directions[3] + directions[4],
directions[3] + directions[7],
directions[1] + directions[6],
directions[1] + directions[7],
directions[2] + directions[5],
directions[2] + directions[6]
]
for direct in direction_check:
actual_to_key = from_key + direct
if actual_to_key == to_key:
return bool(True)
return bool(False)
def is_bishop_threat(from_key, to_key, board, skip = False):
""" Detects Bishop Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if skip == True or data != 0 and data[1] == 2:
direction_check = [
directions[4],
directions[5],
directions[6],
directions[7]
]
for direct in direction_check:
res = loop_direction(from_key, to_key, board, direct)
if res == True:
return bool(True)
return bool(False)
def is_rook_threat(from_key, to_key, board, skip = False):
""" Detects Rook Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if skip == True or data != 0 and data[1] == 3:
direction_check = [
directions[0],
directions[1],
directions[2],
directions[3]
]
for direct in direction_check:
res = loop_direction(from_key, to_key, board, direct)
if res == True:
return bool(True)
return bool(False)
def is_queen_threat(from_key, to_key, board):
""" Detects Queen Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if data != 0 and data[1] == 4:
return bool(is_bishop_threat(from_key, to_key, board, True) or is_rook_threat(from_key, to_key, board, True))
return bool(False)
def is_king_threat(from_key, to_key, board, enpassants = False):
""" Detects King Threats """
if valid_key(from_key) and valid_key(to_key):
data = board[from_key]
if enpassants == True or data != 0 and data[1] == 5:
direction_check = [
directions[0],
directions[1],
directions[2],
directions[3]
]
if enpassants != True:
direction_check.append(directions[4])
direction_check.append(directions[5])
direction_check.append(directions[6])
direction_check.append(directions[7])
for direct in direction_check:
actual_to_key = from_key + direct
if actual_to_key == to_key:
return bool(True)
return bool(False)
def loop_direction(from_key, to_key, board, direction):
""" Loops Directions """
while True:
from_key += direction
if valid_key(from_key):
check = board[from_key]
if check != 0:
if from_key != to_key:
return False
if from_key == to_key:
return bool(True)
else:
return bool(False)
def get_moves(board, move, castle_rights, enpassants, priorityPiece = False):
""" Gets A List Of Avaliable Moves """
ret = []
for key, square in enumerate(board):
if square != 0 and square[0] == move:
if priorityPiece == False or priorityPiece == 0:
if pawn_start_square(key) and square[1] == 0:
if move == 0:
directone = key + (directions[0] * 2)
directtwo = key + directions[0]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
if board[directone] == 0:
temp_board = board[:]
temp_board[directone] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directone])
elif move == 1:
directone = key + (directions[3] * 2)
directtwo = key + directions[3]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
if board[directone] == 0:
temp_board = board[:]
temp_board[directone] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directone])
elif move == 2:
directone = key + (directions[1] * 2)
directtwo = key + directions[1]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
if board[directone] == 0:
temp_board = board[:]
temp_board[directone] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directone])
else:
directone = key + (directions[2] * 2)
directtwo = key + directions[2]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
if board[directone] == 0:
temp_board = board[:]
temp_board[directone] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directone])
elif square[1] == 0:
if move == 0:
directtwo = key + directions[0]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
elif move == 1:
directtwo = key + directions[3]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
elif move == 2:
directtwo = key + directions[1]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
else:
directtwo = key + directions[2]
if board[directtwo] == 0:
temp_board = board[:]
temp_board[directtwo] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) == 0:
ret.append([key, directtwo])
if priorityPiece == False or priorityPiece == 5:
if square[1] == 5 and in_check(board, move) == 0:
if castle_rights[move][0] == True:
if move == 0:
local_a = 249
local_b = 250
elif move == 1:
local_a = 113
local_b = 97
elif move == 2:
local_a = 38
local_b = 37
else:
local_a = 174
local_b = 190
if board[local_a] == 0 and board[local_b] == 0:
allow = True
for key_check, square_check in enumerate(board):
if square_check != 0 and not(is_not_opposite_color(move, square_check[0])):
if is_threat(key_check, local_a, board) or is_threat(key_check, local_b, board):
allow = False
if allow == True:
ret.append([key, local_b])
if castle_rights[move][1] == True:
if move == 0:
local_a = 247
local_b = 246
local_c = 245
elif move == 1:
local_a = 145
local_b = 161
local_c = 177
elif move == 2:
local_a = 40
local_b = 41
local_c = 42
else:
local_a = 142
local_b = 126
local_c = 110
if board[local_a] == 0 and board[local_b] == 0:
allow = True
for key_check, square_check in enumerate(board):
if square_check != 0 and not(is_not_opposite_color(move, square_check[0])):
if is_threat(key_check, local_a, board) or is_threat(key_check, local_b, board) or is_threat(key_check, local_c, board):
allow = False
if allow == True:
ret.append([key, local_b])
for key_check, square_check in enumerate(board):
if is_threat(key, key_check, board):
if priorityPiece == False or priorityPiece == 0:
if square_check == 0:
if square[1] == 0:
for enpassant_key, enpassant_check in enumerate(enpassants):
if key_check == enpassant_check and not(is_not_opposite_color(enpassant_key, move)):
if move == 0:
hasOpposingPawnKey = key + directions[0]
elif move == 1:
hasOpposingPawnKey = key + directions[3]
elif move == 2:
hasOpposingPawnKey = key + directions[1]
else:
hasOpposingPawnKey = key + directions[2]
accessKey = board[hasOpposingPawnKey]
if accessKey != 0 and accessKey[0] == enpassant_key and accessKey[1] == 0:
ret.append([key, key_check])
continue
if square_check != 0:
if is_not_opposite_color(square[0], square_check[0]):
continue
skipSection = False
if priorityPiece == False or priorityPiece == 5:
if square[1] == 5:
for threat_key_check in valid_keys:
if board[threat_key_check] == 0:
continue
check_opposite = board[threat_key_check]
if not(is_not_opposite_color(square[0], check_opposite[0])):
if is_threat(threat_key_check, key_check, board):
skipSection = True
if priorityPiece == False or square[1] == priorityPiece:
if skipSection == False:
temp_board = board[:]
temp_board[key_check] = temp_board[key]
temp_board[key] = 0
if in_check(temp_board, move) != 0:
continue
ret.append([key, key_check])
return ret
def undo(history):
""" Undo The Position """
pos = history.pop()
return [pos, history]
def in_checkmate(color, board, castle_rights, enpassants):
""" Detects Checkmates """
if in_check(board, color) != 0 and len(get_moves(board, color, castle_rights, enpassants)) == 0:
return bool(True)
return bool(False)
def in_stalemate(color, board, castle_rights, enpassants):
""" Detects Stalemates """
if in_check(board, color) == 0 and len(get_moves(board, color, castle_rights, enpassants)) == 0:
return bool(True)
return bool(False)
def in_check(board, color):
""" Detects Checks """
ret = 0
for key, square in enumerate(board):
if square != 0 and square[0] == color and square[1] == 5:
for key_check, square_check in enumerate(board):
if square_check != 0 and not(is_not_opposite_color(color, square_check[0])) and is_threat(key_check, key, board):
ret += 1
return ret
def is_draw(color, board, half_moves, castle_rights, enpassants, history):
""" Detects Draws """
if half_moves > 49:
return bool(True)
if in_stalemate(color, board, castle_rights, enpassants):
return bool(True)
start = 0
for pos in history:
if pos[0] == color and pos[1] == board:
start += 1
if start == 2:
return bool(True)
return bool(False)
def is_gameover(color, board, half_moves, castle_rights, enpassants, history):
""" Detects A Final Position """
if is_draw(color, board, half_moves, castle_rights, enpassants, history):
return bool(True)
if in_checkmate(color, board, castle_rights, enpassants):
return bool(True)
return bool(False)
def valid_key(key):
""" Checks An Input Key """
if key in valid_keys:
return bool(True)
return bool(False)
def is_not_opposite_color(color_one, color_two):
""" Checks The Opposite Colors """
if color_one == 0 and color_two == 0 or color_one == 0 and color_two == 2:
return bool(True)
if color_one == 1 and color_two == 1 or color_one == 1 and color_two == 3:
return bool(True)
if color_one == 2 and color_two == 2 or color_one == 2 and color_two == 0:
return bool(True)
if color_one == 3 and color_two == 3 or color_one == 3 and color_two == 1:
return bool(True)
return bool(False)
def pawn_start_square(key):
""" Check To See If This Is A Pawn Start Key """
if key in pawn_start_keys:
return bool(True)
return bool(False)
def next_move(color):
""" Return Who's Next To Move """
return (color + 1) % 4
def is_promotion_key(key, move):
""" Check To See If This Is A Promotion Key """
if key in promotion_keys[move]:
return bool(True)
return bool(False)
def valid_promotion(code):
""" Check To See If This Is A Valid Promotion Code """
if code in valid_promotion_codes:
return bool(True)
return bool(False)
def evaluate_material(board):
""" Evaluate The Material """
sum = 0
for square in board:
if square == 0:
continue
if square[0] == 0 or square[0] == 2:
sum += piece_val[square[1]]
else:
sum += -piece_val[square[1]]
return sum
def maxi(state, depth, alpha, beta):
if depth == 0 or state.gameover() == True:
return evaluate_material(state.board)
avaliable_actions = state.get_actions()
doBreak = False
for action in avaliable_actions:
newState = state.play_action(action)
score = mini(newState, depth - 1, alpha, beta)
if score >= beta:
alpha = beta
doBreak = True
if score > alpha:
alpha = score
state = newState.undo_action()
if doBreak == True:
break
return alpha
def mini(state, depth, alpha, beta):
if depth == 0 or state.gameover() == True:
return evaluate_material(state.board)
avaliable_actions = state.get_actions()
doBreak = False
for action in avaliable_actions:
newState = state.play_action(action)
score = maxi(newState, depth - 1, alpha, beta)
if score <= alpha:
beta = alpha
doBreak = True
if score < beta:
beta = score
state = newState.undo_action()
if doBreak == True:
break
return beta
class GameState:
def __init__(self, color, board, half_moves, castle_rights, enpassants, history):
""" Constructs A New Game State """
self.board = board
self.color = color
self.half_moves = half_moves
self.castle_rights = castle_rights
self.enpassants = enpassants
self.history = history
def get_actions(self, priority = False):
""" Gets The Avaliable Actions For This State """
return get_moves(self.board, self.color, self.castle_rights, self.enpassants, priority)
def get_best_action(self, depth):
max = -99999
min = 99999
best_action = []
avaliable_actions = self.get_actions()
for action in avaliable_actions:
newState = self.play_action(action)
if self.color == 0 or self.color == 2:
score = maxi(newState, depth - 1, -99999, 99999)
if score > max:
best_action = action
max = score
else:
score = mini(newState, depth - 1, -99999, 99999)
if score < min:
best_action = action
min = score
self = newState.undo_action()
return best_action
def play_action(self, action, promotion_code = 4):
""" Plays The Action And Returns The New Game State """
skipRest = False
new_board = self.board[:]
new_color = next_move(self.color)
new_castle_rights = self.castle_rights[:]
new_half_moves = self.half_moves
new_enpassants = self.enpassants[:]
new_history = self.history
if self.board[action[0]][1] == 5 and not(is_king_threat(action[0], action[1], self.board)):
ext_req = castle_req_keys[action[0]][action[1]]
ext_rep = castle_rep_keys[action[0]][action[1]]
new_board[action[1]] = self.board[action[0]]
new_board[action[0]] = 0
new_board[ext_req] = 0
new_board[ext_rep] = [self.color, 3]
new_castle_rights[self.color][0] = False
new_castle_rights[self.color][1] = False
if self.color == 0:
new_half_moves += 1
new_enpassants[self.color] = '-'
skipRest = True
elif self.board[action[0]][1] == 0:
if not(is_king_threat(action[0], action[1], self.board, True)):
if self.color == 0:
new_enpassants[self.color] = action[1] + directions[1]
elif self.color == 1:
new_enpassants[self.color] = action[1] + directions[2]
elif self.color == 2:
new_enpassants[self.color] = action[1] + directions[0]
else:
new_enpassants[self.color] = action[1] + directions[3]
for enpassant_check in new_enpassants:
if action[1] == enpassant_check:
if self.color == 0:
direct = action[1] + directions[0]
elif self.color == 1:
direct = action[1] + directions[3]
elif self.color == 2:
direct = action[1] + directions[1]
else:
direct = action[1] + directions[2]
new_board[direct] = 0
if is_promotion_key(action[1], self.color):
if valid_promotion(promotion_code):
new_board[action[0]][1] = promotion_code
if skipRest == False:
if self.board[action[1]] != 0 or in_check(self.board, self.color) > 0:
new_half_moves = 0
elif self.color == 0:
new_half_moves += 1
if self.board[action[0]][1] != 0:
new_enpassants[self.color] = '-'
if self.board[action[0]][1] == 5:
new_castle_rights[self.color][1] = False
new_castle_rights[self.color][0] = False
if self.board[action[0]][1] == 3:
if self.color == 0:
if action[0] == 244:
new_castle_rights[self.color][1] = False
if action[0] == 251:
new_castle_rights[self.color][0] = False
elif self.color == 1:
if action[0] == 193:
new_castle_rights[self.color][1] = False
if action[0] == 81:
new_castle_rights[self.color][0] = False
elif self.color == 2:
if action[0] == 43:
new_castle_rights[self.color][1] = False
if action[0] == 36:
new_castle_rights[self.color][0] = False
else:
if action[0] == 94:
new_castle_rights[self.color][1] = False
if action[0] == 206:
new_castle_rights[self.color][0] = False
new_board[action[1]] = new_board[action[0]]
new_board[action[0]] = 0
new_history.append([self.color, self.board, self.half_moves, self.castle_rights, self.enpassants])
new_state = GameState(new_color, new_board, new_half_moves, new_castle_rights, new_enpassants, new_history)
return new_state
def gameover(self):
""" Checks To See If This Game State Is Final """
return is_gameover(self.color, self.board, self.half_moves, self.castle_rights, self.enpassants, self.history)
def undo_action(self):
""" Undo The Action And Return The Old Game State """
prev = undo(self.history)
data = prev[0]
new_history = prev[1]
new_state = GameState(data[0], data[1], data[2], data[3], data[4], new_history)
return new_state
def render(self):
""" Render The Board To The Console """
outputa = outputb = outputc = outputd = outpute = outputf = outputg = outputh = outputi = outputj = outputk = outputl = outputm = outputn = ""
start_one = "|"
start_two = "|-----|-----|-----|"
renderBoard = iter(self.board[:])
for i in range(36):
next(renderBoard)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(8):
value = next(renderBoard)
if value == 0:
outputa += " |"
else:
outputa += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputa + "-----|-----|-----|\n")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(8):
next(renderBoard)
for i in range(8):
value = next(renderBoard)
if value == 0:
outputb += " |"
else:
outputb += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputb + "-----|-----|-----|\n")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(8):
next(renderBoard)
for i in range(8):
value = next(renderBoard)
if value == 0:
outputc += " |"
else:
outputc += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputc + "-----|-----|-----|")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(5):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputd += " |"
else:
outputd += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputd)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outpute += " |"
else:
outpute += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outpute)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputf += " |"
else:
outputf += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputf)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputg += " |"
else:
outputg += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputg)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputh += " |"
else:
outputh += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputh)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputi += " |"
else:
outputi += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputi)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputj += " |"
else:
outputj += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputj)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(2):
next(renderBoard)
for i in range(14):
value = next(renderBoard)
if value == 0:
outputk += " |"
else:
outputk += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_one + outputk)
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(5):
next(renderBoard)
for i in range(8):
value = next(renderBoard)
if value == 0:
outputl += " |"
else:
outputl += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputl + "-----|-----|-----|\n")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(8):
next(renderBoard)
for i in range(8):
value = next(renderBoard)
if value == 0:
outputm += " |"
else:
outputm += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputm + "-----|-----|-----|\n")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")
for i in range(8):
next(renderBoard)
for i in range(8):
value = next(renderBoard)
if value == 0:
outputn += " |"
else:
outputn += " " + str(value[0]) + "." + str(value[1]) + " |"
print(start_two + outputn + "-----|-----|-----|\n")
print("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n")