projectmesa/mesa

Make connections in experiment cell spaces named

quaquel opened this issue · 0 comments

What's the problem this feature will solve?
Currently the connections of Cell are stored as a list in _connections. While developing cell space, it was suggested to replace this with a dict with named connections. This would make it possible to get the cell to, e.g., the left or right, top or bottom in case of a von Neumann grid. Once connections are named, all kinds of other movements over the cell space are easily expressed.

For example, it becomes trivial to retrieve all cells on a diagonal in a Moore grid.

# within an agent class
startcell = self.cell
cell = None
diagonal = []
while cell is not startcell:
    cell = cell.connections['top_left']
    diagonal.append(cell)

Describe the solution you'd like
The largest challenge is to come to a clear naming of the connections. This is likely to be different across OrthogonalMooreGrid, OrthogonalVonNeumannGrid, and HexGrid. Moreover, it might not work for Network, and become tricky for n-dimensional grids