@@ -54,7 +54,7 @@ def is_alive(self):
5454
5555 def show_state (self ):
5656 "Display the agent's internal state. Subclasses should override."
57- print "I don't know how to show_state."
57+ print ( "I don't know how to show_state." )
5858
5959 def display (self , canvas , x , y , width , height ):
6060 # Do we need this?
@@ -94,7 +94,7 @@ def TraceAgent(agent):
9494 old_program = agent .program
9595 def new_program (percept ):
9696 action = old_program (percept )
97- print '%s perceives %s and does %s' % (agent , percept , action )
97+ print ( '%s perceives %s and does %s' % (agent , percept , action ) )
9898 return action
9999 agent .program = new_program
100100 return agent
@@ -172,7 +172,7 @@ def TableDrivenVacuumAgent():
172172
173173def ReflexVacuumAgent ():
174174 "A reflex agent for the two-state vacuum environment. [Fig. 2.8]"
175- def program (( location , status ) ):
175+ def program (location , status ):
176176 if status == 'Dirty' : return 'Suck'
177177 elif location == loc_A : return 'Right'
178178 elif location == loc_B : return 'Left'
@@ -181,7 +181,7 @@ def program((location, status)):
181181def ModelBasedVacuumAgent ():
182182 "An agent that keeps track of what locations are clean or dirty."
183183 model = {loc_A : None , loc_B : None }
184- def program (( location , status ) ):
184+ def program (location , status ):
185185 "Same as ReflexVacuumAgent, except if everything is clean, do NoOp."
186186 model [location ] = status ## Update the model here
187187 if model [loc_A ] == model [loc_B ] == 'Clean' : return 'NoOp'
@@ -276,12 +276,12 @@ def delete_thing(self, thing):
276276 """Remove a thing from the environment."""
277277 try :
278278 self .things .remove (thing )
279- except ValueError , e :
280- print e
281- print " in Environment delete_thing"
282- print " Thing to be removed: %s at %s" % (thing , thing .location )
283- print " from list: %s" % [(thing , thing .location )
284- for thing in self .things ]
279+ except ( ValueError , e ) :
280+ print ( e )
281+ print ( " in Environment delete_thing" )
282+ print ( " Thing to be removed: %s at %s" % (thing , thing .location ) )
283+ print ( " from list: %s" % [(thing , thing .location )
284+ for thing in self .things ])
285285 if thing in self .agents :
286286 self .agents .remove (thing )
287287
@@ -591,12 +591,12 @@ def __init__(self, parent, env, canvas):
591591 scale .pack (side = 'left' )
592592
593593 def run (self ):
594- print 'run'
594+ print ( 'run' )
595595 self .running = True
596596 self .background_run ()
597597
598598 def stop (self ):
599- print 'stop'
599+ print ( 'stop' )
600600 self .running = False
601601
602602 def background_run (self ):
@@ -609,14 +609,14 @@ def background_run(self):
609609 self .after (ms , self .background_run )
610610
611611 def list_things (self ):
612- print "Things in the environment:"
612+ print ( "Things in the environment:" )
613613 for thing in self .env .things :
614- print "%s at %s" % (thing , thing .location )
614+ print ( "%s at %s" % (thing , thing .location ) )
615615
616616 def list_agents (self ):
617- print "Agents in the environment:"
617+ print ( "Agents in the environment:" )
618618 for agt in self .env .agents :
619- print "%s at %s" % (agt , agt .location )
619+ print ( "%s at %s" % (agt , agt .location ) )
620620
621621 def set_speed (self , speed ):
622622 self .speed = float (speed )
0 commit comments