# coevolution

Model was written in NetLogo 6.0.4
•
Viewed 27 times
•
Downloaded 0 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

breed [prey a-prey] breed [predators predator] turtles-own [speed hit erg] predators-own[keen] globals[prey-mean-speed predator-mean-speed slowest-prey-speed slowest-predator-speed] ;------ to setup ca setup-prey setup-predators setup-habitat do-plotting do-plotting-1 reset-ticks end to prey-traits if species = "Shark-fish" [ set color 84 set shape "fish" set size 1.25] if species = "Falcon-duck" [ set color 36 set shape "bird side" set size 1.25] if species = "Wolf-elk" [set color 22 set shape "elk" set size 2.25] end to predator-traits if species = "Shark-fish" [set color 2 set size 4 set shape "shark"] if species = "Falcon-duck" [ set color 33 set shape "hawk" set size 2.5] if species = "Wolf-elk" [set color 0 set shape "wolf" set size 1.25] end to set-speed if species = "Shark-fish" [ set speed 1 + random-float 1] if species = "Falcon-duck" [ set speed 9 + random-float 1] if species = "Wolf-elk" [set speed 3 + random-float 1] end to setup-prey create-prey Number-of-Prey [prey-traits set-speed setxy random-xcor random-ycor] end to setup-predators create-predators Number-of-Predators [predator-traits set hit 0 set-speed setxy random-xcor random-ycor] end to setup-habitat ask patches [if species = "Shark-fish" [ set pcolor 105] if species = "Falcon-duck" [ set pcolor 88] if species = "Wolf-elk" [set pcolor green] ] end ;------------ to go if years = 0 [user-message "input the years"] if ticks >= years [stop] setup-habitat ask prey [prey-traits] ask predators [predator-traits] move predation predator-death if count prey = 0 [user-message "There is no prey." stop ] if count predators = 0 [user-message "There is no predator." stop ] reproduction energy-back do-plotting do-plotting-1 tick end to move ask turtles [rt random 45 lt random 45 fd 1] end to predation ask predators [ set hit 0 ifelse spot-the-slowest-prey? [repeat 5 [ let meal one-of prey with [speed = min [speed] of prey] if meal != nobody [if [speed] of meal < [speed] of self [ set hit hit + 1 ask meal [die] ] ]]] [repeat 5 [ let meal one-of prey if meal != nobody [if [speed] of meal < [speed] of self [ set hit hit + 1 ask meal [die] ] ]]] ] end to predation-1 ask predators [ set hit 0 ifelse spot-the-slowest-prey? [repeat 5 [ let possible-meal prey in-radius 10 ;Given the radius, the predator only hunts a subgroup of the population. This allows some slow prey survive at some point. if possible-meal != nobody [ let meal one-of prey with [speed = min [speed] of possible-meal] if meal != nobody [if [speed] of meal < [speed] of self [ set hit hit + 1 ask meal [die] ] ]]]] [repeat 5 [ let meal one-of prey in-radius 10 if meal != nobody [if [speed] of meal < [speed] of self [ set hit hit + 1 ask meal [die] ] ]]] ] end to predator-death ask predators with [hit < 3] [die] end to reproduction set prey-mean-speed mean [speed] of prey set predator-mean-speed mean [speed] of predators create-prey Number-of-Prey - count prey [prey-traits ifelse random 2 = 0 [set speed prey-mean-speed + random-float Prey-speed-mutation][set speed prey-mean-speed - random-float Prey-speed-mutation] setxy random-xcor random-ycor] create-predators Number-of-Predators - count predators [predator-traits ifelse random 2 = 0 [set speed predator-mean-speed + random-float Predator-speed-mutation][set speed predator-mean-speed - random-float Predator-speed-mutation] setxy random-xcor random-ycor] end to energy-back ;This procedure is not in use. ask patches [if pcolor = 0 [if species = "Shark-fish" [ set pcolor 105] if species = "Falcon-duck" [ set pcolor 88] if species = "Wolf-elk" [set pcolor green] ] ] end to add-fast-prey create-prey 1 [setxy random-xcor random-ycor prey-traits set speed max [speed] of prey + random-float 0.5] end to add-slow-prey set slowest-prey-speed min [speed] of prey if slowest-prey-speed <= 0 [user-message "Have reached the slowest speed" stop] create-prey 1 [setxy random-xcor random-ycor prey-traits set speed slowest-prey-speed - random-float 0.3 ] end to add-fast-predator create-predators 1 [setxy random-xcor random-ycor predator-traits set speed max [speed] of predators + random-float 0.5] end to add-slow-predator set slowest-predator-speed min [speed] of predators if slowest-predator-speed <= 0 [user-message "Have reached the slowest speed" stop] create-predators 1 [setxy random-xcor random-ycor predator-traits set speed slowest-predator-speed - random-float 0.3] end to do-plotting set-current-plot "Prey Speed Distribution" set-plot-x-range (round min [speed] of turtles - 1) (round max [speed] of turtles + 1) histogram [speed] of prey end to do-plotting-1 set-current-plot "Predator Speed Distribution" set-plot-x-range (round min [speed] of turtles - 1) (round max [speed] of turtles + 1) histogram [speed] of predators end

There is only one version of this model, created 24 days ago by lin xiang.

This model does not have any ancestors.

This model does not have any descendants.