Skip to content

Commit c087f37

Browse files
committed
Merge pull request aimacode#84 from Nishant23/agents
Agents.py
2 parents cc79a92 + 6f43fbf commit c087f37

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

agents.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Thing(object):
4747
You subclass Thing to get the things you want. Each thing can have a
4848
.__name__ slot (used for output only)."""
4949
def __repr__(self):
50-
return '<%s>' % getattr(self, '__name__', self.__class__.__name__)
50+
return '<{}>'.format(getattr(self, '__name__', self.__class__.__name__))
5151

5252
def is_alive(self):
5353
"Things that are 'alive' should return true."
@@ -80,7 +80,7 @@ def __init__(self, program=None):
8080
self.bump = False
8181
if program is None:
8282
def program(percept):
83-
return raw_input('Percept=%s; action? ' % percept)
83+
return input('Percept={}; action? ' .format(percept))
8484
assert callable(program)
8585
self.program = program
8686

@@ -95,7 +95,7 @@ def TraceAgent(agent):
9595
old_program = agent.program
9696
def new_program(percept):
9797
action = old_program(percept)
98-
print('%s perceives %s and does %s' % (agent, percept, action))
98+
print('{} perceives {} and does {}'.format(agent, percept, action))
9999
return action
100100
agent.program = new_program
101101
return agent
@@ -280,9 +280,9 @@ def delete_thing(self, thing):
280280
except(ValueError, e):
281281
print(e)
282282
print(" in Environment delete_thing")
283-
print(" Thing to be removed: %s at %s" % (thing, thing.location))
284-
print(" from list: %s" % [(thing, thing.location)
285-
for thing in self.things])
283+
print(" Thing to be removed: {} at {}" .format(thing, thing.location))
284+
print(" from list: {}" .format([(thing, thing.location)
285+
for thing in self.things]))
286286
if thing in self.agents:
287287
self.agents.remove(thing)
288288

0 commit comments

Comments
 (0)