def __init__(self): """A basic test where Alice puts objects in a box.""" alice = UAgent( 'Alice', ['move', 'take', 'put', 'place_in_box', 'fetch_from_box'], [(('know', 'Alice', ('location', 'pipo', 'pipobox')), ), (('know', 'Alice', ('location', 'pipo2', 'pipobox')), )], knowledge=[ ('know', 'Alice', ('location', 'pipo', 1)), ('know', 'Alice', ('location', 'pipo2', 1)), ('know', 'Alice', ('location', 'pipobox', 2)), ('know', 'Alice', ('full', 'pipobox', False)), ], max_length_plan=9) pipo = UObject('pipo') pipo2 = UObject('pipo2') pipobox = Box('pipobox', 2) uni = Universe(3) uni.add(alice, 0) uni.add(pipo, 1) uni.add(pipobox, 2) uni.add(pipo2, 1) self.agents = [alice] self.objects = [pipo, pipo2, pipobox] self.universe = uni self.nb_iteration_max = 9 self.test_name = 'Test with Alice putting 2 objects in the box'
def __init__(self, name, max_capacity): """ Create a box with a name and a maximum capacity. The box is empty at start.""" UObject.__init__(self, name) if max_capacity < 1: raise ValueError('Capacity should be 1 or higher') else: self.max_capacity = max_capacity self.objects = [] self.capacity = self.max_capacity
def __init__(self, name, max_capacity): """ Create a box with a name and a maximum capacity. The box is empty at start.""" UObject.__init__(self,name) if max_capacity<1: raise ValueError('Capacity should be 1 or higher') else: self.max_capacity = max_capacity self.objects = [] self.capacity = self.max_capacity
def __init__(self): """A basic test where Alice wants to give the object to Bob. Expected result : Alice moves to take the object and gives it to Bob.""" alice = UAgent( 'Alice', ['move', 'take', 'give'], goals = [('know', 'Alice', ('location', 'pipo', 'Bob'))], knowledge = [ ('know', 'Alice', ('location', 'pipo', 2)), ('know', 'Alice', ('location', 'Bob', 1)), ('know', 'Alice', ('free', 'Bob', True)), ] ) bob = UAgent( 'Bob', ['move', 'put'], [('know', 'Bob', ('location', 'pipo', 0))], knowledge = [ ] ) pipo = UObject('pipo') uni = Universe(3) uni.add(alice, 0) uni.add(bob, 1) uni.add(pipo, 2) self.agents = [alice, bob] self.objects = [pipo] self.universe = uni self.nb_iteration_max = 6 self.test_name = 'Test with Alice giving an object to Bob and Bob putting it somewhere else'
def __init__(self): """A basic test where Alice can move, take and put and wants to change the location of an object. Expected result : Alice moves to the item, takes it and moves it.""" alice = UAgent( 'Alice', ['move', 'take', 'put'], [ ('know', 'Alice', ('location', 'pipo', 0)), ], [ ('know', 'Alice', ('location', 'pipo', 1)), ], ) pipo = UObject('pipo') uni = Universe(2) uni.add(alice, 0) uni.add(pipo, 1) self.agents = [alice] self.objects = [pipo] self.universe = uni self.nb_iteration_max = 4 self.test_name = 'Test with Alice changing an object\'s position.'
def __init__(self): """A basic test where Alice can only order and wants to move the item. Bob can move and take/put items. Expected result : Alice orders Bob to move, take the item, move, put the item.""" alice = UAgent('Alice', can_do=['order'], goals=[('know', 'Alice', ('location', 'pipo', 0))], knowledge=[ ('know', 'Alice', ('location', 'pipo', 2)), ('know', 'Alice', ('location', 'Bob', 1)), ('know', 'Alice', ('free', 'Bob', True)), ]) bob = UAgent('Bob', ['move', 'take', 'put'], goals=[], knowledge=[('know', 'Bob', ('location', 'pipo', 2))]) pipo = UObject('pipo') uni = Universe(3) uni.add(alice, 0) uni.add(bob, 1) uni.add(pipo, 2) self.agents = [alice, bob] self.objects = [pipo] self.universe = uni self.nb_iteration_max = 6 self.test_name = 'Test with Alice ordering Bob to move the object.'
def __init__(self): """A basic test where Alice wants to move an item and then move to another position.""" alice = UAgent('Alice', ['move', 'take', 'put'], [ (('know', 'Alice', ('location', 'pipo', 0)), ('know', 'Alice', ('location', 'Alice', 2))), ], [('know', 'Alice', ('location', 'pipo', 1))]) pipo = UObject('pipo') uni = Universe(3) uni.add(alice, 0) uni.add(pipo, 1) self.agents = [alice] self.objects = [pipo] self.universe = uni self.nb_iteration_max = 5 self.test_name = 'Test with Alice moving an item and moving.'
def __init__(self): """A basic test where Alice asks Bob about the object she wants to take.""" alice = UAgent('Alice', ['take', 'ask_if', 'ask_ref'], [ (('know', 'Alice', ('location', 'pipo', 'Alice')), ), ], [], max_length_plan=3) bob = UAgent('Bob', ['move', 'inform_if', 'inform_ref'], [], [('know', 'Bob', ('location', 'pipo', 0))]) pipo = UObject('pipo') uni = Universe(3) uni.add(alice, 0) uni.add(bob, 2) uni.add(pipo, 0) self.agents = [alice, bob] self.objects = [pipo] self.universe = uni self.nb_iteration_max = 6 self.test_name = 'Test with Alice asking Bob about the object.'