FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Changes to planning.py by Chipe1 · Pull Request #452 · aimacode/aima-python · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
37 changes: 9 additions & 28 deletions planning.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL