Open kumom opened 5 years ago
Hey, thanks for looking into this! I think you are not the first one to be confused by this, so your work is very much appreciated.
Regarding the tests, yes they will need to be rewritten before any changes can be merged. But it is fine to create the PR first and get some feedback on your changes. Once they are approved you can change the tests and then we can merge
Describe the bug
Code snippet from class
Grid
As you see,
Grid._remove_agent
is clearly assuming a SingleGrid behavior. This is fine. However, it is also assuming thatNone
is defined as an empty cell, which is not whatGrid.is_cell_empty
does:Since
Grid.default_value == None
, it seems ok so far. But I guess we need to make it consistent.So I was thinking
SingleGrid
andGrid
are really the same. By further looking at the classSingleGrid
, I found these two methods in it:Where in class
Grid
they areSo the default behavior of
Grid.place_agent
is replacing the original agent if a cell has one, otherwise place to an empty cell. The default behavior ofSingleGrid.place_agent
on the other hand binds the agent position when a cell is assigned an agent.I think using
position_agent
as another method name just to do the enforcement can be a bit confusing. Plus, its signature does not match withplace_agent
, which can lead to weird bug. For example, I triedposition_agent(agent=agent, pos=(x,y))
when I was implementing a model. My agent got placed to some random position becausey == "random"
. To further improve this issue, we might want to allow users to fix one of the two coordinates and set the other one to "random".I hope I am stating the issues clearly...I would work on it these two days. I never used CI tools like Travis before, and I guess the tests will fail once I do some changes to the overall hierarchy of classes. Should I change the test files at the same time? I am guessing my own test files won't be used any way and the test will fail. Is there any workaround for this?