Пример #1
0
 def test_gps(self):
     current = ['hand empty', 'arm down']
     goals = ['satisfied', 'baseball in air']
     expected = [
         'Executing drink beer', 'Executing grab baseball',
         'Executing raise arm', 'Executing throw baseball'
     ]
     final = gps.gps(current, goals, ops)
     self.assertEqual(final, expected)  # order matters this time
Пример #2
0
 def test_gps(self):
     current = ['hand empty', 'arm down']
     goals = ['satisfied', 'baseball in air']
     expected = ['Executing drink beer',
                 'Executing grab baseball',
                 'Executing raise arm',
                 'Executing throw baseball']
     final = gps.gps(current, goals, ops)
     self.assertEqual(final, expected) # order matters this time
Пример #3
0
def main():
    start = problem['start']
    finish = problem['finish']
    ops = problem['ops']
    for action in gps(start, finish, ops):
        print action
Пример #4
0
problemB = {
    'initial': ['space on a', 'a on table', 'space on b', 'b on table', 'space on c', 'c on table'],
    'goal': ['c on table', 'b on c', 'a on b', 'space on a'],
    'actions': problem['actions']
}

if __name__ == '__main__':

    # import logging

    # logging.basicConfig(level=logging.DEBUG)

    # Use GPS to solve the problems formulated above.
    actionSequence = gps(
        problem['initial'],
        problem['goal'],
        problem['actions']
    )

    actionSequenceA = gps(
        problemA['initial'],
        problemA['goal'],
        problemA['actions']
    )

    actionSequenceB = gps(
        problemB['initial'],
        problemB['goal'],
        problemB['actions']
    )
Пример #5
0
 def test_gps_fail(self):
     current = ['hand empty', 'arm down']
     goals = ['satisfied', 'baseball in air', 'awesome']
     self.assertFalse(gps.gps(current, goals, ops))
Пример #6
0
def main():
    start = problem['start']
    finish = problem['finish']
    ops = problem['ops']
    for action in gps(start, finish, ops):
        print action
Пример #7
0
 def test_gps_fail(self):
     current = ['hand empty', 'arm down']
     goals = ['satisfied', 'baseball in air', 'awesome']
     self.assertFalse(gps.gps(current, goals, ops))
Пример #8
0
        'preconds': [
            'have plan',
        ],
        'add': ['landed safely'],
        'delete': ['falling']
    }, {
        'action': 'plan safe landing',
        'preconds': ['on top of cliff'],
        'add': ['have plan'],
        'delete': ['clueless']
    }]
}

if __name__ == '__main__':
    # Use GPS to solve the problem formulated above.
    actionSequence = gps.gps(problem['initial'], problem['goal'],
                             problem['actions'])

    print("Manually reordered solution:")
    # Print the solution, if there is one.
    if actionSequence is not None:
        for action in actionSequence:
            print(action)
    else:
        print('plan failure...')

    actionSequence = gps.gps(problem['initial'], problem['badGoal'],
                             problem['actions'])

    print("Bad solution:")
    # Print the solution, if there is one.