Netlogo:与其他代理进行交互';变量

Netlogo:与其他代理进行交互';变量,netlogo,Netlogo,我试图让代理根据另一个代理的变量是否介于第一个代理的个人最小值和最大值之间来做出决定。我对netlogo预期的语法有问题 此位,在下面的完整代码中: to settle-decision ask turtles [ ifelse ( myneighbor mycall ) > myminthresh AND myneighbor mycall < mymaxthresh) [ set settled? true ] [ set color yell

我试图让代理根据另一个代理的变量是否介于第一个代理的个人最小值和最大值之间来做出决定。我对netlogo预期的语法有问题

此位,在下面的完整代码中:

to settle-decision
  ask turtles [
    ifelse ( myneighbor mycall ) > myminthresh AND myneighbor mycall < mymaxthresh)
      [ set settled? true ]
      [ set color yellow ]
解决决策
问海龟[
ifelse(myneighbor mycall)>myminthresh和myneighbor mycall
最终,我想让代理做比改变颜色更有趣的事情,但我不能先通过这一关!任何帮助都非常感谢

turtles-own [
  myneighbor                                 ;; closest other male frog to myself
  mycall                                     ;; the amplitude (loudness) of my own call
  myminthresh                                ;; when my neighbor's call is below this threshold, I move toward him
  mymaxthresh                                ;; when my neighbor's call is above this threshold, I move away from him
  myNND                                      ;; the distance to my nearest neighbor
  settle?                                    ;; true if male decides to create a territory and stop moving

 ]


to setup

  clear-all
  create-turtles population [                         ;; use the population slider to choose number of males

set size 1.5                                      ;; easy to see but is it actual agent size or just agent image size?
setxy random-xcor random-ycor                     ;; distribute frogs randomly in the landscape

set mycall random 100                             ;; choose the amplitude of my own call from a random distribution 0 to 100
set color scale-color red mycall 0 100            ;; allows easy visualization of variability in call amplitude
                                                  ;; lighter color is a higher amplitude
set myminthresh inputminthresh                    ;; use the input on interface to set the min-threshold
set mymaxthresh inputmaxthresh                    ;; use the input on the interface to set the max-threshold
set myNND 0                                       ;; initialize nearest neighbor distance for all

  ]

  reset-ticks

end

to go
  choose-neighbors
  settle-decision
  move-turtles
  tick
end

to choose-neighbors
   ask turtles [
    set myneighbor min-one-of other turtles [distance myself]  ;; choose my nearest neighbor based on distance
    set myNND distance myneighbor

  ]
end


to settle-decision
  ask turtles [
    ifelse ( myneighbor mycall ) > myminthresh AND myneighbor mycall < mymaxthresh)
    [ set settled? true ]
    [ set color yellow ]
  ]
end

to move-turtles
  ask turtles [
    face myneighbor
    ifelse mycall < myminthresh
        [ set color blue ]
        [ set color yellow ]
                                                              ;; this works but everybody moves so needs more work
    fd 5
    pendown
  ]
end
海龟自己的[
我的邻居;离我最近的另一只雄青蛙
我的呼叫;我自己呼叫的幅度(响度)
当我邻居的电话低于这个临界值时,我向他走去
当我邻居的电话超过这个门槛时,我就离开他
myNND;;到最近邻居的距离
定居?;;如果男性决定建立领地并停止移动,则为真
]
设置
清除所有
创建海龟种群[;;使用种群滑块选择雄性海龟的数量
设置大小1.5;;易于查看,但它是实际代理大小还是仅代理图像大小?
setxy random xcor random ycor;;在景观中随机分布青蛙
将mycall random设置为100;;从随机分布0到100中选择我自己通话的幅度
将颜色刻度设置为红色mycall 0 100;;允许轻松可视化通话幅度的变化
颜色越浅,振幅越大
设置myminthresh inputminthresh;;使用接口上的输入设置最小阈值
设置mymaxthresh inputmaxthresh;;使用接口上的输入设置最大阈值
设置myNND 0;;初始化所有对象的最近邻距离
]
重置滴答声
结束
外带
选择邻居
解决决定
搬海龟
打上钩
结束
选择邻居
问海龟[
将myneighbor min设置为其他海龟之一[与自己保持距离];根据距离选择我最近的邻居
设置myNND距离myneighbor
]
结束
决定
问海龟[
ifelse(myneighbor mycall)>myminthresh和myneighbor mycall
您需要的原语是
的,其代码类似于代理的[variablename]。我无法测试这一点,但可能需要:

to settle-decision
  ask turtles [
    ifelse ( myneighbor mycall ) > myminthresh AND myneighbor mycall < mymaxthresh)
    [ set settled? true ]
    [ set color yellow ]
  ]
end
解决决策
问海龟[
ifelse(myneighbor mycall)>myminthresh和myneighbor mycall
试一试

解决决策
问海龟[
ifelse([mycall]的myneighbor>myminthresh)和([mycall]的myneighbor
詹布,你是救命恩人!谢谢你。效果很好。
to settle-decision
  ask turtles [
    ifelse ([mycall] of myneighbor > myminthresh) AND ([mycall] of myneighbor < mymaxthresh)
    [ set settled? true ]
    [ set color yellow ]
  ]
end