summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Renes <wrenes@gmail.com>2021-05-12 02:20:40 +0200
committerWillem Renes <wrenes@gmail.com>2021-05-12 02:20:40 +0200
commit1b4105c7466e10ff091483f7e1c68788a2ab7182 (patch)
tree86aa65695a0b38662d711e4c0306064fc5712a7c
parent57be6e1608e946623f3c6cd2b245cf4025a4f8b5 (diff)
downloadSpiderWorld-testing.tar.gz
SpiderWorld-testing.zip
testing stufftesting
-rw-r--r--spiderworld.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/spiderworld.py b/spiderworld.py
index 8cdbdf9..1f8487d 100644
--- a/spiderworld.py
+++ b/spiderworld.py
@@ -92,12 +92,40 @@ def update():
def main():
""" main function, do stuff """
- board = Terrain()
- board.print_terrain()
+ board = Terrain(100, 100)
- spider1 = Critter()
+ print(f"The board has a width of {board.size()[0]}, and a height of"
+ f" {board.size()[1]}.")
- print("\nSpider1 left", spider1.expire(), "nutrients behind.")
+ spiders = []
+ spider_count = 0
+
+ for tick in range(0, 1_000_000):
+
+ if np.random.rand() < 0.2:
+ spiders.append(Critter(nutrient_value=1,
+ pos_x=np.random.randint(0, board.size()[0]),
+ pos_y=np.random.randint(0, board.size()[1]),
+ lifespan=10))
+ print(f"Spider created at {tick}!", end='\r')
+ spider_count += 1
+
+ for spider in spiders:
+ state = spider.live()
+
+ if state == 'dead':
+ board.update_nutrients(*spider.get_position(), spider.expire())
+ spiders.remove(spider)
+ # print("A spider died.")
+
+ print(f"There are {len(spiders)} spiders remaining"
+ f" of {spider_count} total.")
+
+ xy = [x.get_position() for x in spiders]
+ print(*zip(*xy))
+ plt.scatter(*zip(*xy), c="pink")
+ plt.imshow(board.get_terrain(), cmap='jet', interpolation="nearest")
+ plt.show()
if __name__ == '__main__':