Heros and Cowards (emergence extension)
Model was written in NetLogo 5.2.0
•
Viewed 630 times
•
Downloaded 28 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
turtles-own [ friend enemy ] breed [females female] breed [males male] globals [i] undirected-link-breed [red-links red-link] undirected-link-breed [blue-links blue-link] to setup ;;Minor change added male and females (gender) RDM clear-all ask patches [ set pcolor white ] ;; create a blank background create-females number [ setxy random-xcor random-ycor set shape "circle" set size 0.5 ;; set the turtle personalities based on chooser if (personalities = "brave") [ set color magenta ] if (personalities = "cowardly") [ set color green ] if (personalities = "mixed") [ set color one-of [ green magenta ] ] if (personalities = "mixed25Coward") [ set color one-of [ green green magenta ] ] if (personalities = "mixed75Coward") [ set color one-of [ green magenta magenta ] ] ;; choose friend and enemy targets set friend one-of other females set enemy one-of other females create-red-link-with enemy [set color red] ;; Links added RDM create-blue-link-with friend [set color blue] ;; Links added RDM ] create-males number [ setxy random-xcor random-ycor set shape "circle" set size 0.5 ;; set the turtle personalities based on chooser if (personalities = "brave") [ set color blue ] if (personalities = "cowardly") [ set color red ] if (personalities = "mixed") [ set color one-of [ red blue ] ] if (personalities = "mixed25Coward") [ set color one-of [ red red blue ] ] if (personalities = "mixed75Coward") [ set color one-of [ red blue blue ] ] ;; choose friend and enemy targets set friend one-of other males set enemy one-of other males create-red-link-with enemy [set color red] create-blue-link-with friend [set color blue] ] reset-ticks end to go ask turtles with [color = red or color = blue or color = green or color = magenta] [ ;; print who if (color = blue) [ act-bravely ] if (color = red) [ act-cowardly ] if (color = magenta) [ act-bravely ] if (color = green) [ act-cowardly ] ] tick end to gomf ;; Added male female go routine RDM ask males with [color = red or color = blue] [ ;; print who if (color = blue) [ act-bravely ] if (color = red) [ act-cowardly ] ] ask females with [color = green or color = magenta] [ ;; print who if (color = magenta) [ act-bravely ] if (color = green) [ act-cowardly ] ] tick end to act-bravely ;; move toward the midpoint of your friend and enemy facexy ([xcor] of friend + [xcor] of enemy) / 2 ([ycor] of friend + [ycor] of enemy) / 2 ;;fd 0.1 ;;show [count turtles in-radius 1] of self if ([count turtles in-cone 1 60] of self < 20) [fd 0.1] ;; Added simple collision avoidance RDM if ([count turtles in-radius 1] of self > 20) [ facexy random-xcor random-ycor fd 0.1 ] end to act-cowardly ;; put your friend between you and your enemy facexy ([xcor] of friend + [xcor] of friend - [xcor] of enemy) ([ycor] of friend + [ycor] of friend - [ycor] of enemy) ;;fd 0.1 if ([count turtles in-cone 1 60] of self < 20) [fd 0.1] ;; Added simple collision avoidance RDM if ([count turtles in-radius 1] of self > 20) [ facexy random-xcor random-ycor fd 0.1 ] end to preset [ seed ] ;; sets up the model for use with a particular random seed and constant ;; model parameters, so that a particular pattern can be re-created. set personalities "mixed" set number 68 random-seed seed setup end to one ;; Added routine to have one person be everyone's friend and enemy ;; set all friends and enemies to the same turtle ;; also interesting to set friend and enemy to different turtles clear-all ask patches [ set pcolor white ] ;; create a blank background create-turtles number [ setxy random-xcor random-ycor ;; set the turtle personalities based on chooser if (personalities = "brave") [ set color blue ] if (personalities = "cowardly") [ set color red ] if (personalities = "mixed") [ set color one-of [ red blue ] ] if (personalities = "mixed25Coward") [ set color one-of [ red red blue ] ] if (personalities = "mixed75Coward") [ set color one-of [ red blue blue ] ] ;; choose friend and enemy targets set friend turtle 1 set enemy turtle 1 ] reset-ticks end to linearWrap ;; Added Linear Wrap around or circular buffer order RDM ;; set all friend of turtle i to i+1 and enemy to i-1 ;; connect first and last turtle clear-all ask patches [ set pcolor white ] ;; create a blank background create-turtles number [ setxy random-xcor random-ycor ;; set the turtle personalities based on chooser if (personalities = "brave") [ set color blue ] if (personalities = "cowardly") [ set color red ] if (personalities = "mixed") [ set color one-of [ red blue ] ] if (personalities = "mixed25Coward") [ set color one-of [ red red blue ] ] if (personalities = "mixed75Coward") [ set color one-of [ red blue blue ] ] ;; choose friend and enemy targets set i 1 while [i < (number - 1)] [ ask turtle i [set friend turtle (i + 1)] ask turtle i [create-link-with (friend) [set color blue]] ask turtle i [set enemy turtle (i - 1)] ask turtle i [create-link-with (enemy) [set color red]] set i i + 1 ] ask turtle (number - 1 ) [set friend turtle 0] ask turtle (number - 1 ) [set enemy turtle (number - 2)] ask turtle 0 [set enemy turtle (number - 1)] ask turtle 0 [set friend turtle 1 ] ] reset-ticks end to linearNoWrap ;; Added Linear No Wrap around or queue order RDM ;; set all friend of turtle i to i+1 and enemy to i-1 ;; do not connect first and last turtle clear-all ask patches [ set pcolor white ] ;; create a blank background create-turtles number [ setxy random-xcor random-ycor ;; set the turtle personalities based on chooser if (personalities = "brave") [ set color blue ] if (personalities = "cowardly") [ set color red ] if (personalities = "mixed") [ set color one-of [ red blue ] ] if (personalities = "mixed25Coward") [ set color one-of [ red red blue ] ] if (personalities = "mixed75Coward") [ set color one-of [ red blue blue ] ] ;; choose friend and enemy targets set i 1 while [i < (number - 1)] [ ask turtle i [set friend turtle (i + 1)] ask turtle i [create-link-with (friend) [set color blue]] ask turtle i [set enemy turtle (i - 1)] ask turtle i [create-link-with (enemy) [set color red]] set i i + 1 ] ask turtle (number - 1 ) [set friend turtle (number - 1 )] ask turtle (number - 1 ) [set enemy turtle (number - 2) ] ask turtle 0 [set enemy turtle 0 ] ask turtle 0 [set friend turtle 1 ] ] reset-ticks end ; Copyright 2014 Uri Wilensky. ; See Info tab for full copyright and license.
There is only one version of this model, created almost 8 years ago by Bob McLeod.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Heros and Cowards (emergence extension).png | preview | Preview for 'Heros and Cowards (emergence extension)' | almost 8 years ago, by Bob McLeod | Download |
This model does not have any ancestors.
This model does not have any descendants.