2

我正在尝试在 Netlogo 中编写一些代码。我正在使用现有模型化学平衡并尝试实现以下内容:

海龟自己的[速度]

问海龟[

;; set velocity ( ambient-temperature = 30 )
;; fd velocity
if temp  > 40 [ "speed" increases of turtles  ]  
ifelse temperature < 30 [ speed of turtles decreases]

]

;; 到温度

但它似乎不起作用

(温度超过 40 海龟的速度会增加 如果温度低于 30 海龟的速度会降低) 温度是模型上的滑块

同样的压力问海龟[

;; if pressure > 50 then speed increases of turtles
;; if pressure < 50 then speed decreases of turtles

]

;; 施压

谢谢

4

1 回答 1

2

I think what you are trying to do is something like this:

turtles-own [speed]


to setup
  ca
  create-turtles 50 [
    set speed 1
  ]
end

to go
  ask turtles [
    if (temperature  > 40) [ 
      set speed min (list (speed + 1) 100) ;cap the speed at 100 otherwise it will shoot to infinity
    ]
    if (temperature < 30) [
      set speed max (list (speed - 1) 0); min speed is 0
    ]
    ;move
    forward speed
  ]  
end

I had to add minimum and maximum speeds (0 and 100 respectively) otherwise the speed would quickly shoot to innfinity. Also, "temperature" is a slider in my model.

于 2010-03-04T16:07:15.670 回答