diff options
| author | Willem Renes <wrenes@gmail.com> | 2021-05-09 16:05:26 +0200 |
|---|---|---|
| committer | Willem Renes <wrenes@gmail.com> | 2021-05-09 16:05:26 +0200 |
| commit | 8088774c12f5912c68735be4983382b7abce83fe (patch) | |
| tree | 94fe54cd4e1f021868e5e31157af5a06e4fba45f | |
| parent | 142c51551bf9916bed82ddba2862082c7c06ac3a (diff) | |
| download | SpiderWorld-8088774c12f5912c68735be4983382b7abce83fe.tar.gz SpiderWorld-8088774c12f5912c68735be4983382b7abce83fe.zip | |
| -rw-r--r-- | spiderworld.py | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/spiderworld.py b/spiderworld.py index 9414c23..8cdbdf9 100644 --- a/spiderworld.py +++ b/spiderworld.py @@ -4,7 +4,10 @@ Script to rudementarally model spiders colonising new terrain, and the effect that could have on increasing the nutrient levels. """ +import matplotlib.pyplot as plt import numpy as np +import time + class Terrain: """ Terrain class represents the terrain over which the model is run. @@ -23,10 +26,22 @@ class Terrain: """ Display the field """ print(f"Terrain:\n" f"{self.field}\n" - f"Terrain mask:\n" - f"{self.field_mask}\n" + # f"Terrain mask:\n" + # f"{self.field_mask}\n" ) + def get_terrain(self): + """ Return the terrain """ + return self.field + + def update_nutrients(self, x, y, nutrients): + """ change nutrient values on the terrain """ + self.field[x][y] += nutrients + + def size(self): + """ return size of the terrain """ + return self.field.shape + class Critter: """ Basic class for a creature that can appear, modify the terrain, and @@ -36,15 +51,19 @@ class Critter: self.nutrient_value = nutrient_value self.pos_x = pos_x self.pos_y = pos_y - self.lifespan = lifespan + self.lifespan = lifespan # built in (max?) life + self.life = lifespan # dynamic life left def live(self): """ Live another tick, decrement lifespan, and resolve """ - print("Living another tick") - self.lifespan -= 1 - if not self.lifespan: - print("Expires!") - # self.expire() + # print("Living another tick") + self.life -= 1 + if not self.life: + self.life = 'dead' + return self.life + + def get_lifespan(self): + """ return how long a creature is supposed to liv """ return self.lifespan def get_position(self): @@ -56,6 +75,20 @@ class Critter: return self.nutrient_value +def immigrate(): + """ check for immigrants """ + pass + + +def actions(): + """ actions taken """ + pass + + +def update(): + pass + + def main(): """ main function, do stuff """ |
