update
This commit is contained in:
@@ -1,38 +1,36 @@
|
||||
type_to_name = []
|
||||
OUT_OF_BOARD = 0xFFE01806018060180601807FF
|
||||
|
||||
INDEX_TO_FIELD = ["XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX",
|
||||
"XX", "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "XX",
|
||||
"XX", "a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2", "XX",
|
||||
"XX", "a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3", "XX",
|
||||
"XX", "a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4", "XX",
|
||||
"XX", "a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5", "XX",
|
||||
"XX", "a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6", "XX",
|
||||
"XX", "a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7", "XX",
|
||||
"XX", "a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8", "XX",
|
||||
"XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX", "XX"]
|
||||
|
||||
PIECE_TO_UNICODE = {"wk": "\u2654 ", "wq": "\u2655 ", "wr": "\u2656 ", "wb": "\u2657 ", "wn": "\u2658 ", "wp": "\u2659 ",
|
||||
"bk": "\u265A ", "bq": "\u265B ", "br": "\u265C ", "bb": "\u265D ", "bn": "\u265E ", "bp": "\u265F "}
|
||||
|
||||
INDEX_TO_FIELD = [
|
||||
"a1", "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",
|
||||
]
|
||||
|
||||
''' Board Index:
|
||||
a b c d e f g h
|
||||
(90) (91) (92) (93) (94) (95) (96) (97) (98) (99)
|
||||
8 (80) [81] [82] [83] [84] [85] [86] [87] [88] (89)
|
||||
7 (70) [71] [72] [73] [74] [75] [76] [77] [78] (79)
|
||||
6 (60) [61] [62] [63] [64] [65] [66] [67] [68] (69)
|
||||
5 (50) [51] [52] [53] [54] [55] [56] [57] [58] (59)
|
||||
4 (40) [41] [42] [43] [44] [45] [46] [47] [48] (49)
|
||||
3 (30) [31] [32] [33] [34] [35] [36] [37] [38] (39)
|
||||
2 (20) [21] [22] [23] [24] [25] [26] [27] [28] (29)
|
||||
1 (10) [11] [12] [13] [14] [15] [16] [17] [18] (19)
|
||||
(00) (01) (02) (03) (04) (05) (06) (07) (08) (09)
|
||||
a b c d e f g h
|
||||
8 [56] [57] [58] [59] [60] [61] [62] [63]
|
||||
7 [48] [49] [50] [51] [52] [53] [54] [55]
|
||||
6 [40] [41] [42] [43] [44] [45] [46] [47]
|
||||
5 [32] [33] [34] [35] [36] [37] [38] [39]
|
||||
4 [24] [25] [26] [27] [28] [29] [30] [31]
|
||||
3 [16] [17] [18] [19] [20] [21] [22] [23]
|
||||
2 [08] [09] [10] [11] [12] [13] [14] [15]
|
||||
1 [00] [01] [02] [03] [03] [05] [06] [07]
|
||||
|
||||
'''
|
||||
|
||||
class Piece():
|
||||
def __init__(self, type, is_white, index):
|
||||
def __init__(self, pce_type, is_white, index):
|
||||
|
||||
self.type = type
|
||||
self.type = pce_type
|
||||
self.is_white = is_white
|
||||
self.has_castled = False if type == 'K' else True
|
||||
self.index = index
|
||||
@@ -42,10 +40,9 @@ class Move():
|
||||
def __init__(self, start_index, end_index, piece_moved, piece_captured=None):
|
||||
self.piece_moved = piece_moved
|
||||
self.piece_captured = piece_captured
|
||||
|
||||
self.index_start = start_index
|
||||
self.index_end = end_index
|
||||
self.bitmask_start = 1 << start_index
|
||||
self.bitmask_start: int = 1 << start_index
|
||||
self.bitmask_end = 1 << end_index
|
||||
self.chess_notation = f"{self.piece_moved[1].upper()}{INDEX_TO_FIELD[self.index_start]}{INDEX_TO_FIELD[self.index_end]}"
|
||||
|
||||
@@ -144,3 +141,11 @@ class Board():
|
||||
board = Board()
|
||||
board.print_board()
|
||||
|
||||
while True:
|
||||
print("Your Move, Please: ")
|
||||
move_str = input()
|
||||
if len(move_str) != 4:
|
||||
print("Wrong Syntax")
|
||||
continue
|
||||
move = board.notation_to_move(move_str)
|
||||
board.make_move(move)
|
||||
@@ -1,17 +1,20 @@
|
||||
width = 4
|
||||
width = 3
|
||||
|
||||
TOP_L, TOP_F, TOP_R = "\u2598", "\u2580", "\u259D"
|
||||
MID_L, MID_F, MID_R = "\u258C", "\u2588", "\u2590"
|
||||
BOT_L, BOT_F, BOT_R = "\u2596", "\u2584", "\u2597"
|
||||
|
||||
print(TOP_L, TOP_F, TOP_R)
|
||||
print(MID_L, MID_F, MID_R)
|
||||
print(BOT_L, BOT_F, BOT_R)
|
||||
# print(TOP_L, TOP_F, TOP_R)
|
||||
# print(MID_L, MID_F, MID_R)
|
||||
# print(BOT_L, BOT_F, BOT_R)
|
||||
|
||||
BL_TR, TL_BR = "\u259E", "\u259A"
|
||||
|
||||
|
||||
print((BOT_R + BOT_F * width + BOT_L + " " * (2+width))*4) # Top Row
|
||||
print((BOT_R + BOT_F * width + BOT_L + " " * (2+width)) * 4) # Top Row
|
||||
print((MID_R + " " * width + MID_L + " " * (2+width)) * 4) # Mid Row
|
||||
print((TOP_R + TOP_F * width + TOP_L + " " * (2+width)) * 4) # Bot Row
|
||||
|
||||
for row in range(8):
|
||||
line1 = ""
|
||||
line2 = ""
|
||||
|
||||
Reference in New Issue
Block a user