Reputation: 23
We are modeling an interaction between two agents using the function "let" similar to the wolf-sheep model. When the agent1 is in the same space as agent2, agent2 (prey) needs to get the variable a with the same value as the variable a from agent1 (predator).
Something similar to:
ask agents [
let prey one-of agents-here [
ask prey set a "the variable a from agent"
]
]
Upvotes: 1
Views: 85
Reputation: 17678
What I think you want (not tested) is this:
ask agents
[ let prey one-of agents-here
ask prey
[ set varname [varname] of myself
]
]
It appears your question is not really about let
, which is simply saying 'make the variable value the result of some statement'. Since the not-coded bit was about how to obtain the value of 'variable a of agent' then I think your question was about myself
.
The bit [] of
says 'get the value of a variable belonging to some agent' and myself
sort of jumps out a level of brackets to find the agent to which the variable belongs.
As a side note, it's probably not a good idea to have 'agents' as your turtles
breed
because it will be difficult to talk about your model - the word 'agent' will refer to one of your types of agent as well as being the general class of agents.
Upvotes: 3