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

Skip to content

Commit 5fb618b

Browse files
committed
More agent-program cleanup, and incorporated fix from AIMA3e pseudocode.
1 parent 9a0099e commit 5fb618b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

search.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ def expand(self, problem):
9191

9292
class SimpleProblemSolvingAgent(agents.Agent):
9393
"""Abstract framework for problem-solving agent. [Fig. 3.1]"""
94-
def __init__(self):
95-
Agent.__init__(self)
94+
def make_agent_program(self):
9695
state = []
9796
seq = []
9897

@@ -102,12 +101,10 @@ def program(percept):
102101
goal = self.formulate_goal(state)
103102
problem = self.formulate_problem(state, goal)
104103
seq = self.search(problem)
105-
action = seq[0]
106-
seq[0:1] = []
107-
return action
108-
109-
self.program = program
104+
if not seq: return None
105+
return seq.pop(0)
110106

107+
return program
111108
#______________________________________________________________________________
112109
## Uninformed Search algorithms
113110

0 commit comments

Comments
 (0)