turtles-own [ age ] to setup ca cct 3 [ set color pink fd 2 ] end to go ask turtles [ wander reproduce grow-old ] plot count turtles if count turtles = 0 [ stop ] end to grow-old set age age + 1 if (age > 50) [ die ] end to wander rt random 360 fd 1 end to reproduce if (color = pink and random 5 = 0) [ hatch 1 [ if random 10 > 0 [set color blue] ;9 of 10 hatched turtles are made blue set age 0 ] ] end ;;This model was created as part of the project: ;;PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ;;CLASSROOMS. The project gratefully acknowledges the support of the ;;National Science Foundation ( REPP program ) -- grant number REC #9814682. ;;Copyright 2001 by Uri Wilensky. All rights reserved. ;;Permission to use, copy, or modify this software and its documentation for ;;educational and research purposes only and without fee is hereby granted, ;;provided that this copyright notice and the original authors' names appear ;;on all copies and supporting documentation. For any other uses of this ;;software, in original or modified form, including but not limited to ;;distribution in whole or in part, specific prior permission must be ;;obtained from Uri Wilensky. These programs shall not be used, rewritten, ;;or adapted as the basis of a commercial software or hardware product ;;without first obtaining appropriate licenses from Uri Wilensky. We make no ;;representations about the suitability of this software for any purpose. It ;;is provided "as is" without express or implied warranty. @#$#@#$#@ GRAPHICS-WINDOW 326 19 657 350 18 18 8.945945945945946 1 10 CC-WINDOW 6 289 302 435 Command Center BUTTON 19 228 74 261 setup setup NIL 1 T OBSERVER MONITOR 163 220 265 269 count turtles count turtles 3 1 BUTTON 78 228 133 261 go go T 1 T OBSERVER PLOT 6 18 307 203 Population time count 0.0 200.0 0.0 50.0 true false PENS "number" 1.0 0 -16776961 true @#$#@#$#@ WHAT IS IT? ----------- This code example demonstrates the HATCH command. Blue turtles never reproduce. Pink turtles have a one-in-five chance of reproducing at each time tick. Each turtle's life lasts 50 ticks. Nine out of ten baby turtles are blue. The turtles created by HATCH are exact duplicates of their parents, so it is necessary to reset each new turtle's age to 0 inside the HATCH command. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 1.0 Beta 10 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@