English 中文(简体)
如何界定接口梯度中变数的价值,而不是代理初始化?
原标题:how to define the value of a variable in an interface slider instead of agent initialization?
  • 时间:2024-01-24 16:48:19
  •  标签:
  • netlogo

我将这一变量称为flip-rate

globals [
  magnetization
]

turtles-own [
  opinion
  flip-rate
  temp-opinion
]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; AGENT INITIALIZATION ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to initialize-hvm ;; turtle procedure
  ask turtles [
    set opinion one-of n-values number-states [ ?1 -> ?1 ]
    recolor
    set flip-rate random-float 1
  ]
  set-magnetization
end

instead of having this flip-rate variable set as a random value in agent initialization, how do I set with a slider on the interface section?

I tried moving the flip-rate variable to

globals 

but when I try to create a slider with the same name, I get an error saying "There is already a global variable called FLIP-RATE".

最佳回答

斜体本身是一个全球变量(见here)。 因此,你不必在表格中加以界定。 假设你指定了你的螺旋式fliprate-slider,你可以将其价值分配到海龟所拥有的可变的<代码>flip-rate:

globals [
  magnetization
]

turtles-own [
  opinion
  flip-rate
  temp-opinion
]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; AGENT INITIALIZATION ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to initialize-hvm ;; turtle procedure
  ask turtles [
    set opinion one-of n-values number-states [ ?1 -> ?1 ]
    recolor
    set flip-rate flip-rate-slider
  ]
  set-magnetization
end
问题回答

暂无回答




相关问题
netlogo runtime error turtles on

while running the following code if any? (turtles-on patch-ahead q) [ some commands ] where q is a number variable there is a run time error saying: turtles-on expected the input to be agent or ...

netlogo programing help on traffic simulation

I am trying to find if there is a turtle on patch-ahead n whose speed - acceleration is <= 0. The code I came up with is: if any? turtles on patch-ahead n with [speed <= (speed - acceleration)]...

NetLogo - reading and writing to a text file for Java API use

I want to use the Java API in my NetLogo program. For that, I need to write to a text file and read input from a text file. How can this be done in NetLogo? Additionally - what are the ways by which ...

Using the NetLogo API to get turtle coordinates

I am trying to get coordinates for turtles in NetLogo by using the Java API. I have managed to get the workspace loaded and have been using the following code that I made: public static int getX(...

How to create maze walls in NetLogo?

I am trying to create a 5x5 grid with 2 exits and put some walls in it. In other words, I want to create a maze or a labyrinth. I was wondering if there is a way to make a border line thicker or ...

热门标签