0

我一直在开发一个程序,让“人类”特工从 0600 到 1200 小时向南移动到森林中,然后从 1200 到 1800 离开森林。目前所有的人类特工都在 0600 开始进入。这会产生波浪效应,但相反,我想要源源不断的人流。我想到的一个选择是让它们中的一个随机子集从 0600 开始移动,另一个子集从 0700 开始,依此类推,直到 1200 时它们都转身返回。或者,最好在每个早上的时间(即 0600,0700,0800,0900,1000,1100)生成一组新的“人类”搬进来,而不是选择随机子集。我已经坚持了一段时间,任何帮助将不胜感激。我有下面的代码。——尼尔

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
4

0 回答 0