2017-10-15 93 views
0

我正在建模一个城市景观,用于观察运动,其中补丁等同于建筑物并具有不同的影响值。我需要使用计算的东西,如每个补丁值的记者函数:netlogo:有补丁使用记者计算影响力值

(its own influence) plus (the influence of neighbors) divided by the 
distance to a specific turtle (max-one-of distance myself) 

龟然后将朝着具有最高影响值的补丁移动,但沿着街道定义。

我是新使用netlogo并已完全卡住。

我已经包括了我到目前为止的一部分,但我无法弄清楚如何编写将计算每个补丁影响值(圆锥体内)的记者函数,以便海龟可以朝着最好的选择。

to setup-influence-field 
    ask patches with [pcolor = green] [set influence commercial-influence] 
    ask patches with [pcolor = orange] [set influence production-influence] 
    ask patches with [pcolor = yellow] [set influence domestic-influence] 
    ask patches with [pcolor = pink] [set influence religious-influence] 
    ask patches with [pcolor = blue] [set influence public-influence] 
end 

to go 
    move-serapis 
end 

to move-serapis 
    ask serapis [set-procession-heading] 
    repeat 2 [ ask serapis [ fd .25 ] display ] 
    tick 
end 

;;;;; the reporter values are need for this part of the code so that the turtles (serapis) can move towards the patches with the highest influence value;;;; 
    to set-procession-heading 
     let direction patches in-cone 4 40 with [influence-field > 0] 
     if any? influence-field 
      [face max-one-of influence-field] ;;;; face towards the highest computed influence value 
     ifelse any? patches with [pcolor = black] in-cone 1 25 
     [process] 
    end 

任何帮助将不胜感激!

回答

1

我不认为这是完全正确的,我不能测试它,但它应该启动你,也许有人在这里可以解决它,如果你让我们知道错误。

to set-procession-heading 
    let direction-targets patches in-cone 4 40 with [influence-field > 0] 
    if any? direction-targets 
    [ face max-one-of direction-targets [ influence-amount self ] ] 
end 

to-report influence-amount [ target-node ] 
    report ([ influence-field ] + sum [ influence-field] of neighbors)/distance target-node 
end 

我所做的是设置一个单独的过程来报告计算结果。该过程需要一个参数(名为target-node),因为您需要能够传递受影响的乌龟的身份。一旦你有了这个过程,那么你可以简单地将潜在方向的代理集合传递给计算过程,并选择最大值。