Polarainer

No preview image

1 collaborator

Default-person Rainer Mahidin (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 19 times • Downloaded 3 times • Run 0 times
Download the 'Polarainer' 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

breed [polar-bears polar-bear]

polar-bears-own [hunting-timer]
patches-own [has-ice?]

to setup
  clear-all
  set-default-shape polar-bears "wolf"  ;; Use wolf shape for visibility
  setup-ice
  setup-bears
  reset-ticks
end 

to setup-ice
  ask patches [
    ifelse random-float 100 < initial-ice-percentage [
      set pcolor white
      set has-ice? true
    ] [
      set pcolor blue
      set has-ice? false
    ]
  ]
end 

to setup-bears
  ;; Create 10 small, 10 medium, and 10 large bears
  repeat 10 [
    create-polar-bears 1 [
      set size 0.5
      set color white
      set label "S"
      setxy random-xcor random-ycor
      set hunting-timer 5
    ]
    create-polar-bears 1 [
      set size 1.0
      set color gray
      set label "M"
      setxy random-xcor random-ycor
      set hunting-timer 5
    ]
    create-polar-bears 1 [
      set size 1.5
      set color black
      set label "L"
      setxy random-xcor random-ycor
      set hunting-timer 5
    ]
  ]
end 

to go
  if not any? polar-bears [ stop ]
  shrink-ice
  move-bears
  bears-hunt
  remove-drowned-bears
  plot-data
  tick
end 

to shrink-ice
  ask patches with [has-ice?] [
    if random-float 100 < ice-shrink-rate [
      set has-ice? false
      set pcolor blue
    ]
  ]
end 

to move-bears
  ask polar-bears [
    rt random 50 - random 50
    fd 1
    if not can-move? 1 [ rt 180 fd 1 ]
  ]
end 

to bears-hunt
  ask polar-bears [
    let p patch-here
    ifelse [has-ice?] of p [
      ;; successful hunt
      set hunting-timer 5
    ] [
      ;; no ice → reduce hunting timer
      set hunting-timer hunting-timer - 1
    ]
  ]
end 

to remove-drowned-bears
  ask polar-bears [
    if hunting-timer <= 0 [
      let drown-chance 0
      if size = 1.5 [ set drown-chance 80 ]   ;; large
      if size = 1.0 [ set drown-chance 40 ]   ;; medium
      if size = 0.5 [ set drown-chance 5 ]    ;; small
      if random-float 100 < drown-chance [
        die
      ]
    ]
  ]
end 

to plot-data
  set-current-plot "Bear Population by Size"

  set-current-plot-pen "Small"
  plot count polar-bears with [size = 0.5]

  set-current-plot-pen "Medium"
  plot count polar-bears with [size = 1.0]

  set-current-plot-pen "Large"
  plot count polar-bears with [size = 1.5]
end 

There is only one version of this model, created 3 days ago by Rainer Mahidin.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.