Reputation: 1500
I have individuals (turtles) and I have households (turtles with fixed xy) I have a variable address stored at households. I have a number of a family attached to individuals. The households has the same number. How can I ATTACH or MOVE the individuals to their corresponding household? I tried something like:
ask individuals
[ if family = [family-place] of household
[
move-to [address] of household
]
]
Upvotes: 1
Views: 1314
Reputation: 30453
I'm having trouble understanding your question, so I've having to guess at what you want, but with the help of your comment on Bryan's answer, maybe I've guessed right?
ask individuals [
move-to one-of households with [address = [family-place] of myself]
]
if this seems confusing because of the myself
, you could also write it as:
ask individuals [
let f family-place
move-to one-of households with [address = f]
]
Upvotes: 0
Reputation: 21
Since it is a slow monday morning, here is how I would do it. I assume familiy-number to be the name of the common number in both moving and sessile turtles. I would use let to create a local variable that only works within the procedure. (See the procedure go-home for this)
breed [walkers walker]
breed [houses house]
houses-own [family-number]
walkers-own [family-number]
to setup
clear-all
set-default-shape houses "house"
create-houses 10 [
setxy random-xcor random-ycor
set family-number random 10000
]
reset-ticks
end
to leave-home
ask houses [
hatch-walkers 1 [
set family-number [family-number] of myself
set color [color] of myself
set heading random 360
fd 1
]
]
end
to go
ask walkers [
rt random 120
lt random 120
fd 1
]
tick
end
to go-home
ask walkers [
let family-place one-of houses with [family-number = [family-number] of myself]
move-to family-place
fd 1 ;; walker will step away one step so we can see him.
]
end
Just copy it into NetLogo, make a button for each procedure and play. Works best if in the order
setup
leave-home
go
go-home
Hope this helps!
Upvotes: 2