@@ -85,10 +85,10 @@ def __init__(self, program=None):
85
85
self .bump = False
86
86
self .holding = []
87
87
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__ ))
89
90
def program (percept ):
90
91
return eval (input ('Percept={}; action? ' .format (percept )))
91
- assert isinstance (program , collections .Callable )
92
92
self .program = program
93
93
94
94
def can_grab (self , thing ):
@@ -298,12 +298,14 @@ def add_thing(self, thing, location=None):
298
298
for it. (Shouldn't need to override this."""
299
299
if not isinstance (thing , Thing ):
300
300
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 )
307
309
308
310
def delete_thing (self , thing ):
309
311
"""Remove a thing from the environment."""
0 commit comments