首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Netlogo:如何使用with,if语句或else添加一些条件?

Netlogo:如何使用with,if语句或else添加一些条件?
EN

Stack Overflow用户
提问于 2017-07-22 10:54:27
回答 1查看 283关注 0票数 0

我想要计算在路上停下来的乌龟的数量,我想取X坐标信息,并将其设为队列长度。以下是示例程序。

代码语言:javascript
复制
ask turtles with [ not right-end ] ;a flag "right-end" to the red turtle for differentiation to the other blue turtles
[
  ask turtles with [ speed = 0 ] ;the speed is 0 means stopped
  [
    set top max-one-of turtles [who] ;get a turtle with biggest id
    set topx [xcor] of top
    set L count turtles with [xcor > topx] ; L is the queue length of Little's Law
  ]
]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-23 01:45:27

我很难确切地理解你想要做什么,但我认为是这样的:

代码语言:javascript
复制
to-report countRightmost ;global context
  let ts (turtles with [speed = 0 and not right-end] )
  let top max-one-of turtles [who]
  let topx [xcor] of top
  report count ts with [xcor > topx]
end
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45250194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档