微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Netlogo:海龟检查它是否可以移动到一个有效的目标

如何解决Netlogo:海龟检查它是否可以移动到一个有效的目标

我正在尝试模拟访问当地企业的社区。有两个品种的补丁(家庭和企业)和海龟(人和业主)。该计划是让人们可以在店主在营业补丁期间访问商店,否则将被视为关闭

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

运行一段时间后,我收到错误 MOVE-TO 预期输入是代理但没有收到。 指向 night-move 命令的“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

基本问题是,我标出的那条线实际上是在移动人员并耗尽开放的业务。所以第一个条件首先测试是否有业务空间,并且永远不会被重新测试。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。