breeds [ boys girls ] to setup ;; executed once each time we press the SETUP button ca ;; clear all patches and turtles set-default-shape boys "boy-shape" create-boys boys-num ;; create BOYS-NUM number of turtles of breed BOYS ;; BOYS-NUM equals the current value of the BOYS-NUM slider set-default-shape girls "girl-shape" create-girls girls-num ;; create GIRLS-NUM number of turtles of breed GIRLS ;; GIRLS-NUM equals the current value of the GIRLS-NUM slider ask boys [ set color blue ] ask girls [ set color red ] ask turtles [ ;; includes both boys and girls setxy (random screen-size-x) 0 ;; disperse turtles along X axis set heading 0 ;; point all turtles up (north) ] end to move-boys ask boys [ ;; ask all turtles of breed BOYS, fd 1 ;; to move forward by 1 ] end to move-girls ask girls [ ;; ask all turtles of breed GIRLS, fd 1 ;; to move forward by 1 ] end to kill-boys ask boys [ ;; ask all turtles of breed BOYS die ;; to die ] end to kill-girls ask girls [ ;; ask all turtles of breed GIRLS die ;; to die ] end ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML) ; The project gratefully acknowledges the support of the National Science ; Foundation (Applications of Advanced Technologies Program) -- grant numbers ; RED #9552950 and REC #9632612. ; ; Converted from StarLogoT to NetLogo, 2001 ; Copyright 1999 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 270 18 660 408 6 6 30.0 1 10 0 0 CC-WINDOW 9 278 261 415 Command Center BUTTON 138 206 255 244 Girls Disappear kill-girls NIL 1 T OBSERVER BUTTON 12 206 122 244 Boys Disappear kill-boys NIL 1 T OBSERVER BUTTON 138 157 227 195 NIL move-girls NIL 1 T OBSERVER BUTTON 43 157 122 196 NIL move-boys NIL 1 T OBSERVER BUTTON 27 25 219 61 setup setup NIL 1 T OBSERVER SLIDER 6 118 243 151 girls-num girls-num 0 5 5 1 1 NIL SLIDER 5 77 243 110 boys-num boys-num 0 5 5 1 1 NIL @#$#@#$#@ WHAT IS IT? ----------- This code example shows how to create and control groups of turtles, i.e. breeds. It also shows how to set the default shape of a breed, so all turtles with that breed will have that shape. If you want to create your own shapes, press the SHAPES button on the right-hand side of the toolbar, click the "New" button, and draw your own shape! @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 boy-shape false 0 Circle -7566196 true true 107 15 84 Line -7566196 true 150 75 150 224 Line -7566196 true 150 150 74 135 Line -7566196 true 150 149 224 135 Line -7566196 true 150 224 195 284 Line -7566196 true 150 226 105 284 girl-shape false 0 Circle -7566196 true true 107 15 84 Line -7566196 true 150 75 150 224 Line -7566196 true 150 150 74 135 Line -7566196 true 150 149 224 135 Line -7566196 true 150 224 195 284 Line -7566196 true 150 226 105 284 Polygon -7566196 true true 150 99 105 267 195 267 @#$#@#$#@ NetLogo 1.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@