Beginner user of Agents.jl here …
With a space defined as
space = GridSpaceSingle(..., is it possible to access the underlying grid and its cells in some way, so as to be able to store and retrieve information, eg about the cells’ usage?
For example, in the following example, how would each agent be able to tell which agent has previously passed over the cell? Each one keeps its own history, but the information isn’t shared, so some kind of common storage.
Any tips gratefully received…!
Agents.jl are really only meant to store positions and provide a simple and unified interface. Storing meta-data for each position would therefore need be done separately.
If your two-dimensional grid is of size n \times m then you can simply create a corresponding matrix in
model.properties[:cell_matrix] (or call it whatever) where you track whatever information you need. Whenever an agent passes a cell in position
(x,y), they can then check on the current value of that cell by accessing
model.cell_matrix[x,y] and also update it if need be.
Hope this helps.
P.s.: You can of course also create your own space type instead of using the built-in ones. If you’re so inclined, feel free to check out the part in the docs describing how to do it. In there you could store whatever info you want.
Hi @cormullion , kickass animation as always. You can access the underlying grid by considering a spatial property like @fbanning said. Like it is done in the Sugar scape example here : Sugarscape · Agents.jl Example Zoo the agents move in the discrete grid, but one additional array (with same dimension as grid) is a model property. You can access this array using the agent positions. Each time an agent visits a cell you can do something like:
pos = agent.pos
array = model.property_with_your_name
array[pos...] += 1 # or whatever other modification you want, e.g., merging colors
There are many more models that utilize spatial properties in discrete space, e.g.
I hope this helps! Please do share the animation code
@fbanning @datseris Thanks so much for your replies and pointers, very helpful! The Agents.jl package appears to already have all the tools I need - it’s a very cool package, and the documentation is excellent.
Thanks! I am sure the documentation can be made better with your super cool animation in the Agents Example Zoo!!!