Closed dybber closed 4 years ago
Looks good to me.
random.shuffle()
is probably the better solution. I have also submitted a pull-request where it is removed, so it might as well be the only solution.Agent.update_current_tile()
if we just make the model itself call it when it adds an agent though Model.add_agent()
.Agent.align()
had been renamed in another pull request, but apparently not. I agree that Agent.center_in_tile()
or similar is better.Agent.__model
(it is set when calling Model.add_agent()
), but it might as well just be renamed to Agent.model
so we can remove the model
-parameter required for the button functions.From StupidModel 12:
"• The model stopping rule is changed: the model stops after 1000 time steps have been executed or when the number of bugs reaches zero."
Should we keep an iteration-count variable in the model? Currently I'm adding it as a TODO in a comment in stupid12-mortality-reproduction.py
I've been through the rest of the stupid models, trying to simplify everything. There's still some TODOs left (marked in comments). In addition to those TODO's everywhere we open a file, and have the on_close handler, we need to make it conditional on the file actually being open:
def close(model):
if file_handle:
file_handle.close()
I've only done that in the last model (stupid16), the same fix could be applied in the rest of the models.
Perhaps some utility functions for working with list of agents would be nice:
Also, it's unintuitive that agents_ordered also removes agents that doesn't have the property. Perhaps it's better either to keep them/add them in the end or to error, that is, first let the user get all agents of a specific type and then call a sort function
I'm working on simplifying the stupid model code, still on my TODO is to simplify stupid12 to stupid16.
Some notes for further simplication of the code i've been through so far:
Agent.align()
was namedAgent.center_in_tile()
or similar