Error: You can't use % in a turtle context, because % is observer only

Error: You can't use % in a turtle context, because % is observer only

我知道有很多关于这个错误的问题(和答案),但不幸的是我还没有修复我的代码中的错误,现在还没有,即使按照过去的答案。我希望你能帮我解决这个问题。我知道有些东西因为问其中一个 A 而不起作用,但我不知道如何以不同的方式实现它,以便要求代理创建一个新对象。 当我在 go.
中调用过程 create_object 时出现错误消息 品种 Aagenda 的所有者。 品种 objectatt1

的拥有者
to go
  ifelse random-float 1 < 0.5
  [ ask one-of A
     [
      ifelse empty? agenda

      [ ifelse random-float 1 < 0.5
        [create_object]  ;; this returns the error message
        [remove_object] 
      ]
     ]
   ]
[...]
end

错误来自 create_object。 定义如下

to create_object

  create-object 1[
          hide-turtle
          set att1 random-float 1  
          let this-post myself ; is it the same object that I am creating?
        if (condition1= TRUE)
              [set agenda fput this-post agenda] ; this should add the object in the agent A's list
         ]
end

不知道您是否需要更多代码。 如果您需要更多信息,请随时发表评论。

谢谢

'A' 和 'object' 都是海龟品种吗?如果是这样,则您有一只乌龟(品种 A)调用一个过程,在该过程中它试图创建一只乌龟(品种对象)。但是,如果您查看 Netlogo 词典,您会发现 create-turtles(以及其他形式如 create-object)仅在观察者使用时有效,而在乌龟使用时无效。

如果你想要一个海龟创建一个新的海龟,你需要hatch命令。请注意,新孵出的海龟将具有与父海龟相同的属性(例如位置)。