NetLogo 之 FAQ(部分)

1.How do I give my turtles “vision”?
You can use in-radius to let a turtle see a circular area around it.
Several primitives let the turtle “look” at specific points. The patch-ahead primitive is useful for letting a turtle see what is directly in front of it. If you want the turtle to look in another direction besides straight ahead, try patch-left-and-ahead and patch-rightand-ahead.
If you want the turtle to have a full “cone” of vision, use thei n-cone primitive.
You can also find out the next patch a turtle would cross into if it moved forward continuously. See Next Patch Example, in the Code Examples section of the Models Library.

2.How can I keep two turtles from occupying the same patch?
See One Turtle Per Patch Example, in the Code Examples section of the Models Library.

3.Does NetLogo have arrays?

Nearly all models should just use lists for this.
The usual motivation for using arrays in other programming languages is that they provide fast random access i(tem) and mutation (replace-item). But NetLogo’s lists, even though they are immutable, now provide near constant time performance on these operations.
Lists in earlier versions of NetLogo (4.1 and 4.0) were simple singly-linked lists and therefore these operations took linear time.
The data structure underlying NetLogo’s lists now is the immutable Vector class from the Scala collections library. It uses 32-wide hash array mapped tries, as implemented by Tiark Rompf, based in part on work by Phil Bagwell and Rich Hickey.
If you are certain you want to use raw, mutable JVM arrays in your model, they are provided by the array extension. See the Arrays & Tables section of the User Manual.

4.Does NetLogo have hash tables or associative arrays?
Yes, using the table extension. See the Arrays & Tables section of the User Manual.

5.How can I use different patch “neighborhoods” (circular, Von Neumann, Moore, etc.)?
The in-radius primitives lets you access circular neighborhoods of any radius.
The neighbors primitive gives you a Moore neighborhood of radius 1, and the neighbors4 primitive gives you a Von Neumann
neighborhood of radius 1.
For Moore or Von Neumann neighborhoods of a larger radius, see Moore & Von Neumann Example in the Code Examples
section of the Models Library.

6.How can I convert an agentset to a list of agents, or vice versa?
If you want the list in a particular order, use the sort or sort-by primitives. The Lists section of the Programming Guide explains how to do this. See also Ask Ordering Example, in the Code Examples section of the Models Library.
If you want the list in a random order, here’s how:
[self] of <agentset>
Because all operations on agentsets are in random order, the resulting list is in random order.
To convert a list of agents to an agentset, use the turtle-set, patch-set, or link-set primitives.

7.I’m trying to make a list. Why do I keep getting the error “Expected a literal value”?
If a list contains only literal values, you can write it down just by putting square brackets around it, like[ 1 2 3].
If you want your list to contain items that may vary at runtime, the list cannot be written down directly. Instead, you build it using the list primitive.

8.BehaviorSpace

How do I measure runs every n ticks?
Use repeat in your experiment’s go commands, e.g.:
repeat 10 [ go ]
to measure the run after every 10 ticks. Essentially you are making one experiment step equal 10 ticks.

9.I’m writing an extension. Why does the compiler say it can’t find org.nlogo.api?
You need to add NetLogo.jar to your classpath when compiling. NetLogo.jar is included with NetLogo.

 参考:

NetLogo 6.2.2 User Manual
https://ccl.northwestern.edu/netlogo/docs/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值