Netlogo let8/16/2023 We use let in this model because it allows us to not rewrite a longer piece of code again and again ( other turtles-here). Two situations might occcur: either a sad turtle will make its friend sad or a happy turtle will make its friend happy. Every time two turtles are on the same patch, one turtle will ask the other to change its shape. In the model example below, we have some happy and some sad turtles. Set total-outcome (total-outcome + new-outcome) For example, if we wanted a turtle to roll 6 dices and report the sum of the dices, we could use let as shown below: to-report roll-six let is very useful for calculating temporary values or creating temporary agentsets. Once you create a local variable with let, you can then use the set primitive to assign it a new value. Look up the let command, which can bind a name to a value at NetLogo’s command line. Set my-friends (lput new-friend my-friends) Let people-nearby (other turtles in-radius 2) Similar to a global variable, a local variable's value is the same for all the turtles. A local variable is a variable that only exists within the procedure it was created in or within the brackets of a specific ask statement. You could then ask owners to do something, which you can not do with a list of who numbers.Let creates a new local variable and sets its initial value. to-report midpoint s let x 0 xcor of midpoint let y 0 ycor of midpoint. Global variables are known to all procedures, local variables are known only to. As secondary effect, this new turtle will connect with the extremes of the segment. after the distance between him and his neighbours is more than that distance, this turtle can start to move. Set owner highlanders with Īnd get an set of owners. Netlogo differentiates two type of variables global and local variables. I am trying to write code in Netlogo to ask turtles wait for a certain time (eg:2 seconds) if his neighbours are less than a certain distance. Or if there were more than one owner like that, you could say Set owner of highlander with īut you'd need to be careful there was only one such brown-haired highlander or you would have the owner be a list of all the brown-haired highlanders. Of course you could also make the owner the self of the highlander with brown hair, eg., When you set owner to self, you are saying that the owner is literally me. When you set owner-id to who, you are making the owner-id a number that does in fact link back to a particular agent. And, indeed, very little would be lost of NetLogo dropped who numbers altogether. Because the self belongs to the agent, and not the system, it is more in keeping with the philosophy of agent-based modeling to use "self"s rather than sequence numbers to refer to them. I don't know how they are represented internally, but NetLogo can create lists of them, or sets of them. The desktop version of NetLogo is recommended for most uses See here for more information on how to use NetLogo Web. Each agent, of course, knows its self and NetLogo keeps track of all the agents' selves internally. Perhaps you could think of it as the agent's name, or even its anima. Each agent is unique, and thus each agent has its own identity, its "self". self, on the other hand, belongs to the agent itself. who numbers are actual (interger) numbers, in this case, sequence numbers, as you would expect. Since each agent is created one at a time, each agent has a unique place in the order, and thus a unique who number. You can think of who as a sequence number that the system uses to keep track of the order of each agent's creation. So, let me see if I can help with self vs who.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |