1

I want to use "complex objects" in NetLogo, that have several attributes. These are not agents, so they do not "act" from the perspective of the model.

A possible way would be to just use a list for these objects, where each index would be a specific attribute - so for example, if the object has the 3 attributes "price", "weight" and "name", then a list with 3 elements would store it in this order.

Using a turtle - specifically, a breed of turtles - would allow me to name these attributes. This might be useful in the future, as it makes the code way more readable - it is not clear that the second element of the list is weight, for example. However, a turtle suggests that it is an agent/actor.

Is it against conventions to use turtles for modeling non-agents, and I should go with lists? Or is there some third possibility I am not considering?

I tried creating lists in the aforementioned way, but it made way less clear. It was difficult to read and develop for me, so I believe that someone who did not even work on it before would be even more confused.

Edit for clarifications: the objects I want to use would be items, that agents "own". They would have several attributes, and could change ownership during a step of the program. Their attributes would matter for, inter alia, whether two agents want to exchange ownership of these objects, and how much they "pay" or "gain" for them. There would be many of these items, and different instances would get created at different parts of the runtime of the program.

bbkovacs
  • 13
  • 4
  • It seems like you want to do Object Oriented programming in an agent context. While you might be able to do this in Netlogo, other Agent Based tools like Mesa or Unity might be more appropriate as they are based on python/C# respectively – Jumboman Mar 31 '23 at 13:59
  • This is a good use of turtles. Using lists to manage object properties is horrible, and unnecessary. Turtle-owned variables used this way is a natural extension of the NetLogo "Way" – TurtleZero Apr 16 '23 at 03:22

2 Answers2

2

I use separate breeds of turtles as non-agent objects all the time. For example, in our river trout model (https://ecomodel.humboldt.edu/instream-7-and-insalmo-7) the fish are one breed, their nests are another breed (and do nothing but keep track of where the nest is and how many eggs survive), another breed simply holds the variables of habitat cells that are polygons imported from GIS, and another breed (hidden so you don't even see them) holds variables of river reaches.

I don't see anything unconventional or otherwise wrong with your idea; to me it makes perfect sense. I certainly wouldn't recommend giving up all the advantages of NetLogo just because you need something that looks more like standard object-oriented programming.

Steve Railsback
  • 1,251
  • 6
  • 7
  • To further expand this good answer, I use also use turtles as non agent or at least meta agent data structures. I've even implemented a database for the agents, where a "table" breed owns a "rows" variable that is a set of "row" turtle that own variables representing the columns. Also: clocks, animated numbers, UI elements, decorative add-ons, mouse pointer, event listeners, drum machine sequencers... – TurtleZero Apr 16 '23 at 03:17
-1

In principle I don't like the idea of using agents as non-agents, considering that you put it this way. So first I propose a possible solution based on something you mentioned in the question, but later I'll also make an extra consideration.

One approach that would solve the problem that you mentioned with lists would be to use lists of lists, where the first element of each inner list would be the attribute's name and the second element of each inner list would be the attribute's value. Such as:

globals [
  object-a
  object-b
]

to setup
  clear-all

  set object-a (list (list "name" "a") (list "price" 3) (list "weight" 28))
  set object-b (list (list "name" "b") (list "price" 5) (list "weight" 41))
end

or other approaches of this type.

Anyway my question would be: what role do these entities have in your model and how do you plan to use them? The answer to this question would be useful to give a better-targeted answer, including on the topic of whether these things could actually be turtles or not. You started with the assumption that these entities are not agents, but for what we know now they are entities that have varying values of the same attributes, and surely you'll want to use these values somehow... sounds like a good starting point for describing an agent, maybe just belonging to a different breed from the others'.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Matteo
  • 2,774
  • 1
  • 6
  • 22