WLM 3.t Slange simulering SRP

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 20 times • Downloaded 0 times • Run 0 times
Download the 'WLM 3.t Slange simulering SRP' 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 [vov      a-vov     ]    ; volume of venom
breed [snake    a-snake   ]
breed [food     a-food    ]
breed [predator a-predator]
breed [tree     a-tree    ]

snake-own [
   energy
   snake-volume-venom
   venom-range
  rattle
]

predator-own [
  energy
  size-matters
]

to setup
  clear-all

  ask patches  [ set pcolor brown ]

  set-default-shape snake "turtle"
  create-snake number-snakes-at-start
  [

    set size 1
    set color blue
    setxy random-xcor random-ycor
    set snake-volume-venom 1 + random 6
    set venom-range 3

  ]

  set-default-shape predator "circle"
  create-predator number-predators-at-start
  [
    set size size-of-predators
    set color red
    setxy random-xcor random-ycor
    set size-matters 0
  ]

  set-default-shape food "circle"
  create-food number-food-at-start
  [

   set color green
   set size 0.75
   setxy random-xcor random-ycor
  ]

if trees?
  [
     set-default-shape tree "tree"
     create-tree 35
          [ set size 2
            setxy random-xcor random-ycor
            set color 53 ]
  ]

if range?
  [
  ]

  ask snake      [set energy 100 ]
  ask predator   [set energy 40 ]


  ask snake  [ produce-vov ]
 reset-ticks
end 

to go

 if (( not any? snake) or ( not any? predator )) [ print "stopping ! " stop ]

  ask snake
  [
    move
    set energy energy - 1
    catch-food
    reproduce-snake
    death
  ]

  ask predator
  [
     move
     set energy energy - 1
     catch-snake
     death
     reproduce-predator
  ]

  make-new-food

  tick
end 

to make-new-food
  if 30 < food-respawn [

      create-food 3 [
                      set color green
                      setxy random-xcor random-ycor
                    ]
  ]
end 

to move
  rt random 50
  lt random 50
  fd 1
end 

to death
  if energy < 0 [ die ]
end 

to  catch-food
  let prey one-of food in-radius venom-range
  if prey != nobody
    [
      ask prey   [ die ]
      set energy energy + food-gain-for-snakes
      set snake-volume-venom snake-volume-venom + venom-gain
   ]
end 

to  catch-snake
  let prey one-of snake in-radius 1.5
  if prey != nobody
      [
        ifelse  [ snake-volume-venom ] of prey  > size-matters
        [ ask self [ print ( word "Attacking predator " self "was intoxicated and will die now " )
          ;user-message "Predator died in a fight with a snake"
          die ]]
        [print (word "Attacking predator wins against snake: " ) show prey
           ;user-message "Predator successfully hunted and killed a snake"
          ask prey [ die ] ]
         set energy energy + food-gain-for-predators

      ]
end 

to reproduce-snake
  if random-float 100 < snake-reproduce [
    set energy energy * 1 / 2
    hatch 1 [
      rt random-float 360 fd 1
    ]]
end 

to reproduce-predator
  if random-float 150 < predator-reproduce [
    set energy energy * 2 / 3
    hatch 1 [ rt random-float 360 fd 1 ] ]
end 

to produce-vov
  let prey one-of snake
  let rad snake-volume-venom
  hatch-vov 1 [
    set color yellow
    set shape "circle"
    set size ( [ snake-volume-venom ] of prey + [ rad ] of prey) / 3
    create-link-from myself [ tie ]
  ]
end 

to predator-size-matters
  ifelse size-of-predators > 1.5
  [ set size-matters size-matters + 7 ]
  [ set size-matters size-matters + 5 ]
end 

to range-venom
 if range?
  [ set venom-range venom-range + 2 ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
William Lohmann Meyhoff 18 days ago New layout of menu Download this version
William Lohmann Meyhoff 18 days ago New layout of menu Download this version
William Lohmann Meyhoff 18 days ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.