Development of turtles from one breed to another

I don't know much about netlogo, so this might be a very simple solution, but I have several breeds of turtles where each breed has different age ranges (eggs, chickens, juveniles, hawksbills (adults)) and I need them were able to move from one breed to the next after a certain number of ticks (in my model, one tick = one day). Is this possible for the code?

Here's my code for now

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

      

+3


source to share


1 answer


To transform a turtle into a puppy, just do it set breed hatchlings

! Thus, your code will probably look something like this:



if age > 10 [
  set breed hatchlings
]

      

+3


source







All Articles