我目前有一个代理组(端口)孵化另一个代理组(船舶)。这个想法是让船只面对离它们当前位置最近的港口。
[let target min-one-of ports [distance myself]
face target]
.
不幸的是,这使得船只面对它们当前的位置,因为它们是在给定的港口孵化的。如果无法排除它们孵化的端口 - 我有一个位置(端口)的索引,并且可能将目标设置为索引中的以下项目,但是我不确定我将如何实现这一点。有什么建议么?
完整的代码示例
breed [ships ship]
breed[ports port]
to setup
let index 0
create-ports 3
[ let loc item index [ [459 -324] [670 -233] [677 -356] ]
setxy (item 0 loc) (item 1 loc)
set index index + 1
set shape "circle"
set size 5
set color red - 1]
ask ports
[ hatch-ships 1
[ set size 10
set color red
pen-down
set pen-size 1
let target min-one-of other ports [distance myself]
face target] ]
reset-ticks
end