Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit 6702d1f

Browse files
authored
Merge pull request #5 from WmHHooper/master
Update to fix vacuum2
2 parents a409ce5 + 537fccb commit 6702d1f

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

agents.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,20 @@ def is_thing_at(self, location, tclass=Thing):
250250
return True
251251
return False
252252

253-
def old_list_things_at(self, location, tclass=Thing):
253+
# def old_list_things_at(self, location, tclass=Thing):
254+
# "Return all things exactly at a given location."
255+
# return [thing for thing in self.things
256+
# if thing.location == location
257+
# and isinstance(thing, tclass)]
258+
259+
def get_things(self, tclass=Thing):
254260
"Return all things exactly at a given location."
255-
return [thing for thing in self.things
256-
if thing.location == location
257-
and isinstance(thing, tclass)]
261+
rlist = []
262+
for thing in self.things:
263+
if not isinstance(thing, tclass):
264+
continue
265+
rlist.append(thing)
266+
return rlist
258267

259268
def list_things_at(self, location, tclass=Thing):
260269
"Return all things exactly at a given location."

envgui.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def help(self):
294294
print(line)
295295

296296
def list_things(self, MyClass=object):
297-
print(MyClass.__name__ + '(s) in the environment:')
297+
print(MyClass.__name__ + 's in the environment:')
298298
for obj in self.env.things:
299299
if isinstance(obj, MyClass):
300300
print("%s at %s" % (obj, obj.location))
@@ -307,8 +307,7 @@ def list_agents(self):
307307
def step(self, n=1):
308308
for s in range(n):
309309
self.env.step()
310-
if n > 0:
311-
print(str(n) + ' step(s) later:')
310+
print(str(n) + ' step(s) later:')
312311
print(self.displayString())
313312

314313
def mainloop(self):

0 commit comments

Comments
 (0)