@@ -195,20 +195,20 @@ def object_classes(self):
195
195
return [] ## List of classes that can go into environment
196
196
197
197
def percept (self , agent ):
198
- "Return the percept that the agent sees at this point. (Implement this.)"
198
+ "Return the percept that the agent sees at this point. (Implement this.)"
199
199
abstract
200
200
201
201
def execute_action (self , agent , action ):
202
202
"Change the world to reflect this action. (Implement this.)"
203
203
abstract
204
204
205
205
def default_location (self , object ):
206
- "Default location to place a new object with unspecified location."
206
+ "Default location to place a new object with unspecified location."
207
207
return None
208
208
209
209
def exogenous_change (self ):
210
- "If there is spontaneous change in the world, override this."
211
- pass
210
+ "If there is spontaneous change in the world, override this."
211
+ pass
212
212
213
213
def is_done (self ):
214
214
"By default, we're done when we can't find a live agent."
@@ -217,20 +217,20 @@ def is_done(self):
217
217
return True
218
218
219
219
def step (self ):
220
- """Run the environment for one time step. If the
221
- actions and exogenous changes are independent, this method will
222
- do. If there are interactions between them, you'll need to
223
- override this method."""
224
- if not self .is_done ():
220
+ """Run the environment for one time step. If the
221
+ actions and exogenous changes are independent, this method will
222
+ do. If there are interactions between them, you'll need to
223
+ override this method."""
224
+ if not self .is_done ():
225
225
actions = [agent .program (self .percept (agent ))
226
226
for agent in self .agents ]
227
227
for (agent , action ) in zip (self .agents , actions ):
228
- self .execute_action (agent , action )
228
+ self .execute_action (agent , action )
229
229
self .exogenous_change ()
230
230
231
231
def run (self , steps = 1000 ):
232
- """Run the Environment for given number of time steps."""
233
- for step in range (steps ):
232
+ """Run the Environment for given number of time steps."""
233
+ for step in range (steps ):
234
234
if self .is_done (): return
235
235
self .step ()
236
236
@@ -245,11 +245,11 @@ def some_objects_at(self, location, oclass=Object):
245
245
return self .list_objects_at (location , oclass ) != []
246
246
247
247
def add_object (self , obj , location = None ):
248
- """Add an object to the environment, setting its location. Also keep
249
- track of objects that are agents. Shouldn't need to override this."""
250
- obj .location = location or self .default_location (obj )
251
- self .objects .append (obj )
252
- if isinstance (obj , Agent ):
248
+ """Add an object to the environment, setting its location. Also keep
249
+ track of objects that are agents. Shouldn't need to override this."""
250
+ obj .location = location or self .default_location (obj )
251
+ self .objects .append (obj )
252
+ if isinstance (obj , Agent ):
253
253
obj .performance = 0
254
254
self .agents .append (obj )
255
255
0 commit comments