Exemple #1
0
    def __can_capture_there(self, board: Board, captured: Piece, turn: int):
        b = copy.deepcopy(board)
        b.set_is_simulation(True)
        s = copy.deepcopy(self)

        position = captured.get_position()
        b.capture(s, b.get_piece_at(position).get(), turn)
        return not b.is_tile_attacked(s.get_color(), s.get_position(), turn + 1)
Exemple #2
0
def line_of_sight_captures(board: Board, piece: Piece, directions: [(int, int)], max_step: int = float('inf')) \
        -> set:
    position = piece.get_position()
    captures = functools.reduce(lambda x, y: x + [__get_first_seen_in_direction(board, position, y, max_step)],
                                directions, [])
    captures = filter(lambda x: x.is_just(), captures)
    captures = list(map(lambda x: x.get(), captures))
    return set(filter(lambda x: x.get_color() != piece.get_color(), captures))
Exemple #3
0
    def draw_selected_piece(self, selected_piece: Piece):
        x, y = selected_piece.get_position()
        gl.glPushMatrix()
        gl.glTranslatef(*self.__transform)
        gl.glTranslatef(x * self.__tile_size, y * self.__tile_size, 0)

        self.__draw_label(selected_piece.get_color(), '▢', self.__half_tile_size, self.__half_tile_size * 1.4,
                          self.__piece_size * 1.25)

        gl.glPopMatrix()
Exemple #4
0
 def capture_piece(self, piece: Piece):
     position = piece.get_position()
     self.remove_piece_at(position)