@@ -85,10 +85,10 @@ def __init__(self, program=None):
8585 self .bump = False
8686 self .holding = []
8787 self .performance = 0
88- if program is None :
88+ if program is None or not isinstance (program , collections .Callable ):
89+ print ("Can't find a valid program for {}, falling back to default." .format (self .__class__ .__name__ ))
8990 def program (percept ):
9091 return eval (input ('Percept={}; action? ' .format (percept )))
91- assert isinstance (program , collections .Callable )
9292 self .program = program
9393
9494 def can_grab (self , thing ):
@@ -298,12 +298,14 @@ def add_thing(self, thing, location=None):
298298 for it. (Shouldn't need to override this."""
299299 if not isinstance (thing , Thing ):
300300 thing = Agent (thing )
301- assert thing not in self .things , "Don't add the same thing twice"
302- thing .location = location if location is not None else self .default_location (thing )
303- self .things .append (thing )
304- if isinstance (thing , Agent ):
305- thing .performance = 0
306- self .agents .append (thing )
301+ if thing in self .things :
302+ print ("Can't add the same thing twice" )
303+ else :
304+ thing .location = location if location is not None else self .default_location (thing )
305+ self .things .append (thing )
306+ if isinstance (thing , Agent ):
307+ thing .performance = 0
308+ self .agents .append (thing )
307309
308310 def delete_thing (self , thing ):
309311 """Remove a thing from the environment."""
0 commit comments