我一直在为'人'代理人开发一个向南移动的程序 森林从0600到1200,然后从1200到1800离开森林。 目前所有的人类代理人都在0600开始行走。这造成了一股浪潮 效果,但我想要一个连续的人类流。一个选择我 想到的是他们的随机子集开始在0600开始移动,另一个 子集从0700等开始,直到1200,当他们全部转身并返回时 出。或者,在每个人身上生成一组新的“人类”可能会很好 早上(即0600,0700,0800,0900,1000,1100)搬入,而不是 选择随机子集。我已经坚持了一段时间并且有任何帮助 非常感谢。我有下面的代码。 --Neil
to setup
ca
clear-all-plots
clear-output
set typeAgro 1 ;this is Agricultural land outside forest
set typeTrop 2 ;this is tropical forest
ask patches
[ set habitat typeAgro ]
ask patches with [pycor <= 300] ;all patches south of y-coord 300 is tropical
forest
[ set habitat typeTrop]
create-humans number-humans ;on a slider from 100 to 200
[ setxy random-xcor 310 ; start humans in agricultural land just north of
tropical forest
if any? turtles-on patch-here
[ setxy random-xcor 310 ]
set morning 6
set midday 12
set afternoon 18
set midnight 24
set step-size 50
set color white
set size 10
set shape "person" ]
reset-ticks
end
to go
tick
ask humans [move-humans] ; humans moving into the forest
end
to move-humans
let hour ticks mod midnight ; sets the ticks on 24 hour day
if morning <= hour and hour < midday [ ; from 0600 to 1200 people move into
forest
set heading (random-normal 180 30)
fd random-normal step-size 4
]
if midday <= hour and ycor < 310 [ ; from 1200 to 1800 people move out of the
forest
set heading (random-normal 360 30)
fd random-normal step-size 1
]
end