DatalogiForAlle / AgentsPy

Agent-based simulation for education in Python
GNU General Public License v3.0
5 stars 0 forks source link

Simplification of stupid model code #54

Closed dybber closed 4 years ago

dybber commented 4 years ago

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:

JensKanstrupLarsen commented 4 years ago

Looks good to me.

dybber commented 4 years ago

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

dybber commented 4 years ago

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.

dybber commented 4 years ago

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