Netlogo 之 agentset 转 List

let whited_patches (list patches with [pcolor = white]);错误方法

print whited_patches

打印结果如下:

[(agentset, 7 patches)]

let whited_patches sort [self] of patches with [pcolor = white];正确方法

print whited_patches

打印结果如下:

[(patch -20 23) (patch -21 21) (patch 19 21) (patch 2 19) (patch -4 18) (patch 4 18) (patch -5 16) ]
 

参考:

list - Converting agentset into list in NetLogo - STACKOOM
https://stackoom.com/en/question/3JQNb

2022/09/09增补如下:

 Extensions · NetLogo/NetLogo Wiki · GitHub
https://github.com/NetLogo/NetLogo/wiki/Extensions

该网址中的Netlogo 扩展“Agentlist” 可以实现快速从Agentset 向list 的转化:

Converts an agentset to a list of agents with a simple primitive agentset-to-list.

猜你喜欢

转载自blog.csdn.net/Jerry_liu20080504/article/details/126542494