根据对龟自己的变量的操作创建列表
问题描述:
我有3只海龟,每个都有一个大小变量。我想创建一个维度3的列表,它基本上是每个乌龟相对于总大小的%支持大小。名单应该像根据对龟自己的变量的操作创建列表
[turtle1-size/sum[size] of all turtles
turtle2-size/sum[size] of all turtles
turtle3-size/sum[size] of all turtle]
我知道有海龟,自己和补丁,自己的名单,但将只包含龟/补丁名称本身正确的名单?
谢谢,感谢帮助。
问候
答
这里有一个解决方案:
to-report proportions
let total-size sum [size] of turtles
report (list [size/total-size] of turtle 0
[size/total-size] of turtle 1
[size/total-size] of turtle 2)
end
让我们试试吧:
observer> clear-all
observer> create-turtles 3 [ set size who ]
observer> show proportions
observer: [0 0.3333333333333333 0.6666666666666666]
看起来我的权利。