示例#1
0
    def __init__(self, name, model):
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        root = py_trees.composites.Sequence("Sequence")

        self.blackboard = Blackboard()
        self.blackboard.shared_content = dict()

        name = type(model.target).__name__
        self.shared_content[name] = {model.target}

        low = GoTo('1')
        low.setup(0, self, name)

        mid = Away('2')
        mid.setup(0, self)
        high = Move('3')
        high.setup(0, self)
        root.add_children([low, mid, high])
        self.behaviour_tree = py_trees.trees.BehaviourTree(root)
示例#2
0
    def __init__(self, name, model):
        """Initialize the agent methods."""
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        self.shared_content['Hub'] = {model.hub}

        # Just checking the randomwalk behavior with many agent
        # how much they explore the environment

        r1 = RandomWalk('1')
        r1.setup(0, self, None)

        m1 = Move('2')
        m1.setup(0, self, None)

        randseq = py_trees.composites.Sequence('RSequence')
        randseq.add_children([r1, m1])
        self.behaviour_tree = py_trees.trees.BehaviourTree(randseq)
示例#3
0
    def setup(self, timeout, agent, item):
        """Have defined the setup method.

        This method defines the other objects required for the
        behavior. Agent is the actor in the environment,
        item is the name of the item we are trying to find in the
        environment and timeout defines the execution time for the
        behavior.
        """
        self.agent = agent
        self.item = item
        # Define goto primitive behavior
        goto = GoTo('MA_GOTO_1')
        goto.setup(0, self.agent, self.item)

        # Define away behavior
        away = Away('MA_Away_2')
        away.setup(0, self.agent)

        # Define move behavior
        move = Move('MA_MOVE_3')
        move.setup(0, self.agent)

        # Define a sequence to combine the primitive behavior
        mt_sequence = Sequence('MA_SEQUENCE')
        mt_sequence.add_children([goto, away, move])

        self.behaviour_tree = BehaviourTree(mt_sequence)
示例#4
0
    def __init__(self, name, model):
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        # name = type(model.target).__name__
        # self.shared_content[name] = {model.target}

        root = py_trees.composites.Selector("Selector")
        left_sequence = py_trees.composites.Sequence("LSequence")
        right_sequence = py_trees.composites.Sequence("RSequence")
        low = RandomWalk('1')
        low.setup(0, self)
        # low1 = IsMoveable('2')
        # low1.setup(0, self,)
        low2 = Move('3')
        low2.setup(0, self)
        medium = NeighbourObjects('4')
        medium.setup(0, self, 'Sites')
        high = DoNotMove('5')
        high.setup(0, self)
        left_sequence.add_children([medium, high])
        right_sequence.add_children([low, low2])
        # medium = GoTo('2')
        # medium.setup(0, self, self.attached_objects['Sites'][0])
        root.add_children([left_sequence, right_sequence])
        self.behaviour_tree = py_trees.trees.BehaviourTree(root)
    def __init__(self, name, model):
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        # self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        root = py_trees.composites.Sequence("Sequence")

        sense = NeighbourObjects('Sense')
        sense.setup(0, self, 'Debris')

        multiple_carry = CompositeMultipleCarry('MultipleCarry')
        multiple_carry.setup(0, self, 'Debris')

        move = Move('Move')
        move.setup(0, self)

        root.add_children([sense, multiple_carry, move])

        self.behaviour_tree = py_trees.trees.BehaviourTree(root)
示例#6
0
    def __init__(self, name, model):
        super().__init__(name, model)
        self.wealth = 1
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        root = py_trees.composites.Sequence("Sequence")
        low = RandomWalk('1')
        low.setup(0, self)
        high = Move('2')
        high.setup(0, self)
        root.add_children([low, high])
        self.behaviour_tree = py_trees.trees.BehaviourTree(root)
示例#7
0
    def setup(self, timeout, agent, item=None):
        """Have defined the setup method.

        This method defines the other objects required for the
        behavior. Agent is the actor in the environment,
        item is the name of the item we are trying to find in the
        environment and timeout defines the execution time for the
        behavior.
        """
        self.agent = agent
        self.item = item

        # Define the root for the BT
        root = Sequence("Ex_Sequence")

        low = RandomWalk('Ex_RandomWalk')
        low.setup(0, self.agent)

        high = Move('Ex_Move')
        high.setup(0, self.agent)

        root.add_children([low, high])

        self.behaviour_tree = BehaviourTree(root)
