Travel Heat Color 2

Travel Heat Color 2 preview image

1 collaborator

Default-person Aaron Brandes (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 28 times • Downloaded 1 time • Run 0 times
Download the 'Travel Heat Color 2' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

extensions [rnd]

globals [
  sizew
  total-shades      ; the total number of shades ( <= 100)
  midpoint-nl-color ; the named NetLogo color at the midpoint (last digit is 5)
  num-turtles
  ticks-per-round
]
patches-own [ heat  ; number in darkness range,
                    ; with 0 = white, total-shades/2 = midpoint-nl-color, total-shade = black
]

to setup
  clear-all
  random-seed 10100
  set num-turtles 2
  set ticks-per-round 5000
  set midpoint-nl-color orange
  set total-shades 100
  set sizew 60
  resize-world 0 sizew 0 sizew
  set-patch-size 10
  set-default-shape turtles "default"
  init-turtles num-turtles
  ask patches [ set heat 0 set pcolor white]
  reset-ticks
end 

to init-turtles [ n ]
   create-turtles n
  [ setxy 0 0
    ;hide-turtle
    set color yellow
    set size 3 ]
end 

to go
  ask turtles [
    set heat heat + 1
    ask patch-here [recolor-patch ]
    move-random
  ]
  tick
end 

to move-random
  right random 360 forward 1
end 

; use heat + .5 because there should be some chance of moving to a patch that was never visited

to move-weighted
  move-to rnd:weighted-one-of neighbors [ heat + .5 ]
end 

; It's faster to only recolor the patch being visited

to recolor-patch
  set pcolor make-nl-color-shade  midpoint-nl-color heat total-shades
end 

; Reports a color ranging from white to 'nl-color' to black as
;  'shade-value' ranges from 0 to 'num-shades
;
; nl-color      a NetLogo color with last digit 5: can be referenced by name
; shade-value   darkness number with 0 = white, shade-value/2 = nl-color, num-shades = black
;               numbers < 0 will be set to 0, numbers > num-shades will be set to num-shades
; num-shades    the total number of shades ( <= 100)

to-report make-nl-color-shade [ nl-color shade-value num-shades]
  ; shade-value is forced to be between 0 and num-shades
  set shade-value min list num-shades max list 0 shade-value
  report scale-color nl-color shade-value num-shades 0
end 

There is only one version of this model, created 3 months ago by Aaron Brandes.

Attached files

File Type Description Last updated
Travel Heat Color 2.png preview Preview for 'Travel Heat Color 2' 3 months ago, by Aaron Brandes Download

This model does not have any ancestors.

This model does not have any descendants.