如何创建新的海龟并将它们随机放置在GIS地图中?

问题描述 投票:0回答:1

我使用 GIS 数据将海龟放置在环境中。该模型运行5年。每年年底,根据海龟的年收入,我会杀死一只海龟,然后我想在前一只海龟所在的同一 GIS 点中创建一只新海龟。我正在尝试下面编写的代码行,但出现以下错误:

this code can't be run by a turtle, only the observer
error while TAK 6244 running GIS:CREATE-TURTLES-INSIDE-POLYGON
  called by (anonymous command: [ this-vector-feature -> gis:create-turtles-inside-polygon this-vector-feature TAK 1 [ set shape "house" set size 0.9 set color 17 ] ask minhealth [ die ] ])
  called by procedure less-profitable
  called by procedure GO
  called by Button 'go'

我的代码:

to less-profitable 
    let minhealth one-of RES with-min [annual-earnings-h]
     let minunhealth one-of TAK with-min [annual-earnings-nh]
     ifelse ([annual-earnings-nh] of minunhealth < [annual-earnings-h] of minhealth)
      [ask minhealth [foreach gis:feature-list-of healthy-dataset [this-vector-feature -> gis:create-turtles-inside-polygon this-vector-feature RES 1 [set shape "house" set size 0.9 set color 57] ask minunhealth [die]]]]
    [ask minunhealth [foreach gis:feature-list-of unhealthy-dataset [this-vector-feature -> gis:create-turtles-inside-polygon this-vector-feature TAK 1 [set shape "house" set size 0.9 set color 17] ask minhealth [die]]]]
    end
netlogo agent-based-modeling
1个回答
0
投票

免责声明:我不太熟悉 GIS 软件包

GIS:CREATE-TURTLES-INSIDE-POLYGON
是一个观察者上下文过程。因此乌龟不能调用它。 然而,您可以在观察者上下文而不是海龟上下文中执行您的过程。看看你的代码,似乎
RES
TAK
是你用来创建新海龟的相关海龟自己的变量,但除此之外,我看不出有任何理由让它在海龟中运行上下文。

  ifelse ([annual-earnings-nh] of minunhealth < [annual-earnings-h] of minhealth)
   [
      let the-RES [RES] of minhealth
      foreach gis:feature-list-of healthy-dataset [this-vector-feature -> gis:create-turtles-inside-polygon this-vector-feature the-RES 1 [set shape "house" set size 0.9 set color 57] ask minunhealth [die]]
   ] [
      let the-TAK [TAK] of minunhealth
      foreach gis:feature-list-of unhealthy-dataset [this-vector-feature -> gis:create-turtles-inside-polygon this-vector-feature the-TAK 1 [set shape "house" set size 0.9 set color 17] ask minhealth [die]]
   ]

我还想知道为什么

ask minhealth
部分位于
foreach
内。目前,您尝试为每个功能杀死一次。

© www.soinside.com 2019 - 2024. All rights reserved.