Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Development of turtles from one breed to another

Tags:

netlogo

I dont know much about netlogo so this may be a really simple solution but I have multiple breeds of turtles where each breed is a different age range (eggs, hatchlings, juveniles, hawksbills (adults)) and i need them to be able to go from one breed to the next after a certain amount of ticks (in my model one tick = one day). Is this possible to code for?

Here's my code so far

globals [island] 

Breed [eggs egg]
Breed [hatchlings hatchling]
Breed [juveniles juvenile]
Breed [hawksbills hawksbill]

turtles-own [
  age
  z
  ]

to setup
  clear-all
  set-default-shape eggs "circle"
  create-eggs 80
  [ set color 49.5
    set size 0.5
    setxy random-xcor random-ycor ] 

  set-default-shape hatchlings "turtle"
  create-hatchlings 70
  [ set color 57
    set size 1.5
    setxy random-xcor random-ycor ]

  set-default-shape juveniles "turtle"
  create-juveniles 10
  [ set color 55
set size 2
setxy random-xcor random-ycor ]

set-default-shape hawksbills "turtle"
  create-hawksbills 9
  [ set color 53
    set size 3
    setxy random-xcor random-ycor ]

  clear-output
  setup-environment
  setup-birthdays
  reset-ticks

end

to setup-environment
  ask patches [set pcolor cyan]
  ask patches with [abs(pxcor) < 5 and abs(pycor) < 5] [set pcolor yellow]
  ask patches with [abs(pxcor) < 2 and abs(pycor) < 2] [set pcolor brown]
end

to setup-birthdays

end

to go
  ask eggs 
  [ kill-eggs ]
  ask hatchlings 
  [ move-hatchlings
    kill-hatchlings]
  ask juveniles 
  [ move-juveniles
    kill-juveniles]
   ask hawksbills
  [ move-hawksbills
    kill-hawksbills
    reproduce-hawksbills ] 

  tick
  if not any? turtles [stop]
end

to kill-eggs  
   set z random 100
   if z > 50
    [die]
end

to kill-hatchlings  
   set z random 100
   if z > 10
   [die]
end

to kill-juveniles 
   set z random 20
   if z > 18
   [die]
end

to kill-hawksbills  
   set z random 5
   if z > 4
   [die]
end

to move-hatchlings
  rt random 360
  fd 1
end

to move-juveniles
  rt random 360
  fd 1
end

to move-hawksbills
  rt random 360
  fd 1
end

to reproduce-hawksbills
     if pcolor = yellow
     [set z random 100
     if z > 75
     [hatch-eggs 5[
         set color 49.5
         set size 0.5]
     ]]
end
like image 949
Dana Avatar asked Sep 28 '22 02:09

Dana


1 Answers

To turn a turtle into a hatchling, just do set breed hatchlings! So, your code will probably look something like:

if age > 10 [
  set breed hatchlings
]
like image 71
Bryan Head Avatar answered Nov 17 '22 15:11

Bryan Head