mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Locatable: position updates work differently across spaces

Open souro26 opened this issue 7 months ago • 2 comments

Context

PR #3287 adds the Locatable protocol so that agents and cells can expose a .position interface. Right now, position is handled differently in different places. In continuous space, ContinuousSpaceAgent writes directly into space-managed numpy arrays. In discrete space, CellAgent gets its position from cell.position and does not support setting it directly. With HasPosition, the position is just stored on the agent itself. This means position may currently be stored on the agent, managed by the space, or derived from a cell depending on the implementation. There have also been recent discussions like stacked spaces #3458 that suggest moving toward a more agent-centric way of handling position, especially in cases where an agent may exist in multiple spaces at once.

Problem

Even though Locatable gives a common .position interface, what happens when you actually set position is not consistent. The same line agent.position = value does different things depending on the agent:

  • in continuous space, it updates the space’s internal array
  • in discrete space, it is not supported (position comes from the cell)
  • with HasPosition, it just updates a local variable

From the recent discussions, it seems like the direction might be to treat agent.position as the main source of truth, and have spaces update themselves based on it. In that model, setting agent.position = value would mean the agent changes position, and spaces react to that (update indices, move between cells, etc.). This is different from what we have now, where position may be stored on the agent, managed by the space, or derived from the cell.

Open Questions

  1. Who owns position? Should position live on the agent, or should it stay space specific like it is now?

  2. What should agent.position = value do? Should this work the same way for all Locatable objects? If yes, how should this behave for cell-based agents where position currently comes from the cell?

  3. How should updates propagate? If position is agent-owned, should changing it automatically update all related spaces? Or should each space handle updates in its own way?

  4. How does this work with cells? Right now, movement in discrete space is done like agent.cell = new_cell which indirectly changes position. If agent.position becomes the main thing, how should position to cell and cell to position stay in sync without causing conflicts, inconsistencies, or update loops?

souro26 avatar Apr 03 '26 19:04 souro26

Let's just keep it to #3458 and #2585, Instead of spreading it over multiple issues and discussions

codebreaker32 avatar Apr 03 '26 19:04 codebreaker32

Alright i'll move this into #3458

souro26 avatar Apr 03 '26 20:04 souro26