【发布时间】:2020-12-05 04:00:43
【问题描述】:
我正在尝试创建一个代码,让我可以获取 10 只海龟的编号并将它们存储在一个列表中。但是,“谁”号码只有在之前没有被添加到列表的情况下才能被添加到列表中。
我必须使用“foreach”命令来检查号码是否已经添加到列表中。
有什么建议吗?
我的代码:
turtles-own [contact-list]
to setup
clear-all
create-turtles 10 [
set contact-list []
print who
]
reset-ticks
end
to go
ask turtles [
set contact-list lput [who] of one-of other turtles-here contact-list
foreach contact-list[
; this is where the command goes
]
print contact-list
]
end
【问题讨论】:
标签: netlogo