如何 link 一个品种的乌龟 x 到另一个品种的乌龟 y?
How to link turtle x of one breed to turtle y of another breed?
我正在尝试 link 品种 x 的个体海龟到品种 y 的个体海龟。以下引发错误:
breed [xs x]
breed [ys y]
to setup
clear-all
create-xs 25 []
create-ys 25 []
ask x 1 [ create-link-with y 2 ]
end
错误说 "x 2 is not a Y" 我不明白,因为我要求在 x 1 和 y 2 之间设置 link。
我很困惑,因为我知道将一只品种 x 的海龟连接到多只品种 y 的海龟确实有效,a la:
breed [xs x]
breed [ys y]
to setup
clear-all
create-xs 25 []
create-ys 25 []
ask x 1 [ create-links-with n-of 5 ys ]
end
我已经阅读了有关 links 和品种的 NetLogo 指南,但我没有看到任何具体解决此问题的内容。
单link版本可以吗?
谁的编号分配给所有海龟,而不是每个品种。所以例如create-link-with y 27
会成功。您的 xs 编号为 0 到 24,您的 ys 编号为 25 到 49。
(顺便说一句,请注意,使用 who 编号根本不是一个好主意 — 至少在实际代码中,而不是进行小的测试和实验。create-link-with one-of ys
也可以工作并避免涉及谁的号码。)
我正在尝试 link 品种 x 的个体海龟到品种 y 的个体海龟。以下引发错误:
breed [xs x]
breed [ys y]
to setup
clear-all
create-xs 25 []
create-ys 25 []
ask x 1 [ create-link-with y 2 ]
end
错误说 "x 2 is not a Y" 我不明白,因为我要求在 x 1 和 y 2 之间设置 link。
我很困惑,因为我知道将一只品种 x 的海龟连接到多只品种 y 的海龟确实有效,a la:
breed [xs x]
breed [ys y]
to setup
clear-all
create-xs 25 []
create-ys 25 []
ask x 1 [ create-links-with n-of 5 ys ]
end
我已经阅读了有关 links 和品种的 NetLogo 指南,但我没有看到任何具体解决此问题的内容。
单link版本可以吗?
谁的编号分配给所有海龟,而不是每个品种。所以例如create-link-with y 27
会成功。您的 xs 编号为 0 到 24,您的 ys 编号为 25 到 49。
(顺便说一句,请注意,使用 who 编号根本不是一个好主意 — 至少在实际代码中,而不是进行小的测试和实验。create-link-with one-of ys
也可以工作并避免涉及谁的号码。)