-
Notifications
You must be signed in to change notification settings - Fork 0
/
praktikum07.py
28 lines (23 loc) · 1.05 KB
/
praktikum07.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from ai_pkg.planning import PlanningProblem, Action, goal_test
from ai_pkg.utils import expr
def double_tennis_problem():
initial = 'At(A, LeftBaseLine) & At(B, RightNet) & Approaching(Ball, RightBaseLine) & Team(A, B) & Team(B, A)'
goal = 'Returned(Ball) & At(a, RightNet) & At(a, LeftNet)'
action = [Action('Hit(player, Ball, loc)',
precond='Approaching(Ball, loc) & At(player, loc)',
effect='Returned(Ball)'),
Action('Go(player, to, loc)',
precond='At(player, loc)',
effect='At(player, to)')]
return PlanningProblem(init=initial,
goals=goal,
actions=action)
if __name__=='__main__':
p = double_tennis_problem()
print(goal_test(p.goals, p.init))
solution = [expr("Go(A, RightBaseLine, LeftBaseLine)"),
expr("Hit(A, Ball, RightBaseLine)"),
expr("Go(A, LeftNet, RightBaseLine)")]
for action in solution:
p.act(action)
print(goal_test(p.goals, p.init))