# Evolution of Aggression

Model was written in NetLogo 5.0.2
•
Viewed 620 times
•
Downloaded 41 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

;; Hawks, doves and retaliators are breeds of turtle. breed [hawks hawk] breed [doves dove] breed [retaliators retaliator] ;; Hawks, doves and retaliators have a fitness, a reproduction time and an engaged flag turtles-own [fitness reproduction-time engaged ] ;; Initialisation of the system to setup ;; Remove all previous turtles ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) __clear-all-and-reset-ticks ;; Create doves and initialise their variables set-default-shape doves "default" create-doves initial-number-doves [ ;; Doves are blue set color blue ;; Labels are white set label-color white ;; The fitness is set to the intial value set fitness initial-fitness ;; The reproduction time is generated according to a normal distribution set reproduction-time round (random-normal time-to-reproduce (time-to-reproduce / 5)) ;; Initially each dove is not engaged in a fight set engaged 0 ;; Located at random position setxy random-xcor random-ycor ] ;; Create hawks and initialise their variables set-default-shape hawks "default" create-hawks initial-number-hawks [ ;; Hawks are red set color red ;; Labels are white set label-color white ;; The fitness is set to the intial value set fitness initial-fitness ;; The reproduction time is generated according to a normal distribution set reproduction-time round (random-normal time-to-reproduce (time-to-reproduce / 5)) ;; Initially each hawk is not engaged in a fight set engaged 0 ;; Located at random position setxy random-xcor random-ycor ] ;; Create retaliators and initialise their variables set-default-shape retaliators "default" create-retaliators initial-number-retaliators [ ;; Retaliators are green set color green ;; Labels are white set label-color white ;; The fitness is set to the intial value set fitness initial-fitness ;; The reproduction time is generated according to a normal distribution set reproduction-time round (random-normal time-to-reproduce (time-to-reproduce / 5)) ;; Initially each retaliator is not engaged in a fight set engaged 0 ;; Located at random position setxy random-xcor random-ycor ] display-labels update-plot end to go ;; simulation stops if there are no turtles if not any? turtles [ stop ] ;; All breeds move, decrease their time to reproduction, fight, ;; set their engaged flag to 0, die and reproduce ask doves [ move set reproduction-time reproduction-time - 1 fight-as-dove set engaged 0 death reproduce ] ask hawks [ move set reproduction-time reproduction-time - 1 fight-as-hawk set engaged 0 death reproduce ] ask retaliators [ move set reproduction-time reproduction-time - 1 fight-as-retaliator set engaged 0 death reproduce ] ;; advance the time and update the plots tick update-plot display-labels end ;; Procedure for all breeds to move rt (30 - (random-float 60)) ;;(random-float 180) fd 1 ;;2 end to fight-as-dove ;; Only not engaged dove can start a fight if engaged = 0 [ ;; Checking if there are available opponents in the patch to ;; start a fight let opponent one-of other turtles-here with [ engaged = 0 ] if opponent != nobody [ ;;If there is a free oponent both get engaged in a fight set engaged 1 ask opponent [ set engaged 1 ] ifelse is-hawk? opponent [ ;; If opponent is a hawk, doves flee and hawks get the reward ask opponent [ set fitness ([fitness] of opponent + reward) ] ] [ ;; If opponent is a dove or retaliator, doves pose for some time ;; which produces a penalty for wasting time. The probability of ;; eventually getting the reward is 0.5 ifelse (random 10) < 5 [ set fitness (fitness - cost-wasted-time) ask opponent [ set fitness ([fitness] of opponent + reward - cost-wasted-time) ] ] [ set fitness (fitness + reward - cost-wasted-time) ask opponent [ set fitness ([fitness] of opponent - cost-wasted-time) ] ] ] ] ] end to fight-as-hawk ;; Only not engaged hawks can start a fight if engaged = 0 [ ;; Checking if there are available opponents in the patch to ;; start a fight let opponent one-of other turtles-here with [ engaged = 0 ] if opponent != nobody [ ;;If there is a free oponent both get engaged in a fight set engaged 1 ask opponent [ set engaged 1 ] ifelse is-dove? opponent ;; If opponent is a dove, hawks get the reward and doves flee [ set fitness (fitness + reward) ] ;; If opponent is a hawk or a retaliator, they fight until one of them gets seriously injured [ ifelse (random 10) < 5 [ set fitness (fitness - cost-injure) ask opponent [ set fitness ([fitness] of opponent + reward) ] ] [ set fitness (fitness + reward) ask opponent [ set fitness ([fitness] of opponent - cost-injure) ] ] ] ] ] end to fight-as-retaliator ;; Only not engaged retaliators can start a fight if engaged = 0 [ ;; Checking if there are available opponents in the patch to ;; start a fight let opponent one-of other turtles-here with [ engaged = 0 ] if opponent != nobody [ ;;If there is a free oponent both get engaged in a fight set engaged 1 ask opponent [ set engaged 1 ] ifelse is-hawk? opponent ;; Retaliator behaves as a hawk against a hawk [ ifelse (random 10) < 5 [ set fitness (fitness - cost-injure) ask opponent [ set fitness ([fitness] of opponent + reward) ] ] [ set fitness (fitness + reward) ask opponent [ set fitness ([fitness] of opponent - cost-injure) ] ] ] ;; Retaliator behaves as a dove agains another retaliator or a dove [ ifelse (random 10) < 5 [ set fitness (fitness - cost-wasted-time) ask opponent [ set fitness ([fitness] of opponent + reward - cost-wasted-time) ] ] [ set fitness (fitness + reward - cost-wasted-time) ask opponent [ set fitness ([fitness] of opponent - cost-wasted-time) ] ] ] ] ] end to reproduce ;; turtle procedure ;; when reproduction time equals zero breeds reproduce if reproduction-time = 0 [ hatch 2 [ rt random-float 360 fd 2 set fitness initial-fitness set reproduction-time round (random-normal time-to-reproduce (time-to-reproduce / 5)) ] die ] end to death ;; turtle procedure ;when fitness dips below zero, die if fitness < 0 [ die ] end to update-plot set-current-plot "populations" set-current-plot-pen "doves" plot count doves set-current-plot-pen "hawks" plot count hawks set-current-plot-pen "retaliators" plot count retaliators set-current-plot "fitness" set-current-plot-pen "dove-fitness" if any? doves [ plot mean [fitness] of doves ] set-current-plot-pen "hawk-fitness" if any? hawks [ plot mean [fitness] of hawks ] set-current-plot-pen "retaliator-fitness" if any? retaliators [ plot mean [fitness] of retaliators ] set-current-plot-pen "average-fitness" plot mean [fitness] of turtles set-current-plot "ratio" set-current-plot-pen "doves" if any? turtles [ plot count doves / count turtles ] set-current-plot-pen "hawks" if any? turtles [ plot count hawks / count turtles ] set-current-plot-pen "retaliators" if any? turtles [ plot count retaliators / count turtles ] end to display-labels ask turtles [ set label "" ] if show-fitness? [ ask hawks [ set label fitness ] ask doves [ set label fitness ] ask retaliators [ set label fitness ] ] end ; Copyright 2011 Francisco J. Romero-Campero. ; http://www.cs.us.es/~fran/

There is only one version of this model, created over 9 years ago by Francisco J. Romero-Campero.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Evolution of Aggression.png | preview | Preview for 'Evolution of Aggression' | over 9 years ago, by Francisco J. Romero-Campero | Download |

This model does not have any ancestors.

This model does not have any descendants.