class ChessModel: def __init__(self): self.board = self.create_board() self.turn = "white" def create_board(self): # Simplified chess board representation board = [[" " for _ in range(8)] for _ in range(8)] # Initialize pawns board[1] = ["p" for _ in range(8)] board[6] = ["P" for _ in range(8)] # Initialize rooks board[0][0] = board[0][7] = "r" board[7][0] = board[7][7] = "R" # Initialize knights board[0][1] = board[0][6] = "n" board[7][1] = board[7][6] = "N" # Initialize bishops board[0][2] = board[0][5] = "b" board[7][2] = board[7][5] = "B" # Initialize queens board[0][3] = "q" board[7][3] = "Q" # Initialize kings board[0][4] = "k" board[7][4] = "K" return board def move(self, start_pos, end_pos): start_x, start_y = start_pos end_x, end_y = end_pos piece = self.board[start_x][start_y] self.board[start_x][start_y] = " " self.board[end_x][end_y] = piece self.turn = "black" if self.turn == "white" else "white"