如何报告链接之间的距离并将报告的这些值用于代码中的其他计算?
How does one report the distance between links and use those values reported for other calculations in code?
我正在尝试计算和报告 NetLogo 中特定代理集之间的距离(link-长度)?有没有办法计算列表的 link 长度?
代理的移动是基于距离(连接)值是否是below/above一个阈值。但是,我很难将 link 长度的值设置为可变连接。 (最好在列表中)。如果有任何帮助,我将不胜感激。
globals[hourly-wage connection]
breed[offices office]
breed[employees employee]
offices-own [
pay-high ;; 7 offices pay well
pay-low ;; 3 offices dont pay well
]
to setup
clear-all
create-offices 10 [
set size 1.0
set color blue
set shape "house"
setxy random-xcor random-ycor
ask offices [create-link-with one-of other offices] ;; undirected links
ask links [set color red]
]
create-employees 2 [
set size 1
set color brown
set shape "person"
]
set hourly-wage 20
end
;;;;
to go
cal-dist
ask employees [
if connection > 15
move-to one-of high-pay office
if connection <= 15
move-to one-of low-pay office
]
end
to cal-dist
set connection [list print link-length] ;;
ask links [show link-length]
set salary (hourly-wage * connection) ;;; salary printed in a list
end
不完全确定你在这里用 connection
等做什么,但你可以使用 of
将任何 link 变量放入列表中 - 例如:
to setup
ca
; First create the agents
crt 5 [
while [ any? other turtles in-radius 5 ] [
move-to one-of neighbors
]
set color blue
set shape "house"
]
; Once they're created, have them link with
; one of the other agents
ask turtles [
create-link-with one-of other turtles [
set color red
]
]
let link-lengths [ link-length ] of links
print link-lengths
reset-ticks
end
我不知道这是否真的回答了您的问题,因此您可能希望提供更多详细信息,说明您尝试使用这些 link 完成的任务。
我正在尝试计算和报告 NetLogo 中特定代理集之间的距离(link-长度)?有没有办法计算列表的 link 长度?
代理的移动是基于距离(连接)值是否是below/above一个阈值。但是,我很难将 link 长度的值设置为可变连接。 (最好在列表中)。如果有任何帮助,我将不胜感激。
globals[hourly-wage connection]
breed[offices office]
breed[employees employee]
offices-own [
pay-high ;; 7 offices pay well
pay-low ;; 3 offices dont pay well
]
to setup
clear-all
create-offices 10 [
set size 1.0
set color blue
set shape "house"
setxy random-xcor random-ycor
ask offices [create-link-with one-of other offices] ;; undirected links
ask links [set color red]
]
create-employees 2 [
set size 1
set color brown
set shape "person"
]
set hourly-wage 20
end
;;;;
to go
cal-dist
ask employees [
if connection > 15
move-to one-of high-pay office
if connection <= 15
move-to one-of low-pay office
]
end
to cal-dist
set connection [list print link-length] ;;
ask links [show link-length]
set salary (hourly-wage * connection) ;;; salary printed in a list
end
不完全确定你在这里用 connection
等做什么,但你可以使用 of
将任何 link 变量放入列表中 - 例如:
to setup
ca
; First create the agents
crt 5 [
while [ any? other turtles in-radius 5 ] [
move-to one-of neighbors
]
set color blue
set shape "house"
]
; Once they're created, have them link with
; one of the other agents
ask turtles [
create-link-with one-of other turtles [
set color red
]
]
let link-lengths [ link-length ] of links
print link-lengths
reset-ticks
end
我不知道这是否真的回答了您的问题,因此您可能希望提供更多详细信息,说明您尝试使用这些 link 完成的任务。