示例#8
0
    def __init__(self, name, model):
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        # self.shared_content['Hub'] = model.hub
        # self.shared_content['Sites'] = model.site
        self.shared_content['Hub'] = {model.hub}
        # root = py_trees.composites.Sequence("Sequence")
        # root = py_trees.composites.Selector('Selector')
        mseq = py_trees.composites.Sequence('MSequence')
        nseq = py_trees.composites.Sequence('NSequence')
        select = py_trees.composites.Selector('RSelector')
        carryseq = py_trees.composites.Sequence('CSequence')
        dropseq = py_trees.composites.Sequence('DSequence')

        lowest1 = py_trees.meta.inverter(NeighbourObjects)('00')
        lowest1.setup(0, self, 'Hub')

        lowest11 = NeighbourObjects('0')
        lowest11.setup(0, self, 'Sites')

        lowest = NeighbourObjects('0')
        lowest.setup(0, self, 'Food')

        low = IsCarryable('1')
        low.setup(0, self, 'Food')

        medium = IsSingleCarry('2')
        medium.setup(0, self, 'Food')

        high = SingleCarry('3')
        high.setup(0, self, 'Food')

        carryseq.add_children([lowest1, lowest11, lowest, low, medium, high])

        repeathub = RepeatUntilFalse("RepeatSeqHub")
        repeatsite = RepeatUntilFalse("RepeatSeqSite")

        high1 = py_trees.meta.inverter(NeighbourObjects)('4')
        # high1 = NeighbourObjects('4')
        high1.setup(0, self, 'Hub')

        med1 = GoTo('5')
        med1.setup(0, self, 'Hub')

        # low1 = py_trees.meta.inverter(Move)('6')
        low1 = Move('6')
        low1.setup(0, self, None)

        high2 = py_trees.meta.inverter(NeighbourObjects)('12')
        # high2 = NeighbourObjects('12')
        high2.setup(0, self, 'Sites')

        # med2 = py_trees.meta.inverter(GoTo)('13')
        med2 = GoTo('13')
        med2.setup(0, self, 'Sites')

        # low1 = py_trees.meta.inverter(Move)('6')
        low2 = Move('14')
        low2.setup(0, self, None)

        # Drop
        dropseq = py_trees.composites.Sequence('DSequence')
        c1 = IsCarrying('7')
        c1.setup(0, self, 'Food')

        d1 = IsDropable('8')
        d1.setup(0, self, 'Hub')

        d2 = Drop('9')
        d2.setup(0, self, 'Food')

        dropseq.add_children([c1, d1, d2])

        repeathub.add_children([high1, med1, low1])
        repeatsite.add_children([high2, med2, low2])

        mseq.add_children([carryseq, repeathub])
        nseq.add_children([dropseq, repeatsite])

        # For randomwalk to work the agents shouldn't know the location of Site
        v1 = py_trees.meta.inverter(IsVisitedBefore)('15')
        v1.setup(0, self, 'Sites')

        r1 = RandomWalk('16')
        r1.setup(0, self, None)

        m1 = Move('17')
        m1.setup(0, self, None)

        randseq = py_trees.composites.Sequence('RSequence')
        randseq.add_children([v1, r1, m1])

        select.add_children([nseq, mseq, randseq])

        self.behaviour_tree = py_trees.trees.BehaviourTree(select)
示例#9
0
    def __init__(self, name, model):
        super().__init__(name, model)
        self.location = ()

        self.direction = model.random.rand() * (2 * np.pi)
        self.speed = 2
        self.radius = 3

        self.moveable = True
        self.shared_content = dict()

        root = py_trees.composites.Selector("Selector")
        left_sequence = py_trees.composites.Sequence("LSequence")
        right_sequence = py_trees.composites.Sequence("RSequence")
        hub_sequence = py_trees.composites.RepeatUntilFalse("L1Sequence")

        right_selector = py_trees.composites.Selector("RSelector")
        right1_sequence = py_trees.composites.Sequence("R1Sequence")

        self.blackboard = Blackboard()
        self.blackboard.shared_content = dict()

        name = type(model.hub).__name__
        self.shared_content[name] = {model.hub}

        # self.blackboard.shared_content[
        # type(model.hub).__name__] = [model.hub]

        hub_dnm = NeighbourObjects('5')
        hub_dnm.setup(0, self, 'Hub')

        dmn = DoNotMove('6')
        dmn.setup(0, self)

        low = RandomWalk('7')
        low.setup(0, self)
        # low1 = IsMoveable('8')
        # low1.setup(0, self)
        low2 = Move('9')
        low2.setup(0, self)

        medium = NeighbourObjects('1')
        medium.setup(0, self, 'Sites')

        high = GoTo('2')
        high.setup(0, self, type(model.hub).__name__)

        highm = Move('3')
        highm.setup(0, self)

        high1 = py_trees.meta.inverter(NeighbourObjects)('4')
        high1.setup(0, self, 'Hub')

        hub_sequence.add_children([high, highm, high1])
        left_sequence.add_children([medium, hub_sequence])

        right1_sequence.add_children([hub_dnm, dmn])
        right_sequence.add_children([low, low2])

        right_selector.add_children([right1_sequence, right_sequence])
        root.add_children([left_sequence, right_selector])

        self.behaviour_tree = py_trees.trees.BehaviourTree(root)