Netlogo 创造一个 Link 和一只乌龟,当他们都击中同一个补丁时
Netlogo Creating a Link with a turtle when they both hit the same patch
也许我对问题的措辞有误,但我想在代码中做的是,当另一只乌龟遇到另一只乌龟时,它们会彼此创造 links
我知道它
to go
tick
make-circle
move
if ticks >= timer1 [stop]
end
to move
ask turtles
[
create-links-with other turtles ;here is where i want to put the code
set heading random 360 fd 1]
create-network
end
to create-network
ask links [
set thickness 0.01 * counter
if [patch-here] of end1 = [patch-here] of end2
[set counter (counter + 1)]
]
end
但我不确定如何在他们见面时向 link 正确表达我该怎么做
为您的计数建立品种变量。然后在与其他海龟位于同一块区域的所有海龟之间创建一个 link。然后在其他海龟遇到原始调用海龟时增加该计数变量。我会注意到我将 count 变量递增了 .5,因为 link 中的每只海龟都会递增它(有 2 只海龟,所以 .5 * 2 = 1)。
links-own [meets]
to setup
clear-all
crt 100 [setxy random-xcor random-ycor ]
end
to go
ask turtles [fd 1]
ask turtles [rt random 90]
ask turtles [ create-links-with other turtles-here]
ask turtles [ ask other turtles-here [ask link-with myself [ set meets meets + .5]]]
end
也许我对问题的措辞有误,但我想在代码中做的是,当另一只乌龟遇到另一只乌龟时,它们会彼此创造 links 我知道它
to go
tick
make-circle
move
if ticks >= timer1 [stop]
end
to move
ask turtles
[
create-links-with other turtles ;here is where i want to put the code
set heading random 360 fd 1]
create-network
end
to create-network
ask links [
set thickness 0.01 * counter
if [patch-here] of end1 = [patch-here] of end2
[set counter (counter + 1)]
]
end
但我不确定如何在他们见面时向 link 正确表达我该怎么做
为您的计数建立品种变量。然后在与其他海龟位于同一块区域的所有海龟之间创建一个 link。然后在其他海龟遇到原始调用海龟时增加该计数变量。我会注意到我将 count 变量递增了 .5,因为 link 中的每只海龟都会递增它(有 2 只海龟,所以 .5 * 2 = 1)。
links-own [meets]
to setup
clear-all
crt 100 [setxy random-xcor random-ycor ]
end
to go
ask turtles [fd 1]
ask turtles [rt random 90]
ask turtles [ create-links-with other turtles-here]
ask turtles [ ask other turtles-here [ask link-with myself [ set meets meets + .5]]]
end