File size: 707 Bytes
57f1366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import chess

class GameState:
    def __init__(self):
        self.board = chess.Board()

    def reset(self):
        self.board.reset()

    def make_move(self, uci_move):
        try:
            move = chess.Move.from_uci(uci_move)
            if move in self.board.legal_moves:
                self.board.push(move)
                return True
            return False
        except:
            return False

    def set_piece(self, square, piece):
        """Set a piece on the board directly."""
        self.board.set_piece_at(square, piece)

    def get_fen(self):
        return self.board.fen()

    def is_game_over(self):
        return self.board.is_game_over()