Code Comments, Getting Dirty Env, Naming

This commit is contained in:
Steffen Illium
2021-05-11 10:31:35 +02:00
parent f98f689f5e
commit 7d926c403d
5 changed files with 98 additions and 42 deletions

View File

@ -8,8 +8,9 @@ class SimpleFactory(BaseFactory):
super(SimpleFactory, self).__init__(*args, **kwargs)
self.slice_strings.update({self.state.shape[0]-1: 'dirt'})
def spawn_dirt(self):
free_for_dirt = self.free_cells()
free_for_dirt = self.free_cells
for x, y in free_for_dirt[:self.max_dirt]: # randomly distribute dirt across the grid
self.state[-1, x, y] = 1
@ -27,10 +28,9 @@ class SimpleFactory(BaseFactory):
return 0, {}
if __name__ == '__main__':
import random
factory = SimpleFactory(n_agents=1, max_dirt=8)
random_actions = [random.randint(0, 8) for _ in range(200)]
for action in random_actions:
state, r, done, _ = factory.step(action)
state, r, done, _ = factory.step(action)