Я хочу напечатать «no path», когда нет больше патчей, которые нужно занять, вместо того, чтобы предупредить ошибкой «MOVE-TO ожидал, что вход будет агентом, но вместо этого получил NOBODY». Я сделал несколько вещей, но не работал. Наконец, я сделал следующее:
ask migrants
[let pot-target patches with [value < 11 and not any? turtles-here]
let target pot-target with [count neighbors with [any? turtles-here with [value < 11]] >= 1]
if target = 0 [print (word "no patch")]
if (target != 0 and (status != "resident")) [move-to min-one-of target [value]
set status "resident"
set color blue]
]
Вот полный код
breed [migrants migrant]
breed [residents resident]
patches-own [value]
turtles-own [income
status]
to setup
ca
let total problo + probmid + probhi
if (total != 100)
[print (word "prob is more than 100")]
ask patches [set value random-normal 10 3
let patch-value value
set pcolor scale-color (gray - 5) patch-value 10 3]
ask patches
[if random 100 < 3
[sprout-residents 1
[set color red
set shape "default"
set size 1
set status "resident"
]
]
]
end
to go
ask patches
[if random 100 < 1
[sprout-migrants 1
[set color green
set shape "default"
set size 1
set status "migrant"
set-move
]]]
end
to set-move
ask migrants
[let pot-target patches with [value < 11 and not any? turtles-here]
let target pot-target with [count neighbors with [any? turtles-here with [value < 11]] >= 1]
if target = 0 [print (word "no patch")]
if (target != 0 and (status != "resident")) [move-to min-one-of target [value]
set status "resident"
set color blue]
]
end