cgriffit /220 b/My_Simple_Disease_Rates_sans-notes.nlogo

http://danm.ucsc.edu/~cgriffit/220 b/my_simple_disease_rates_sans-notes.html

;;; my simple disease rates by cmgriffiths

globals [

yellow-count cyan-count

]

turtles-own [

disease disease-remainder

]

to setup

clear-output setup-experiment

end

to setup-experiment

cp ct clear-all-plots reset-ticks crt carrying-capacity [

setxy random-xcor random-ycor ifelse who < (carrying-capacity / 2)

set color cyan? set color yellow?

set size 4

] setup-plot plot-counts

end

to go

wander reproduce grim-reaper tick plot-counts

end

to go-experiment

go if yellow-count = 0 [

output-print (word "yellow eradicated after " ticks " generations") setup-experiment

] if cyan-count = 0 [

output-print (word "cyan eradicated after " ticks " generations") setup-experiment

]

end

to wander

ask turtles [

rt random-float 30 - random-float 30 fd 5

]

end

to reproduce

ask turtles [

ifelse color = yellow [

set disease floor yellow-disease set disease-remainder yellow-disease - (floor yellow-disease)

] [

set disease floor cyan-disease set disease-remainder cyan-disease - (floor cyan-disease)

] ifelse (random-float 100) < (100 * disease-remainder)

hatch disease + 1? hatch disease?

]

end

;; kill turtles in excess of carrying capacity ;; note that yellow and cyan have equal probability of dying to grim-reaper

let num-turtles count turtles if num-turtles <= carrying-capacity

stop?

let chance-to-die (num-turtles - carrying-capacity) / num-turtles ask turtles [

if random-float 1.0 < chance-to-die

die?

]

end

to plot-counts

set-current-plot "Populations"

set yellow-count count turtles with color = yellow? set-current-plot-pen "Yellow" plot yellow-count

set cyan-count count turtles with color = cyan? set-current-plot-pen "Cyan" plot cyan-count

set-current-plot-pen "Total" plot count turtles

end

to setup-plot

set-current-plot "Populations" set-plot-y-range 0 floor (carrying-capacity * 1.2)

end

; *** Net Logo 4.0.2 Model Copyright Notice *** ;

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. ; ; Copyright 1997 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to Net Logo as part of the projects:

PARTICIPATORY SIMULATIONS
NETWORK-BASED DESIGN FOR SYSTEMS LEARNING

; IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. ; The project gratefully acknowledges the support of the ; National Science Foundation (REPP & ROLE programs) -- ; grant numbers REC #9814682 and REC-0126227. ; Converted from StarLogoT to Net Logo, 2001. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1997). Net Logo Simple Birth Rates model.

http
//ccl.northwestern.edu/netlogo/models/Simple Birth Rates?.

; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1997 Uri Wilensky. All rights reserved.

See http
//ccl.northwestern.edu/netlogo/models/Simple Birth Rates?

; for terms of use. ; ; *** End of Net Logo 4.0.2 Model Copyright Notice ***


Page Details
Contact DANM  |  Digital Arts and New Media  |  Arts Division  |  Grad Division
login