试图获取单个 <process> 的 who id:"cpu 0 is not a <breed-name>. error while observer running <breed-name> "

trying to get who id of a single <process> : "cpu 0 is not a <breed-name>. error while observer running <breed-name> "

我正在尝试获取单个进程的 who id(该进程是一只乌龟)但我收到此错误:“cpu 0 is not a PROCESS error while observer 运行 PROCESS . 由程序 GO 调用。由按钮 go 调用

我需要这个 who id 因为我希望只有队列的第一个进程(具有最大优先级的进程)可以到达 cpu 的 cpu 核心。

我发现当我要求单个进程执行指令时会出现错误。它不关心动作是什么(我试图改变指令)。问题是 "ask process N [...] ".

to go

    if ticks > 0 and  ticks mod 10 = 0 and number-of-processes < max-number-of-processes
  [

      create-processes 1[
        set color green
        set shape "square"
        set size 2
        set xcor 0
        set ycor 0
      ]
      ;set whonumber  [who] of  process current-process  --> it'doesn't work.. same error below
      ask process current-process [set whonumber  who ] ; --> current-proces is a variable that start to 0.. yeah i've tried also to put 0 instead.. doesn't work
      set mylist lput one-of processes with[who = whonumber] mylist

      set number-of-processes  number-of-processes + 1
      set current-process  current-process + 1 ;verificare se quando muore un processo l'assegnazione sia sempre sequenziale oppure debba fare -1 in caso di die
  ]


  ;TO DO :  MOVE THE SPAWNED PROCESS TO THE (turtle)QUEUE IF POSSIBLE


  ask processes [show who]

   if any? cores with [core-taken = false] and number-of-processes > 0 [
   ; ask cores with [xcor =  ([xcor] of one-of other processes)] [set core-taken true]   ---> doesn't work.. the comand face doesn't reach the same core coord...
    ask processes with[ who  = [who] of process item 1 mylist]  [face  unused-core forward 1]  ; this action in the future will be done by the first project in the turtle queue

  ]

 tick
end

感谢帮助

错误告诉您 0 号海龟实际上是品种 cpu,而不是品种过程,但您的代码将其视为一个过程。我的猜测是你有 0 作为列表中返回的数字,然后你说 ask process 0 并且 NetLogo 告诉你没有 'process 0'.

这种问题就是为什么在代码中使用 who 数字通常不是一个好主意。它们在您创建海龟时按顺序分配。不要在列表中包含 who 个数字,而只需列出一个海龟列表即可。