如何在我要求死亡的 NetLogo 中存储代理的 xy 坐标?

How can I store the xy coords of an agent in NetLogo that I ask to die?

在我的模型中,我生成了很多海龟,这会减慢速度。我可以通过杀死它们并拥有一个全局计数器来解决这个问题:

ask turtles [
 if energy < 0 [
 set turtle-count turtle-count + 1
 die
  ]]

但我也希望能够提取这些代理的 'who'、'xcor' 和 'ycor'。我怎样才能做到这一点?

谢谢

您可以将这些值保存在外部文件中。我想这会对你的设置有所帮助,不确定你是否可以直接复制粘贴。

设置模拟:

to setup
    ....
    set-current-directory user-directory ;;choose directory of file  
    file-open "database.txt" ;;choose any name for your file  


    ask turtles 
    [
         if energy < 0 
         [  
             write-to-file ;;go to the writing section  
             set turtle-count turtle-count + 1  
             die  
         ]
    ]


    ....
end 



to write-to-file  
    file-write who  
    file-write xcor  
    file-write ycor  
    file-print "" ;;new line for next turtle
end

结束你的模拟
file-close-all ;;save the file

如果你打开 txt 文件,它可能看起来一团糟,但是导入它,例如,在 excel 中用 space 分隔,你将能够很好地阅读所有内容

编辑1

您还可以执行以下操作,这可能会加快您的模拟速度(而不是向每只海龟询问一个 if 函数)

ask turtles with [energy < 0] 
     [  
         write-to-file ;;go to the writing section  
         set turtle-count turtle-count + 1  
         die  
     ]

也许有经验的人可以评论一下是否是这种情况?