How to get the tick times that turtles arrive at different 10 patches using behaviourspace in Netlogo?

Viewed 88

There are 100 green patches and 10 turtles. Whenever a turtle comes to a green patch, it becomes red. So after a long time, all the green patches become red AT DIFFERENT TICK TIMES. I want to get those 100 different tick times to an excel sheet using BehaviourSpace. Also i want to run this 100 times. i.e I want 100 sets of 100 different tick times.

I have made a code such that when a turtle comes to the green patch, the patch becomes red and I have written "show ticks" under it. So when a green patch becomes red, the tick time is shown on command center at the bottom of the screen. Tick times Example: 34,56,78,98,99,...,1234. There are 100 different times.

breed [InfMosquitoes InfMosquito]

to setup
  clear-all

  set-default-shape InfMosquitoes "butterfly"
  create-InfMosquitoes  num-infected-mosquitoes-red
   [
    set color red
   ]

ask turtles [
    set size 1
    setxy random-xcor random-ycor
     ]

ask turtles[
      ifelse coin-flip?
          [ifelse coin-flip? [set heading 0][set heading 90]]
          [ifelse coin-flip? [set heading 180][set heading 270]]
     ]

ask n-of num-humans patches [set pcolor green]

   show num-infected-mosquitoes-red

  reset-ticks
end

to go
  ask turtles
  [
          right random 360
          forward 1
      ask InfMosquitoes[
      if pcolor = green 
          [
            set pcolor red 
            show ticks   
          ]
       ]
  ]
    tick
end


to-report coin-flip?
  report random 2 = 0
end

I want to know what should I write in BehaviourSpace table. I know Repititions:100. I want to know what should I write on other command boxes.

1 Answers

You can create a global variable and initiate it as a list.

globals [
...
ticks-recorder
...
]

to setup
...
  set ticks-recorder []
...
end

Then, instead of having the tick number printed in the Command Center, you will have it added to the list:

to go
  ask turtles
  [
          right random 360
          forward 1
      ask InfMosquitoes[
      if pcolor = green 
          [
            set pcolor red 
            set ticks-recorder lput ticks ticks-recorder   ; this is the line I've changed
          ]
       ]
  ]
    tick
end

You will end up with ticks-recorder being a list of all the ticks when a patch changed colour to red.

Then, you can just specify ticks-recorder as a reporter in BehaviorSpace.

Note that, with this solution, you will end up with a list being reported. For example, let's say your list contains the values 1 and 2. In NetLogo, this is seen as [1 2]. This means that, if for instance you're opening your output file in Excel, the cell where your reporter is located will contain exactly the text [1 2], which means that you won't be able to perform any mathematics on it. You may or may not care about this, I don't know (e.g. you may be handling your output with a different programming language where you unlist the reporter). But I think this becomes a different thing.

Related