예제 #1
0
    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.'
예제 #2
0
파일: test3.py 프로젝트: bok/AI-with-Pyke
    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.'
예제 #3
0
    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'
예제 #4
0
파일: test5.py 프로젝트: bok/AI-with-Pyke
    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'
예제 #5
0
    def __init__(self):
        """ Trivial test
        Alice is at location 0, can move, and wants herself to be in location 1.
        Expected result : Alice moves from 0 to 1."""
        alice = UAgent('Alice', ['move'],
                       [('know', 'Alice', ('location', 'Alice', 1))])

        uni = Universe(2)
        uni.add(alice, 0)

        self.agents = [alice]
        self.objects = []
        self.universe = uni
        self.nb_iteration_max = 2
        self.test_name = 'Test of the move action.'
예제 #6
0
파일: test0.py 프로젝트: bok/AI-with-Pyke
    def __init__(self):
        """ Trivial test
        Alice is at location 0, can move, and wants herself to be in location 1.
        Expected result : Alice moves from 0 to 1."""
        alice = UAgent( 'Alice',
                        ['move'],
                        [('know', 'Alice', ('location', 'Alice', 1))]
                )

        uni = Universe(2)
        uni.add(alice, 0)

        self.agents = [alice]
        self.objects = []
        self.universe = uni
        self.nb_iteration_max = 2
        self.test_name = 'Test of the move action.'
예제 #7
0
    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.'
예제 #8
0
    def __init__(self):
        """Basic test where Alice can only order and Bob can only move. Alice
        wants Bob to change his location.
        Expected result : Alice orders Bob to move."""

        alice = UAgent('Alice', ['order'],
                       [('know', 'Alice', ('location', 'Bob', 2))],
                       [('know', 'Alice', ('location', 'Bob', 1))])
        bob = UAgent('Bob', ['move'], [])

        uni = Universe(3)
        uni.add(alice, 0)
        uni.add(bob, 1)

        self.agents = [alice, bob]
        self.objects = []
        self.universe = uni
        self.nb_iteration_max = 3
        self.test_name = 'Test of Alice ordering moving to Bob.'
예제 #9
0
파일: test2.py 프로젝트: bok/AI-with-Pyke
    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.'
예제 #10
0
파일: test4.py 프로젝트: bok/AI-with-Pyke
    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.'
예제 #11
0
    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'
예제 #12
0
    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.'
예제 #13
0
파일: test7.py 프로젝트: bok/AI-with-Pyke
    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.'
예제 #14
0
파일: test1.py 프로젝트: bok/AI-with-Pyke
    def __init__(self):
        """Basic test where Alice can only order and Bob can only move. Alice
        wants Bob to change his location.
        Expected result : Alice orders Bob to move."""

        alice = UAgent( 'Alice',
                        ['order'],
                        [('know', 'Alice', ('location', 'Bob', 2))],
                        [('know', 'Alice', ('location', 'Bob', 1))]
                )
        bob = UAgent( 'Bob',
                      ['move'],
                      []
                )

        uni = Universe(3)
        uni.add(alice, 0)
        uni.add(bob, 1)

        self.agents = [alice, bob]
        self.objects = []
        self.universe = uni
        self.nb_iteration_max = 3
        self.test_name = 'Test of Alice ordering moving to Bob.'
예제 #15
0
    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.'
예제 #16
0
                max_length_plan = 3
        )

bob = UAgent( name='Bob',
              can_do=['move', 'inform_if', 'inform_ref'],
              goals=[],
              knowledge=
              [
                ('know', 'Bob', ('location', 'pipo', 0))
              ]
      )

pipo = UObject('pipo')

uni = Universe(3)
uni.add(alice, 0)
uni.add(bob, 2)
uni.add(pipo, 0)

print(uni)

finished = False
i = 0
nb_iteration_max = 5

while not finished and i < nb_iteration_max:
    print 'Itération %d' % i
    uni.step()
    i += 1
    finished = uni.all_satisfied