Пример #1
0
    def __init__(
        self,
        obj: Union[Union[ActBase, list, Callable[["Knowledge"], bool]],
                   List[Union[ActBase, list, Callable[["Knowledge"],
                                                      bool]]], ],
        *argv,
    ):
        """
        Build order is a list of actions that are executed sequentially, but they are not blocking.
        When every act in build order returns true, so will also build order.

        @param orders: build order can accept lists, acts and custom methods as parameters.
        @param argv: same type requirements as for orders, but you can skip [] syntax by using argv
        """
        super().__init__()

        self.orders: List[ActBase] = []
        if len(argv) > 0 or isinstance(obj, ActBase) or isinstance(
                obj, Callable):
            orders = [obj] + list(argv)
        else:
            orders = obj

        for order in orders:
            assert order is not None

            if isinstance(order, list):
                self.orders.append(SequentialList(order))
            else:
                self.orders.append(Step.merge_to_act(order))
Пример #2
0
    def __init__(
        self,
        orders: Union[Union[ActBase, Callable[["Knowledge"], bool]],
                      List[Union[ActBase, Callable[["Knowledge"], bool]]]],
        *argv,
    ):

        is_act = isinstance(orders, ActBase) or isinstance(orders, Callable)
        assert orders is not None and (isinstance(orders, list) or is_act)
        super().__init__()

        if is_act:
            self.orders: List[ActBase] = [Step.merge_to_act(orders)]
        else:
            self.orders: List[ActBase] = []
            for order in orders:
                assert order is not None
                self.orders.append(Step.merge_to_act(order))

        for order in argv:
            assert order is not None
            self.orders.append(Step.merge_to_act(order))