From c726b3e1e62f44252f831940a116f050eda1a347 Mon Sep 17 00:00:00 2001 From: VS-Code <-> Date: Fri, 6 Feb 2026 13:23:45 +0100 Subject: [PATCH] changed chess to chess_64 --- chess/chess_64.py | 145 +++++----------------------------------------- index.html | 2 +- 2 files changed, 15 insertions(+), 132 deletions(-) diff --git a/chess/chess_64.py b/chess/chess_64.py index 4aac838..0b1f1bb 100644 --- a/chess/chess_64.py +++ b/chess/chess_64.py @@ -1,17 +1,21 @@ type_to_name = [] -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 "} +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 " +} +NOT_A_FILE = 0xfefefefefefefefe +NOT_H_FILE = 0x7f7f7f7f7f7f7f7f 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", + "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: @@ -27,125 +31,4 @@ INDEX_TO_FIELD = [ ''' -class Piece(): - def __init__(self, pce_type, is_white, index): - self.type = pce_type - self.is_white = is_white - self.has_castled = False if type == 'K' else True - self.index = index - self.bit_mask = 1 << index - -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: 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]}" - -class Board(): - def __init__(self): - - self.bit_mask_w = 0x0000000000000001FE7F800 - self.bit_mask_b = 0x1FE7F800000000000000000 - self.bit_mask_all=0x1FE7F80000000001FE7F800 - self.white_to_move = True - - # self.wr1 = Piece('R', True, 11) - # self.wn1 = Piece('N', True, 12) - # self.wb1 = Piece('B', True, 13) - # self.wk = Piece('K', True, 14) - # self.wq = Piece('Q', True, 15) - # self.wb2 = Piece('B', True, 16) - # self.wn2 = Piece('N', True, 17) - # self.wr2 = Piece('R', True, 18) - - # self.wp = [Piece('P', True, 21), - # Piece('P', True, 22), - # Piece('P', True, 23), - # Piece('P', True, 24), - # Piece('P', True, 25), - # Piece('P', True, 26), - # Piece('P', True, 27), - # Piece('P', True, 28)] - - self.piece_dict = { - 'br1':81, 'bn1':82, 'bb1':83, 'bk' :84, 'bq' :85, 'bb2':86, 'bn2':87, 'br2':88, - 'bp1':71, 'bp2':72, 'bp3':73, 'bp4':74, 'bp5':75, 'bp6':76, 'bp7':77, 'bp8':78, - 'wp1':21, 'wp2':22, 'wp3':23, 'wp4':24, 'wp5':25, 'wp6':26, 'wp7':27, 'wp8':28, - 'wr1':11, 'wn1':12, 'wb1':13, 'wk' :14, 'wq' :15, 'wb2':16, 'wn2':17, 'wr2':18, - } - - self.move_log = [] - - def print_board(self): - for x in range(100): - if OUT_OF_BOARD & 1 << x != 0: - if (x+1) % 10 == 0: - print("") - continue - continue - if self.bit_mask_all & 1 << x != 0: - for p in self.piece_dict: - if self.piece_dict[p] == x: - print(f"{PIECE_TO_UNICODE[p[:2]]} ", end="") - else: - print("\u25FB ", end="") - - def notation_to_move(self, notation_str): # Kb1a5 - if len(notation_str) < 6: - start = INDEX_TO_FIELD.index(notation_str[1]+ notation_str[2]) - end = INDEX_TO_FIELD.index(notation_str[3]+ notation_str[4]) - for p in self.piece_dict: - if self.piece_dict[p] == start: - piece_moved = p - if self.piece_dict[p] == end: - piece_captured = p - if piece_moved and piece_captured: - return Move(start, end, piece_moved, piece_captured) - elif piece_moved: - return Move(start, end, piece_moved) - else: - print("No Piece to Move") - return - else: - print("Move to long") - return - - def make_move(self, move): - self.piece_dict[move.piece_moved] = move.index_start - - if self.white_to_move: - self.bit_mask_w = self.bit_mask_w & ~move.bitmask_start - self.bit_mask_w = self.bit_mask_w | move.bitmask_end - - if move.piece_captured: - self.piece_dict[move.piece_captured] = -1 - self.bit_mask_b = self.bit_mask_b & ~move.bitmask_end - - else: - self.bit_mask_b = self.bit_mask_b & ~move.bitmask_start - self.bit_mask_b = self.bit_mask_b | move.bitmask_end - - if move.piece_captured: - self.piece_dict[move.piece_captured] = -1 - self.bit_mask_b = self.bit_mask_b & ~move.bitmask_end - - self.bit_mask_all = self.bit_mask_w | self.bit_mask_b - - self.move_log.append(move) - -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) \ No newline at end of file diff --git a/index.html b/index.html index c0850c0..a8c5ad3 100755 --- a/index.html +++ b/index.html @@ -178,7 +178,7 @@
Große Dinge haben kleine Anfänge. Diese Präsenz befindet sich derzeit im Aufbau. - Schau später wieder vorbei, um Projekte rund um Entwicklung, Datenanalyse und mehr zu sehen. + Schau später wieder vorbei, um Projekte rund um Spiele, Datenanalyse und mehr zu sehen.