This comes after reading the documentation tutorial, specifically the part "Defining a space".
I have not understood at all why a user has to define a space by creating a struct. At least not at all for the simple grid cases.
Wouldn't it be much better to avoid all these complications and simply provide simple constructors like:
space = Space(x, y, z; periodic = true, Moore = false)
where internally Space does something like
``
Space(args...; kwargs...) = Space((args...,,), grid(args...; kwags...), instantiate_agents(grid))
````
and returns the resultingstruct? HereSpaceis the standardSpacetype of Agents.jl (currently not existing), which would replace theMyGrid` of the documentation.
From what I have understood, the only information the user _really_ cares about is simply the dimensionality of the space, and whether it is Moore/periodic. Everything else is so that Agents.jl operates internally. Thus this information should stay internal and the user should have to care about it / create a Space struct.
Of course it should be stated that this Space struct contains the actual agent locations, but still this is advanced usage I feel.
Similarly, from the section "Insantiating the model" of the docs one sees:
# 1) Creates an array of empty arrays as many as there are agents.
agent_positions = [Int64[] for i in 1:gridsize(griddims)]
Why would the user have to do this? It happens in every case, so it should happen internally. (If I am missing something, or have missunderstood something, please correct me.)
Note that this doesn't really "change" or over complicate the possibility of using any graph as a space.
Simply define two constructors:
function Space(x, y, z; periodic = true, Moore = true)
# stuff
end
function Space(graph::AbstractGraph)
# stuff (e.g. initialize the stuff)
end
Here both constructors would internally create agent_positions.
The approach proposed here could simplify the construction / initialization phase by a lot I think. It would remove the need of always creating a custom Space struct (e.g. MyGrid). This would now only be necessary for very specific cases of advanced usage.
I think this is a good suggestion. I will try to implement it; I may not be able to move it forward immediately, though, because I am busy preparing some teaching material.
Happy to see that you agree with the suggestion. I also want to remind that it is a suggestion, and this is an open source project, so there is no rush for anything ! :)
I will do this along with #20 (currently working on it already)
What about spaces that aren't grids, e.g. a social graph?
Advanced usage of the interface will remain as is, in the sense that a user will always be able to create any instance of a graph and use it accordingly. The discussion here concerns mostly the convenience function that makes the grids.
Closed in #41
Most helpful comment
Advanced usage of the interface will remain as is, in the sense that a user will always be able to create any instance of a graph and use it accordingly. The discussion here concerns mostly the convenience function that makes the grids.