如何制作长度为67的随机二进制列表 [英] How to make a random binary list of lenght 67

查看:78
本文介绍了如何制作长度为67的随机二进制列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇文章(这是我与netlogo的第一篇文章),所以我会尽量简洁:

This is my first post here (as is my first work with netlogo) so I'll try to be concise:

我正尝试为爱普斯坦(Epstein)和阿克斯泰尔(Axtell)在GAS中编写的海龟列表(第73页).

I'm trying to write a list for my turtles like Epstein and Axtell did in GAS (p. 73).

直到现在,我仍未尝试此操作.

Until now I tried this with no results.

to setup-culture-tags                                     ;set variable
  let initial-culture-tags n-values 67 [ random 2 ]       ;create a random 
                                                           binary list of 67 
  set culture-tags initial-culture-tags                   ;
end

创建列表后,我想根据0的数量对它们进行分类.例如,"00011"将是蓝色",而"00111"将是红色".

After making the list I would like to classify these based on the number of 0s. For example "00011" would be "blue" and "00111" would be "red".

这里的想法是给乌龟一个长度为67的随机二进制列表.然后,它们将进行交互并根据标签翻转"来更改其值: 对于每个邻居,随机选择一个标签. 如果邻居同意该位置的代理,则不会进行任何更改.如果他们不同意,则将邻居的标签翻转为与代理的标签一致.

The idea here is to give the turtles a random binary list of length 67. Then, they'll interact and change its values based on "tag-flipping": For each neighbor, a tag is randomly selected. If the neighbour agrees with the agent at that position, no change is made; if they disagree, the neighbor's tag is flipped to agree with the agent's tag.

我不知道这是否是一个愚蠢的问题,但是我开始感到沮丧,因此,我将不胜感激.

I don't know if this is a stupid question but I'm beginning to feel frustrated so I would appreciate a little help.

推荐答案

不确定确切的错误信息,但似乎您正在尝试全局设置turtles-own变量.如果culture-tagsturtles-own变量(如果您希望所有海龟都拥有自己的culture-tags列表,则必须为变量),您必须使用ask turtles [ ...要求每只海龟填充所需的列表.试试这个:

Not sure exactly what error you're getting here, but it looks like you may be trying to globally set a turtles-own variable. If culture-tags is a turtles-own variable (which it must be if you want all turtles to have their own culture-tags list), you must use ask turtles [ ... to ask each individual turtle to populate the list you want. Try this:

turtles-own [ culture-tags ]

to setup

  ca
  reset-ticks
  crt 10

  ask turtles [
    set culture-tags n-values 67 [ random 2 ]        
  ]

  ask one-of turtles [
    show length culture-tags
    show culture-tags
  ]

end

要获取零/一的计数,请查看filter的词典条目,然后尝试将其与length组合.

To get your counts of zeroes / ones, check out the dictionary entry for filter and try combining it with length.

这篇关于如何制作长度为67的随机二进制列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