blob: f998f3adff2c56020e9e8b3a5f40434dc1b55a24 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/usr/env python
"""
Script to rudementarally model spiders colonising new terrain, and the effect
that could have on increasing the nutrient levels.
"""
import numpy as np
class Terrain:
""" Terrain class represents the terrain over which the model is run. """
def __init__(self, size_x=10, size_y=10):
""" Create a new field of size_x by size_y """
self.field = np.zeros(shape=(size_x, size_y))
def print_terrain(self):
""" Display the field """
print(self.field)
class Critter:
""" Basic class for a creature that can appear, modify the terrain, and
procreate or die. """
def __init__(self, nutrient_value=1):
self.nutrient_value = nutrient_value
def expire(self):
""" Death of the critter """
return self.nutrient_value
def main():
""" main function, do stuff """
board = Terrain()
board.print_terrain()
spider1 = Critter()
print("\nSpider1 left", spider1.expire(), "nutrients behind.")
if __name__ == '__main__':
main()
|