我想创建沿同一类型的线,因为这视频的模拟(1:29 - 1:45)的NetLogo代码的问题,海龟找不到补丁在0,0
https://www.youtube.com/watch?v=pqBSNAOsMDc
我认为一个简单的方法来实现一个无限循环procress将是使海龟面对0,0,然后寻找半径90的空补丁(所以他们总是只是看向右边
我得到错误代码..
'没有标题定义从一个点(3 ,-6)到同一点。 '
有人可以用我的代码指向正确的方向吗?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
turtles-own [ faction ]
to setup
clear-all
ask patches [ set pcolor white ]
set-patch-size 7
resize-world min-pxcor max-pxcor min-pycor max-pycor
ask patch 0 0
[ ask patches in-radius (max-pxcor * .6) with [ random-float 100 < density ]
[ sprout 1
[
set shape "circle"
assign-factions
set color faction-color
set size 1 ] ] ]
ask turtles-on patch 0 0 [ die ]
reset-ticks
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to-report faction-color
report red + faction * 30
end
to assign-factions
let angle 360/factions
foreach n-values factions [?] [
ask patch 0 0 [
sprout 1 [
set heading ? * angle
ask turtles in-cone max-pxcor angle [ set faction ? + 1 ]
die ] ] ]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
ask turtles
[ set heading (towards patch-at 0 0) ; adjusts heading to point to centre
let empty-patches neighbors with [not any? turtles-here]
if any? empty-patches in-radius 90
[ let target one-of empty-patches
face target
move-to target ]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
我不认为要求空半径90英寸的半径将实现你的想法。但我会让你为自己弄清楚这一部分。你总是可以问另一个问题... –