flagged everything made by ai, removed debugging prints

This commit is contained in:
simoncreates
2026-03-03 22:23:47 +01:00
parent b673c1382c
commit b266fd740a
3 changed files with 14 additions and 16 deletions
+9 -11
View File
@@ -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")
+5 -4
View File
@@ -490,10 +490,11 @@ def on_move_request(payload):
current_color = room.board.turn
legal = room.board.generate_moves(current_color)
if move not in legal:
print(f"current_color: {current_color}")
print("rejecting move due to illegal move")
print(f"move: {move}")
room.board.print_legal_moves(current_color)
# todo: finish debugging castling
# print(f"current_color: {current_color}")
# print("rejecting move due to illegal move")
# print(f"move: {move}")
# room.board.print_legal_moves(current_color)
emit("move_reject", {"reason": "illegal move"}, to=sid)
return
-1
View File
@@ -1,6 +1,5 @@
bidict==0.23.1
blinker==1.9.0
chess==1.11.2
click==8.3.1
dnspython==2.8.0
eventlet==0.40.4