Пример #1
0
    def move(self, original_position, new_position, promotion):
        dest = tuple_to_0x88(new_position)
        moves = self.generate_moves(
            LEGAL,
            tuple_to_0x88(original_position),
            COLOR_EMPTY,
        )

        for move in moves:
            if move.destination() == dest:
                move.set_promotion(promotion)
                move.do_update(self)
                return move
        return False
Пример #2
0
 def piece_attack_moves(self, position):
     square = tuple_to_0x88(position)
     color = self.colors[square]
     moves = self.attack_moves(
         square,
         color,
     )
     return moves
Пример #3
0
 def at(self, position):
     square = tuple_to_0x88(position)
     color = self.colors[square]
     piece = self.pieces[square]
     if piece == PIECE_EMPTY:
         return None
     result = "white " if color == WHITE else "black "
     result += NAMES[piece]
     return result
Пример #4
0
 def piece_moves(self, position):
     square = tuple_to_0x88(position)
     color = self.colors[square]
     moves = self.generate_moves(
         LEGAL,
         square,
         color,
     )
     return moves