def print_board(board): print(" a b c d e f g h") print(" +---+---+---+---+---+---+---+---+") for i, row in enumerate(board): print(f"{8 - i}| ", end="") for piece in row: print(f" {piece} |", end="") print("\n +---+---+---+---+---+---+---+---+") def initialize_board(): board = [["♜", "♞", "♝", "♛", "♚", "♝", "♞", "♜"], ["♟", "♟", "♟", "♟", "♟", "♟", "♟", "♟"], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], ["♙", "♙", "♙", "♙", "♙", "♙", "♙", "♙"], ["♖", "♘", "♗", "♕", "♔", "♗", "♘", "♖"]] return board def get_move(): from_square = input("Enter move (e.g., a2a4): ") to_square = input("Enter move (e.g., a2a4): ") return from_square, to_square def parse_square(square): # Convert algebraic notation (e.g., a2) to row and column indices col = ord(square[0]) - ord('a') row = 8 - int(square[1]) return row, col def main(): board = initialize_board() print_board(board) while True: move = get_move() from_square, to_square = move from_row, from_col = parse_square(from_square) to_row, to_col = parse_square(to_square) # Implement move logic here piece = board[from_row][from_col] board[from_row][from_col] = ' ' # Clear the piece from the original position board[to_row][to_col] = piece # Place the piece in the new position print_board(board) if __name__ == "__main__": main()