Heatbugs New Benchmark

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)


(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.0beta5 • Viewed 136 times • Downloaded 18 times • Run 2 times
Download the 'Heatbugs New Benchmark' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


$Id: Heatbugs New Benchmark.nlogo 37529 2008-01-03 20:38:02Z craig $

benchmark -- modeled on Repast version

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [result]



to benchmark
  random-seed 362
  reset-timer ;; put it here because it's easier to imitate this in Repast
  repeat 300 [ go ]
  set result timer

to setup
  ;; creating the bugs the following way ensures that we won't
  ;; wind up with more than one bug on a patch
  ask n-of bug-count patches [
    sprout 1 [
      set color lime
      set size 1.75    ;; try to match look in Repast
      set ideal-temp  min-ideal-temp  + random abs (max-ideal-temp  - min-ideal-temp )
      set output-heat min-output-heat + random abs (max-output-heat - min-output-heat)
      set unhappiness abs (ideal-temp - temp)
  ;; plot the initial state of the system
  ;plot mean values-from turtles [unhappiness]

to go
  if not any? turtles [ stop ]
  ;; diffuse heat through world
  diffuse temp diffusion-rate
  ask turtles [ step ]
  ;plot mean values-from turtles [unhappiness]

to recolor-patches
  ask patches
    ;; the world retains a percentage of its heat each cycle
    set temp temp * (1 - evaporation-rate)
    ;; hotter patches will be red turning to white, cooler patches will be black
    set pcolor scale-color red temp 0 500

to step  ;; turtle procedure
  ;; my unhappiness is the magnitude or absolute value of the difference
  ;; between by ideal temperature and the temperature of this patch
  set unhappiness abs (ideal-temp - temp)
  ;; if unhappy and not at the hottest neighbor8
  ;; then move to an open neighbor (trying random ones up to 10 times)
  ifelse unhappiness = 0
    [ set temp temp + output-heat ]
    [ let target find-target
      if (patch-here != target) or (random-move-chance > random 100)
        [ bug-move target ]
      set temp temp + output-heat

;; find the hottest or coolest location next to me

to-report find-target  ;; turtle procedure
  ifelse temp < ideal-temp
    [ report max-one-of neighbors [temp] ]
    [ report min-one-of neighbors [temp] ]

to bug-move [target]  ;; turtle procedure
  let tries 0
  ;; move to the hottest (or coolest location if I'm too hot) location next to me
  ;; if it is not occupied by another bug
  if not any? turtles-on target [
    move-to target
  ;; If I can't get to the best spot, then I try the others randomly
  ;; I only try 9 times, since there are only nine spots around me.
  ;; Even then, I might try a spot more than once.
  while [tries <= 9]
    [ set tries tries + 1
      set target one-of neighbors
      if not any? turtles-on target [
        move-to target

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 12 years ago Heatbugs New Benchmark Download this version
Uri Wilensky over 12 years ago Heatbugs New Benchmark Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.