【发布时间】:2020-10-24 16:40:41
【问题描述】:
我正在尝试为海龟创建一个移动到相邻补丁的速率模型。最终,我希望海龟在特定条件下孵化 8 只潜在的其他海龟,每只海龟根据它们的方向专门前往它们的邻居之一。基本上我想将邻居补丁指定为北邻居、南邻居、东邻居、西邻居、西北邻居等。从那时起,我希望创建每只海龟以移动到特定的补丁。每个补丁变量有 8 个移动速率:向北移动的速率、向南移动的速率等等。所以我希望这 8 只海龟以它们邻居补丁的速度移动到它们的特定补丁。在它到达其北邻居的中心后,我希望重置北邻居变量,以便新的北邻居是旧北邻居的北邻居。这是一个仅指定北邻的代码示例(我计划为北邻、南邻等设置单独的程序。
patches-own[I-b-N heat-sink-N ROM-N ROM-S]
to setup[
ca
reset-ticks
crt 1 [
set shape "triangle"
set color red
]
ask patches[
set pcolor green
set ROM-N 5
set ROM-S 6 ;here there would be ROS-N ROS-S ROS-E ... for each patch
set I-b-N 8
set heat-sink-N 2
]
]
to go
spread-north
;spread-south
tick
end
to spread-north ;duplicate and modify the same procedure for south, east, west,...
ask turtles [
if xcor = [pxcor] of patch-here and ycor = [pycor] of patch-here[
set N-neighbor [patch-at-heading-and-distance 0 1] of self]
]
ask turtles[ ;I use two ask turtles to make sure N-neighbor is created at the beginning of the procedure
let goal N-neighbor ;here to store N-neighbor
let parent patch-here
if [I-b-N] of parent > [heat-sink-N] of goal[ ;If my patch's North-facing I-b > North heat-sink of North neighbor
hatch 1 [
face goal ;make sure it is facing towards North neighbor
while [xcor != [pxcor] of goal and ycor != [pycor] of goal][
fd 1 / ((ROM-N + [ROM-N] of goal) / 2) ;moves forward a fraction of the distance between patch-here and North neighbor until it has reached the center coordinates of North neighbor
]
set pcolor black
]
end
【问题讨论】:
标签: netlogo patch direction rate