Netlogo:乌龟检查它是否可以进入有效目标

Netlogo: Turtle checking if it can move into a valid target

我正在尝试模拟访问本地企业的社区。有两种斑块(家庭和企业)和海龟(人和所有者)。计划是让人们能够在店主在商业补丁上访问商店,否则将被视为关闭。

一天分为三个时间点:上午、下午和晚上。所有商店通常在早上和下午,但随机数量的业主在晚上回家。如果商店不可用,业主就会回家。

运行 一段时间后,我收到错误 MOVE-TO expected input to be an agent but got NOBODY instead. 指向“ifelse”部分晚上移动命令。

感谢您的帮助!

to go
  morning-move ;Morning movement (First shopping phase)
  tick

  afternoon-move ;Afternoon movement (Second shopping phase)

  tick

  evening-move ;Evening movement (Return home)

  tick

end

to morning-move
  ask owners [move-to work-xy] ;make owners open their businesses
    ask people [ifelse any? open-busi-patches with [any? owners-here and count people-here < MaxCapacity] ;This checks if there are open businesses
    [ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
    [ask people [move-to home-xy]]]
  ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end

to afternoon-move
  ask people [ifelse any? open-busi-patches with [count owners-here > 0 and count people-here < MaxCapacity] ;This checks 
    [ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
    [ask people [move-to home-xy]]]
  ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end

to evening-move
  ask n-of random count owners owners [move-to home-xy] ;This choses a random number of owners to stay open in the evening.
  ask people [ifelse any? open-busi-patches with [any? owners-here and count people-here < MaxCapacity] ;This checks 
    [ask people [move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]]] ;move people to businesses under capacity
    [ask people [move-to home-xy]]]
  ask open-busi-patches [set OpsProfit OpsProfit + count people-here] ;cumulative count of patrons
end

所以这是给你错误的代码(重新格式化)

to afternoon-move
  ask people
  [ ifelse any? open-busi-patches with [count owners-here > 0 and count people-here < MaxCapacity ]
    [ ask people ;;;; THIS LINE
      [ move-to one-of open-busi-patches with [any? owners-here and count people-here < MaxCapacity]
      ]
    ]
    [ ask people
      [ move-to home-xy]
    ]
  ]
  ask open-busi-patches [set OpsProfit OpsProfit + count people-here]
end

基本问题是我标记的那条线实际上是在移动人们并用尽开放的业务。所以第一个条件最初测试是否有 space 的企业,并且它永远不会被重新测试。