Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Changes to planning.py #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ def air_cargo():

def goal_test(kb):
required = [expr('At(C1 , JFK)'), expr('At(C2 ,SFO)')]
for q in required:
if kb.ask(q) is False:
return False
return True
return all([kb.ask(q) is not False for q in required])

# Actions

Expand Down Expand Up @@ -150,11 +147,8 @@ def spare_tire():
expr('At(Spare, Trunk)')]

def goal_test(kb):
required = [expr('At(Spare, Axle)'), expr('At(Flat, Ground)')]
for q in required:
if kb.ask(q) is False:
return False
return True
required = [expr('At(Spare, Axle)')]
return all(kb.ask(q) is not False for q in required)

# Actions

Expand Down Expand Up @@ -196,10 +190,7 @@ def three_block_tower():

def goal_test(kb):
required = [expr('On(A, B)'), expr('On(B, C)')]
for q in required:
if kb.ask(q) is False:
return False
return True
return all(kb.ask(q) is not False for q in required)

# Actions

Expand Down Expand Up @@ -227,10 +218,7 @@ def have_cake_and_eat_cake_too():

def goal_test(kb):
required = [expr('Have(Cake)'), expr('Eaten(Cake)')]
for q in required:
if kb.ask(q) is False:
return False
return True
return all(kb.ask(q) is not False for q in required)

# Actions

Expand Down Expand Up @@ -516,18 +504,14 @@ def extract_solution(self, goals_pos, goals_neg, index):
return solution


def goal_test(kb, goals):
for q in goals:
if kb.ask(q) is False:
return False
return True


def spare_tire_graphplan():
pdll = spare_tire()
negkb = FolKB([expr('At(Flat, Trunk)')])
graphplan = GraphPlan(pdll, negkb)

def goal_test(kb, goals):
return all(kb.ask(q) is not False for q in goals)

# Not sure
goals_pos = [expr('At(Spare, Axle)'), expr('At(Flat, Ground)')]
goals_neg = []
Expand All @@ -552,10 +536,7 @@ def double_tennis_problem():

def goal_test(kb):
required = [expr('Goal(Returned(Ball))'), expr('At(a, RightNet)'), expr('At(a, LeftNet)')]
for q in required:
if kb.ask(q) is False:
return False
return True
return all(kb.ask(q) is not False for q in required)

# Actions

Expand Down