NetLogo LevelSpace报错:已执行reset-ticks仍提示未启动滴答计数器
NetLogo LevelSpace扩展代码问题
正在学习使用NetLogo的LevelSpace扩展,被调用的FlockingModified.nlogo本身无任何错误,现有三段代码分别存在以下问题:
1. A段代码问题
能运行但无法改变id_world,达不到预期效果:
to setup ls:reset ca ls:create-interactive-models number_worlds "FlockingModified.nlogo" ls:ask ls:models [ setup ] reset-ticks end to go clear-all ls:ask ls:models [ go ] let number_centroids [count centroids] ls:of ls:models let x_centroids [ListXCentroids] ls:of ls:models let y_centroids [ListYCentroids] ls:of ls:models let heading_centroids [ListHeadingCentroids] ls:of ls:models foreach ls:models[ i -> let id_world i let number_centroid item id_world number_centroids let xcoords item id_world x_centroids let ycoords item id_world y_centroids let headings item id_world heading_centroids loop [ if number_centroid = 0 [stop] create-turtles 1 [ set color 15 + 10 * id_world setxy last xcoords last ycoords set heading last headings ] ;this is a home made pop, equivalent to java pop set xcoords but-last xcoords set ycoords but-last ycoords set headings but-last headings set number_centroid number_centroid - 1 ] tick end
2. loop版本代码问题
无法执行到set models but-last models语句:
loop[ if empty? models [stop] let id_world last models let number_centroid item id_world number_centroids let xcoords item id_world x_centroids let ycoords item id_world y_centroids let headings item id_world heading_centroids loop [ if number_centroid = 0 [stop] create-turtles 1 [ set color 15 + 10 * id_world last xcoords last ycoords set heading last headings ] ;this is a home made pop, equivalent to java pop set xcoords but-last xcoords set ycoords but-last ycoords set headings but-last headings set number_centroid number_centroid - 1 ] ;;it never gets to here set models but-last models ]
3. while版本代码问题
功能符合预期,但仅在首次tick后抛出错误:
The tick counter has not been started yet. Use RESET-TICKS. error while observer running TICK called by procedure GO called by Button 'go'
代码:
let models ls:models while [not empty? models] [ let id_world last models let number_centroid item id_world number_centroids let xcoords item id_world x_centroids let ycoords item id_world y_centroids let headings item id_world heading_centroids while[number_centroid > 0] [ create-turtles 1 [ set color 15 + 10 * id_world setxy last xcoords last ycoords set heading last headings ] ;this is a home made pop, equivalent to java pop set xcoords but-last xcoords set ycoords but-last ycoords set headings but-last headings set number_centroid number_centroid - 1 ] set models but-last models ]
内容的提问来源于stack exchange,提问作者MatMad-B
相关产品推荐
相关产品推荐

