访问其他代理的列表

时间:2017-03-02 19:26:02

标签: netlogo

我有两个列表,所有代理商都会这样做。我希望一个代理查看代理,看看他的代理号是否在另一个代理的列表中。如果他在另一个代理人的名单中找到他的号码,他必须复制该另一个代理人的号码。怎么样?

if attracted != nobody [set attractinglists fput ([who] of attracted) attractinglists]

if attracted != nobody [set attrlists fput ([who] of attracting) attrlists]

to-report contains-any?
let attrlistss [attrlists] of myself
if attractinglists != nobody [foreach attractinglists [if member? ? attrlistss [report true]] report false]
end

let lisstt list self contains-any?

1 个答案:

答案 0 :(得分:0)

听起来每只海龟都想要一张其他海龟的清单,这些海龟在他们被吸引到的海龟名单中有一只乌龟的身份。这是一个简单的模型,可以为您提供指导。一般来说,你不应该使用谁的数字而这个模型没有。

turtles-own [
  attracted-to
  attracted-to-me
]

to setup
clear-all
reset-ticks
create-turtles 100 
ask turtles [
  ; each turtle picks 20 random turtles to be attracted to.
  set attracted-to n-of 20 other turtles
]
end

to go
ask turtles [
  set attracted-to-me [self] of other turtles with [member? myself attracted-to]
]
ask turtles [show attracted-to-me]
end

希望这有帮助。