From a795535a644b807b13adf47001cdb6c9c39be8c6 Mon Sep 17 00:00:00 2001 From: Chris Bras Date: Thu, 7 Mar 2019 21:31:21 +0100 Subject: [PATCH] mosquitos now move around :) --- malaria.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/malaria.py b/malaria.py index f5af246..4325827 100644 --- a/malaria.py +++ b/malaria.py @@ -101,10 +101,22 @@ class Model: indices = [(i % self.width, j % self.height) for i in range(x_min, x_max + 1) for j in range(y_min, y_max + 1)] + # remove current location from the indices + indices.remove((x, y)) + return indices def move_mosquitos(self): - pass + for mosq in self.mosquitos: + # get the movement box for every mosquito + movement = self.get_movementbox(mosq.x, mosq.y) + + # choose random new position + new_pos = random.choice(movement) + + mosq.x = new_pos[0] + mosq.y = new_pos[1] + def gen_humans(self): """ @@ -203,7 +215,5 @@ class Human(IntEnum): if __name__ == "__main__": model = Model() - # model.run() - - print(model.get_movementbox(0,0)) + model.run()