From 319ca9ae730ce07561a927c096757048d2f8d669 Mon Sep 17 00:00:00 2001 From: Willem Renes Date: Fri, 30 Apr 2021 23:41:38 +0200 Subject: start of Terrain and Critter --- spiderworld.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'spiderworld.py') diff --git a/spiderworld.py b/spiderworld.py index 6d17602..f998f3a 100644 --- a/spiderworld.py +++ b/spiderworld.py @@ -4,10 +4,42 @@ 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() -- cgit v1.2.3-70-g09d2