Random 让海龟从无界世界中的任意位置开始(随机行走360)
我正在使用图书馆的随机行走360模型,只是尝试让海龟从随机位置开始,而不是(0,0)。但不知怎么的,它不起作用。我猜这与代码中允许世界无限的部分有关:Random 让海龟从无界世界中的任意位置开始(随机行走360),random,netlogo,Random,Netlogo,我正在使用图书馆的随机行走360模型,只是尝试让海龟从随机位置开始,而不是(0,0)。但不知怎么的,它不起作用。我猜这与代码中允许世界无限的部分有关: set xc xc + (step-size * dx) set yc yc + (step-size * dy) ; hide turtles who have moved out of the world ifelse patch-at (xc - xcor) (yc - ycor) = nobody [ ht ] [ st set
set xc xc + (step-size * dx)
set yc yc + (step-size * dy)
; hide turtles who have moved out of the world
ifelse patch-at (xc - xcor) (yc - ycor) = nobody
[ ht ]
[ st
set xcor xc
set ycor yc ]
但仍然无法理解如何调整这个代码,使海龟从随机位置开始。
欢迎任何帮助,
谢谢
Kevin在
设置过程中更改此行:
crt num-turtles
致:
可能您没有设置xc
和yc
?在这个模型中,这些变量保持海龟在无限平面上的真实位置。仅仅设置xcor
和ycor
是不够的,它们只代表海龟在世界范围内的位置
crt num-turtles [
setxy random-xcor random-ycor
set xc xcor
set yc ycor
]