hotfix
This commit is contained in:
parent
fb1c8f5797
commit
9fae37347b
10
agent.py
10
agent.py
@ -103,7 +103,7 @@ class RandomWalkerAnt(Agent):
|
||||
"""
|
||||
combined = res_weights * walk_weights
|
||||
normalized = combined / np.sum(combined)
|
||||
return normalized
|
||||
return list(normalized)
|
||||
|
||||
def _pick_from_remaining_five(remaining_five):
|
||||
"""
|
||||
@ -190,7 +190,9 @@ class RandomWalkerAnt(Agent):
|
||||
res_weights = self._get_resistance_weights()
|
||||
weights = _combine_weights(res_weights, sens_weights)
|
||||
|
||||
self._next_pos = np.random.choice(all_neighbors_cells, p=weights)
|
||||
random_index = np.random.choice(range(6), p=weights)
|
||||
self._next_pos = all_neighbors_cells[random_index]
|
||||
|
||||
self._prev_pos = self.pos
|
||||
return
|
||||
|
||||
@ -205,7 +207,9 @@ class RandomWalkerAnt(Agent):
|
||||
walk_weights[front_index] = self.model.alpha
|
||||
|
||||
weights = _combine_weights(res_weights, walk_weights)
|
||||
self._nex_pos = np.random.choice(all_neighbors_cells, p=weights)
|
||||
|
||||
random_index = np.random.choice(range(6), p=weights)
|
||||
self._next_pos = all_neighbors_cells[random_index]
|
||||
self._prev_pos = self.pos
|
||||
|
||||
def step(self):
|
||||
|
21
main.py
21
main.py
@ -180,21 +180,16 @@ if __name__ == "__main__":
|
||||
print(kwargs)
|
||||
model = ActiveWalkerModel(**kwargs)
|
||||
|
||||
# from hexplot import plot_hexagon
|
||||
# a = np.zeros_like(model.grid.fields['food'])
|
||||
# a[np.nonzero(model.grid.fields['food'])] = 1
|
||||
# plot_hexagon(a, title="Nest locations")
|
||||
# plot_hexagon(model.grid.fields['res'], title="Resistance Map")
|
||||
from hexplot import plot_hexagon
|
||||
a = np.zeros_like(model.grid.fields['food'])
|
||||
a[np.nonzero(model.grid.fields['food'])] = 1
|
||||
plot_hexagon(a, title="Nest locations")
|
||||
plot_hexagon(model.grid.fields['res'], title="Resistance Map")
|
||||
|
||||
|
||||
# from tqdm import tqdm as progress_bar
|
||||
#for _ in progress_bar(range(model.max_steps)):
|
||||
# model.step()
|
||||
# agent_densities = model.datacollector.get_model_vars_dataframe()["agent_dens"]
|
||||
# mean_dens = np.mean(agent_densities)
|
||||
# norm_dens = mean_dens/np.max(mean_dens)
|
||||
# plot_hexagon(norm_dens, title="Ant density overall")
|
||||
# plt.show()
|
||||
from tqdm import tqdm as progress_bar
|
||||
for _ in progress_bar(range(model.max_steps)):
|
||||
model.step()
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user