flagged everything made by ai, removed debugging prints
This commit is contained in:
@@ -505,6 +505,7 @@ class ChessBoard:
|
||||
return False
|
||||
return piece.type == piece_type
|
||||
|
||||
# made by chatgpt
|
||||
def iter_pieces(self) -> Iterator[Tuple[BoardPos, Piece]]:
|
||||
for row_idx, row in enumerate(self.fields):
|
||||
for col_idx, field in enumerate(row):
|
||||
@@ -646,7 +647,7 @@ class ChessBoard:
|
||||
|
||||
return BoardPos((row, col))
|
||||
|
||||
# https://www.chess.com/de/terms/forsyth-edwards-notation-fen
|
||||
# this function made by chatgpt
|
||||
def to_fen(self) -> str:
|
||||
# piece placement
|
||||
ranks: List[str] = []
|
||||
@@ -748,7 +749,8 @@ class ChessBoard:
|
||||
|
||||
bm = BoardMove(src, dst, move_type, promotion_piece=promo_piece)
|
||||
return self.make_move(bm, color)
|
||||
|
||||
|
||||
# debugging purposes only
|
||||
def print_legal_moves(self, color: Color) -> None:
|
||||
moves = self.generate_moves(color)
|
||||
|
||||
@@ -763,25 +765,21 @@ class ChessBoard:
|
||||
move_str = f"{from_sq}-{to_sq}"
|
||||
|
||||
# Add move type notation
|
||||
if move.move_type.name == "CASTLING_KINGSIDE":
|
||||
if move.move_type == MoveType.CASTLING_KINGSIDE:
|
||||
move_str += " (O-O)"
|
||||
elif move.move_type.name == "CASTLING_QUEENSIDE":
|
||||
elif move.move_type == MoveType.CASTLING_QUEENSIDE:
|
||||
move_str += " (O-O-O)"
|
||||
elif move.move_type.name == "EN_PASSANT":
|
||||
elif move.move_type.name == MoveType.EN_PASSANT:
|
||||
move_str += " (e.p.)"
|
||||
elif move.promotion_piece:
|
||||
move_str += f" (={move.promotion_piece.name[0]})"
|
||||
|
||||
move_strings.append(move_str)
|
||||
|
||||
print(f"\n{color.name} Legal Moves ({len(moves)} total):")
|
||||
print("-" * 50)
|
||||
print(f"\n{color.name} legal Moves ({len(moves)} total):")
|
||||
|
||||
# Print in columns (6 moves per row)
|
||||
# Print in columns
|
||||
moves_per_row = 6
|
||||
for i in range(0, len(move_strings), moves_per_row):
|
||||
row = move_strings[i:i + moves_per_row]
|
||||
print(" " + " | ".join(f"{m:12}" for m in row))
|
||||
print("-" * 50 + "\n")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user