-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation.py
29 lines (23 loc) · 883 Bytes
/
simulation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
__author__ = 'Michael Lang'
from worm import Worm
from environment import Environment
class Simulation(object):
def __init__(self, environmentSizeX, environmentSizeY):
self.environment = Environment(environmentSizeX, environmentSizeY)
self.worm = Worm(self.environment)
self.clock = 0
def executeTimeStep(self):
print 'Time Step: %s' % self.clock
self.render_display()
self.worm.live()
if not self.worm.alive:
# worm is dead. Return value to signal simulation is done
return False
self.clock = self.clock + 1
def render_display(self):
self.environment.print_environment()
self.worm.print_worm_state()
the_simulation = Simulation(50, 50)
# To start testing this thing, run for at most X steps
while the_simulation.clock < 5:
the_simulation.executeTimeStep()