;INTERNALLY-DEFINED PARAMETERS ;=========================================================================================================================================================================================== globals [ ;global parameters parameter-check generations generations-counter filename unoccupied-patch-counter occupied-patch-counter patch-recolonization-counter patch-extinction-counter turtle-counter turtle-data pop-size pre-disperse-n discard temp ;landscape parameters h-amt H m-cost mean-disturb sigma N addition maxlevel stage smD lgD x y x0 x1 x2 x3 x4 delta total-patch-number landscape-data select-cell p ;reproduction parameters a offspring ;dispersal parameters move-turn current-habitat current-cost new-habitat new-cost available directions-list angle what-patch? new-habitat-mortality current-habitat-mortality matrix-mortality actual-emigrations ;disturbance parameters patches-list select-years current-counter ;landscape change parameters change-rate n-loss ] ;attributes of grid cells patches-own [ cost patch-id fractal-value group needs-assessment disturbance-counter cell-lambda current-mean-reproduction previous-n current-n ] ;attributes of individuals turtles-own [ pr-move p-shape-m p-shape-h pr-cross origin origin-patch destination destination-patch ] ;MODEL PROCESSES AND SUBPROCESSES ;=========================================================================================================================================================================================== to set-up ;sets up for a simulation run ;clear any previous grid landscape clear-all reset-ticks ;specifies where to save simulation data, and sets up the file for saving data (if the user chooses to save the data) if (file-exists? file-directory = true)[set-current-directory file-directory] if (save-output = true)[ set filename (word output-file ".txt") if file-exists? filename = false [ file-open filename file-print "run generation rate_habitat_loss habitat_amount habitat_fragmentation matrix_cost disturbance_frequency habitat_cost carrying_capacity lambda competition_type mutation_rate mutation_increment dispersal_probability probability_boundary_crossing path_shape_matrix path_shape_habitat pre_disperse_n post_disperse_n n_patches emigration immigration natal_patch_settlement natal_habitat_mortality new_habitat_mortality matrix_mortality recolonization local_extinction" file-close ] ] end to run-model ;runs the full model (evolution of dispersal characteristics and response to habitat loss), or only the habitat-loss part of the model, depending on whether the user chooses to load an existing simulation or not ifelse (load-existing-simulation = false)[run-full-model][run-loss-model] stop end to run-full-model ;simulates the evolution of dispersal characteristics + response to habitat loss ;checks model parameters, to make sure user-defined values are valid; stops simulation if any are invalid check-user-input if (parameter-check = 1)[stop] parameterize set change-rate 0 set generations-counter 0 set generations (initial-generations + habitat-loss-generations) create-landscape populate-landscape ;runs model through the user-defined number of generations repeat generations[ ;runs habitat-loss subprocedure only in the second part of the simulation model if (generations-counter >= initial-generations)[ habitat-loss set change-rate rate-habitat-loss ] ask patches with [pcolor = green][set previous-n count turtles-here] disturb if any? turtles [ reproduce set pre-disperse-n count turtles disperse if any? turtles [ ask patches with [pcolor = green][set current-n count turtles-here] set generations-counter (generations-counter + 1) if (save-output = true)[save-data] if (generations-counter = initial-generations and save-final-generation = true)[ save-final-population save-final-landscape save-final-parameters ] ;reset counters set actual-emigrations 0 set matrix-mortality 0 set new-habitat-mortality 0 set current-habitat-mortality 0 ] ] if not any? turtles [stop] tick ] if ((save-final-generation = true) and (any? turtles) and (generations != initial-generations))[ save-final-population save-final-landscape save-final-parameters ] end to run-loss-model ;simulates the population response to habitat loss set change-rate previous-rate-of-loss set generations-counter previous-generations set generations habitat-loss-generations ;checks model parameters, to make sure user-defined values are valid; stops simulation if any are not valid check-user-input if (parameter-check = 1)[stop] ;loads simulation data from text files reparameterize recreate-landscape repopulate-landscape set change-rate rate-habitat-loss repeat generations[ habitat-loss ask patches with [pcolor = green][set previous-n count turtles-here] disturb if any? turtles [ reproduce set pre-disperse-n count turtles disperse if any? turtles [ ask patches with [pcolor = green][set current-n count turtles-here] set generations-counter (generations-counter + 1) if (save-output = true)[save-data] ;reset counters set actual-emigrations 0 set matrix-mortality 0 set new-habitat-mortality 0 set current-habitat-mortality 0 ] ] if not any? turtles [stop] tick ] if (save-final-generation = true and any? turtles)[ save-final-population save-final-landscape save-final-parameters ] end to check-user-input ;checks to make sure the user-defined parameter values are within the accepted ranges of values ;if any value is outside of accepted ranges, prints a message to the 'command center' set parameter-check 0 if ((load-existing-simulation = true) or (save-output = true) or (save-final-generation = true))[ if (file-exists? file-directory = false) [ set parameter-check 1 print "File directory does not exist" ] ] ;only checks for full simulation runs - otherwise these values are loaded from a previous simulation run (saved to text file), rather than from the user interface if (load-existing-simulation = false)[ if (minimum-habitat-amount <= 0 or maximum-habitat-amount > 1)[ set parameter-check 1 output-print "Habitat amount must range from >0 to 1" ] if (minimum-matrix-cost < 0 or maximum-matrix-cost > 1)[ set parameter-check 1 output-print "Matrix cost must range from 0 to 1" ] if (minimum-disturbance-interval < 1)[ set parameter-check 1 output-print "Minimum disturbance interval must be at least 1" ] if (minimum-fragmentation < 0 or maximum-fragmentation > 1)[ set parameter-check 1 output-print "Fragmentation must range from 0 to 1" ] if ((minimum-habitat-amount >= maximum-habitat-amount) or (minimum-matrix-cost >= maximum-matrix-cost) or (minimum-disturbance-interval >= maximum-disturbance-interval) or (minimum-fragmentation >= maximum-fragmentation))[ set parameter-check 1 output-print "Minimum variable values must be smaller than maximum variable values" ] if (initial-generations < 1)[ set parameter-check 1 output-print "Initial generations must be at least 1" ] if (lambda < 1)[ set parameter-check 1 output-print "Lambda must be at least 1" ] if (carrying-capacity < 1)[ set parameter-check 1 output-print "Carrying capacity must be at least 1" ] if (habitat-cost < 0 or habitat-cost > 1)[ set parameter-check 1 output-print "Habitat cost must range from 0 to 1" ] if (competition-type < 1)[ set parameter-check 1 output-print "Competition-type must be at least 1" ] if (mutation-rate < 0 or mutation-rate > 1)[ set parameter-check 1 output-print "Mutation rate must range from 0 to 1" ] if (mutation-increment < 0 or mutation-increment > 0.5)[ set parameter-check 1 output-print "Mutation increment must range from 0 to 0.5" ] ] if (habitat-loss-generations < 0)[ set parameter-check 1 output-print "Generations of habitat loss must be at least 0" ] if (rate-habitat-loss < 0 or rate-habitat-loss > 1)[ set parameter-check 1 output-print "Rate of habitat loss must range from 0 to 1" ] end to parameterize ;sets parameter values ;randomly selects a value for each of the four landscape attributes random-seed new-seed set h-amt random-float (maximum-habitat-amount - minimum-habitat-amount) + minimum-habitat-amount set m-cost random-float (maximum-matrix-cost - minimum-matrix-cost) + minimum-matrix-cost set H random-float (maximum-fragmentation - minimum-fragmentation) + minimum-fragmentation set mean-disturb random-float (maximum-disturbance-interval - minimum-disturbance-interval) + minimum-disturbance-interval ;additional parameters for fractal surface generation set sigma 1 set N max-pycor set addition 1 end to create-landscape ;generates the landscape structure, based on the four landscape attributes create-fractal-surface ;sets habitat locations, dispersal cost and lambda ask max-n-of (round (count patches * h-amt)) patches [fractal-value][ set pcolor green set cost habitat-cost set cell-lambda lambda ] ;sets matrix locations and dispersal cost ask patches with [pcolor != green][ set pcolor black set cost m-cost ] ;identify habitat patches and set initial time to disturbance for each patch set-patch-numbers set-patch-labels set patches-list n-values total-patch-number [? + 1] foreach patches-list [ set select-years random-poisson mean-disturb ask patches with [patch-id = ?][ set disturbance-counter select-years ] ] end to create-fractal-surface ;algorithm to create a fractal surface (according to Saupe 1988) set maxlevel ceiling (log N 2) set delta sigma ask patch 0 0 [set fractal-value random-normal 0 delta] ask patch 0 max-pycor [set fractal-value random-normal 0 delta] ask patch max-pxcor 0 [set fractal-value random-normal 0 delta] ask patch max-pxcor max-pycor [set fractal-value random-normal 0 delta] set lgD N set smD N / 2 set stage 1 repeat maxlevel [ set delta delta * 0.5 ^ (0.5 * H) set x smD repeat ((N - 2 * smD) / lgD)[ set y smD repeat ((N - 2 * smD) / lgD)[ ask patch (x + smD) (y + smD) [set x0 fractal-value] ask patch (x + smD) (y - smD) [set x1 fractal-value] ask patch (x - smD) (y + smD) [set x2 fractal-value] ask patch (x - smD) (y - smD) [set x3 fractal-value] ask patch x y [set fractal-value (x0 + x1 + x2 + x3) / 4 + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] if addition = 1 [ set x 0 repeat (N / lgD)[ set y 0 repeat (N / lgD)[ ask patch x y [set fractal-value fractal-value + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] ] set delta delta * 0.5 ^ (0.5 * H) set x smD repeat ((N - 2 * smD) / lgD)[ ask patch (x + smD) 0 [set x0 fractal-value] ask patch (x - smD) 0 [set x1 fractal-value] ask patch x smD [set x2 fractal-value] ask patch x 0 [set fractal-value (x0 + x1 + x2) / 3 + random-normal 0 delta] ask patch (x + smD) N [set x0 fractal-value] ask patch (x - smD) N [set x1 fractal-value] ask patch x (N - smD) [set x2 fractal-value] ask patch x N [set fractal-value (x0 + x1 + x2) / 3 + random-normal 0 delta] ask patch 0 (x + smD) [set x0 fractal-value] ask patch 0 (x - smD) [set x1 fractal-value] ask patch smD x [set x2 fractal-value] ask patch 0 x[set fractal-value (x0 + x1 + x2) / 3 + random-normal 0 delta] ask patch N (x + smD) [set x0 fractal-value] ask patch N (x - smD) [set x1 fractal-value] ask patch (N - smD) x [set x2 fractal-value] ask patch N x [set fractal-value (x0 + x1 + x2) / 3 + random-normal 0 delta] set x (x + lgD) ] set x smD repeat ((N - 2 * smD) / lgD)[ set y lgD repeat ((N - smD - lgD) / lgD)[ ask patch x (y + smD) [set x0 fractal-value] ask patch x (y - smD) [set x1 fractal-value] ask patch (x + smD) y [set x2 fractal-value] ask patch (x - smD) y [set x3 fractal-value] ask patch x y [set fractal-value (x0 + x1 + x2 + x3) / 4 + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] set x lgD repeat ((N - smD - lgD) / lgD)[ set y smD repeat ((N - 2 * smD) / lgD)[ ask patch x (y + smD) [set x0 fractal-value] ask patch x (y - smD)[set x1 fractal-value] ask patch (x + smD) y [set x2 fractal-value] ask patch (x - smD) y [set x3 fractal-value] ask patch x y [set fractal-value (x0 + x1 + x2 + x3) / 4 + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] if addition = 1 [ set x 0 repeat (N / lgD)[ set y 0 repeat (N / lgD)[ ask patch x y [set fractal-value fractal-value + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] set x smD repeat (N - 2 * smD) / lgD [ set y smD repeat (N - 2 * smD) / lgD [ ask patch x y [set fractal-value fractal-value + random-normal 0 delta] set y (y + lgD) ] set x (x + lgD) ] ] set lgD (lgD / 2) set smD (smD / 2) set stage (stage + 1) ] end to set-patch-numbers ;identifies contiguous groupings of habitat cells, based on a Moore neighborhood rule ;sets default values for unassigned cells ask patches [ set group -99 set patch-id "" set needs-assessment 0 ] ;assigns all matrix cells to the same group ask patches with [pcolor = black] [set group 0] loop [ ;picks an unassigned cell, at random set select-cell one-of patches with [group = -99] ;if there aren't any unassigned cells, exits the loop if select-cell = nobody [stop] ;makes the selected, unassigned cell the first of a new habitat patch, and searches for all other habitat cells in this patch ask select-cell [ set group self set needs-assessment 1 ;used to identify habitat cells with neighbors that still need to be assessed for membership in the given habitat patch find-all-cells ] ] end to find-all-cells ;identifies all habitat cells belonging to a single habitat patch loop [ ;stops when there are no more cells to be assigned to the given habitat patch if not any? patches with [needs-assessment = 1] [stop] ask patches with [needs-assessment = 1][ set needs-assessment 0 ;identifies that the cell's neighbors have been assessed ;identifies neighboring, unassessed habitat cells as part of the habitat patch ask neighbors with [(group = -99) and (pcolor = green)] [ set group [group] of myself set needs-assessment 1 ] ] ] end to set-patch-labels ;gives each habitat patch a unique patch id number set total-patch-number 0 ;counter to identify each patch with a unique number ask patches with [pcolor = black][set patch-id 0] ;sets patch-id for matrix cells to zero loop [ set p one-of patches with [patch-id = ""] ;picks an unlabelled habitat patch if p = nobody [ stop ] ;stops if all habitat patches have been labelled set total-patch-number (total-patch-number + 1) ;finds all cells within the same habitat patch, and assigns them the unique patch id ask p [ ask patches with [group = [group] of myself] [ set patch-id total-patch-number ] ] ] end to populate-landscape ;seeds the landscape with an initial population ;generates one individual per habitat cell, assigns each to a habitat cell and assigns each individual a random set of values for its dispersal characteristics create-turtles (count patches with [pcolor = green]) [ move-to one-of patches with [pcolor = green] set pr-move precision (random-float 1) 2 set pr-cross precision (random-float 1) 2 set p-shape-m precision (random-float 1) 2 set p-shape-h precision (random-float 1) 2 ] end to disturb ;models local extinction events foreach patches-list [ ;determines current value of disturbance counter for a given habitat patch ask one-of patches with [patch-id = ?][set current-counter (disturbance-counter - 1)] ;if the current counter > 0, sets the patch disturbance counter to its current value; otherwise, all individuals on the patch die and a new time to next disturbance is set ifelse (current-counter > 0)[ ask patches with [patch-id = ?][set disturbance-counter current-counter] ][ set select-years random-poisson mean-disturb ask patches with [patch-id = ?][ ask turtles-here [die] set disturbance-counter select-years ] ] ] end to reproduce ;reproduction, including the transmission of the parental genotype (with probability of mutation) ;calculates the mean number of offspring that can be produced in each habitat cell, based on the number of adults in each cell ask patches with [(pcolor = green) and (any? turtles-here)] [ set a (cell-lambda ^ (1 / competition-type) - 1) / carrying-capacity set current-mean-reproduction cell-lambda / ((1 + a * count turtles-here) ^ competition-type) ] ask turtles [ ;retrieves mean number of offspring that can be produced in the habitat cell (as calculated above), and draws a number from a Poisson distribution ask patch-here [set offspring random-poisson current-mean-reproduction] hatch offspring[ ;sets a random initial dispersal direction set heading random 360 ;determines if there is mutation for each dispersal gene if (random-float 1 < mutation-rate)[ ;50% chance of increasing gene value, 50% chance of decreasing gene value ifelse (random-float 1 < 0.5)[set pr-move (pr-move + mutation-increment)][set pr-move (pr-move - mutation-increment)] ;cannot mutate to a value < 0; forces mutation to a larger value if (pr-move < 0)[set pr-move (pr-move + 2 * mutation-increment)] ;cannot mutate to a value >1; forces mutation to a smaller value if (pr-move > 1)[set pr-move (pr-move - 2 * mutation-increment)] ] if (random-float 1 < mutation-rate)[ ifelse (random-float 1 < 0.5)[set pr-cross (pr-cross + mutation-increment)][set pr-cross (pr-cross - mutation-increment)] if (pr-cross < 0)[set pr-cross (pr-cross + 2 * mutation-increment)] if (pr-cross > 1)[set pr-cross (pr-cross - 2 * mutation-increment)] ] if (random-float 1 < mutation-rate)[ ifelse (random-float 1 < 0.5)[set p-shape-m (p-shape-m + mutation-increment)][set p-shape-m (p-shape-m - mutation-increment)] if (p-shape-m < 0)[set p-shape-m (p-shape-m + 2 * mutation-increment)] if (p-shape-m > 1)[set p-shape-m (p-shape-m - 2 * mutation-increment)] ] if (random-float 1 < mutation-rate)[ ifelse (random-float 1 < 0.5)[set p-shape-h (p-shape-h + mutation-increment)][set p-shape-h (p-shape-h - mutation-increment)] if (p-shape-h < 0)[set p-shape-h (p-shape-h + 2 * mutation-increment)] if (p-shape-h > 1)[set p-shape-h (p-shape-h - 2 * mutation-increment)] ] ] ;adult dies after reproduction die ] end to disperse ;dispersal, resulting in either settlement in a habitat cell or mortality ask turtles[ ;identifies the natal habitat cell and patch set origin patch-here ask patch-here[set what-patch? patch-id] set origin-patch what-patch? ;determines whether the individual disperses or not, based on the dispersal probability gene ifelse (random-float 1 < pr-move)[ ;continues dispersing, in steps of one cell-length each, until the individual settles or dies loop[ ;records the current location (in habitat or matrix) and the associated dispersal cost ask patch-here [ set current-cost cost set current-habitat pcolor ] ;selects a turn angle, based on its location in habitat or matrix ifelse (current-habitat = 0)[set heading (heading + wrapped-cauchy p-shape-m)][set heading (heading + wrapped-cauchy p-shape-h)] ;if the intended step would take the individual out of the landscape bounds, selects a new heading that keeps the individual within the landscape ifelse (can-move? 1 = true)[ forward 1 ] [ set heading available-direction forward 1 ] ;records the new location (in habitat or matrix) and the associated dispersal cost ask patch-here [ set new-habitat pcolor set new-cost cost ] ;checks to see if the step crosses from habitat to matrix if (new-habitat = 0 and current-habitat = 55)[ ;determines whether the individual will cross the boundary or not, based on the boundary-crossing gene: if the individual avoids crossing the boundary, moves back to the previous location and selects a new movement direction that keeps the individual within habitat; if there is no heading that will keep the individual within habitat, the individual stays in the current location if (random-float 1 >= pr-cross)[ forward -1 if any? neighbors with [pcolor = green][ let select-angle available-habitat-direction if (select-angle != -99) [ set heading select-angle forward 1 ] ] ask patch-here[ set new-habitat pcolor set new-cost cost ] ] ] ;determines whether the individual dies or not, based on the costs associated with the cells the individual moves across if random-float 1 < ((current-cost + new-cost) / 2)[ ;if the individual dies, identifies whether the individual emigrated (i.e. wasn't in its natal habitat cell at time of death) and where it died (in the natal habitat patch, in a new habitat patch or in the matrix) set destination patch-here ask patch-here[set what-patch? patch-id] set destination-patch what-patch? if (origin != destination)[ set actual-emigrations (actual-emigrations + 1) ifelse (current-habitat = 55)[ ifelse (origin-patch = destination-patch)[ set current-habitat-mortality (current-habitat-mortality + 1) ][ set new-habitat-mortality (new-habitat-mortality + 1) ] ][ set matrix-mortality (matrix-mortality + 1) ] ] die ] ;if the individual does not die, determines whether the individual settles in habitat or continues to disperse if ((new-habitat = 55) and ((count turtles-here - 1) < carrying-capacity))[ set destination patch-here ask patch-here[set what-patch? patch-id] set destination-patch what-patch? stop ] ] ][ set destination origin set destination-patch origin-patch ] ] end to habitat-loss ;habitat loss, as a set proportion of habitat cells converted to matrix set n-loss round (count patches with [pcolor = green] * rate-habitat-loss) repeat n-loss [ ask one-of patches with [(pcolor = green) and (any? neighbors with [pcolor = black])][ set cost m-cost set pcolor black set cell-lambda 0 ask turtles-here [die] ] ] ;sets new patch numbers, to account for the change in number of patches when habitat is lost set-patch-numbers set-patch-labels set patches-list n-values total-patch-number [? + 1] end ; READ DATA FROM, OR WRITE DATA TO, SPACE-DELIMITED TEXT FILES ;=========================================================================================================================================================================================== to save-data ;saves data for a given generation ;calculates the rates of recolonization and local extinction set unoccupied-patch-counter 0 set occupied-patch-counter 0 set patch-recolonization-counter 0 set patch-extinction-counter 0 foreach patches-list [ ifelse not any? patches with [(patch-id = ?) and (previous-n > 0)][ set unoccupied-patch-counter (unoccupied-patch-counter + 1) if any? patches with [(patch-id = ?) and (current-n > 0)][ set patch-recolonization-counter (patch-recolonization-counter + 1) ] ][ set occupied-patch-counter (occupied-patch-counter + 1) if not any? patches with [(patch-id = ?) and (current-n > 0)][ set patch-extinction-counter (patch-extinction-counter + 1) ] ] ] ;saves the data to a text file set filename (word output-file ".txt") file-open filename file-type run-id file-write generations-counter file-write change-rate file-write count patches with [pcolor = green] / count patches file-write H file-write m-cost file-write mean-disturb file-write habitat-cost file-write carrying-capacity file-write lambda file-write competition-type file-write mutation-rate file-write mutation-increment file-write mean [pr-move] of turtles file-write mean [pr-cross] of turtles file-write mean [p-shape-m] of turtles file-write mean [p-shape-h] of turtles file-write pre-disperse-n file-write count turtles file-write total-patch-number file-write actual-emigrations + count turtles with [origin != destination] file-write count turtles with [origin-patch != destination-patch] file-write (count turtles with [origin != destination] - count turtles with [origin-patch != destination-patch]) file-write current-habitat-mortality file-write new-habitat-mortality file-write matrix-mortality ifelse (unoccupied-patch-counter > 0) [file-write patch-recolonization-counter / unoccupied-patch-counter][file-type " NA"] file-type " " ifelse (occupied-patch-counter > 0)[file-print patch-extinction-counter / occupied-patch-counter][file-print "NA"] file-close end to save-final-parameters ;saves parameter values at the end of the simulation run set filename (word "run_" run-id "_parameters_rate_" change-rate "_gen_" generations-counter ".txt") file-open filename file-print "habitat_amount fragmentation matrix_cost disturbance habitat_cost competition_type mutation_increment mutation_rate carrying_capacity lambda population_size" file-type h-amt file-write H file-write m-cost file-write mean-disturb file-write habitat-cost file-write competition-type file-write mutation-increment file-write mutation-rate file-write carrying-capacity file-write lambda file-type " " file-print count turtles file-close end to reparameterize ;reads in parameter values from a text file set filename (word "run_" run-id "_parameters_rate_" change-rate "_gen_" generations-counter ".txt") ;checks to see if the user-specified file exists if (file-exists? filename = false)[ print "Missing parameters file" stop ] file-open filename set discard file-read-line ;skips column titles set h-amt file-read set H file-read set m-cost file-read set mean-disturb file-read set habitat-cost file-read set competition-type file-read set mutation-increment file-read set mutation-rate file-read set carrying-capacity file-read set lambda file-read set pop-size file-read file-close ;set additional parameters for fractal surface generation set sigma 1 set N max-pycor set addition 1 end to save-final-landscape ;saves data to recreate the simulated landscape at the end of the simulation run set filename (word "run_" run-id "_landscape_rate_" change-rate "_gen_" generations-counter ".txt") file-open filename file-print "x_cor y_cor color cost time_to_disturbance patch_id" ask patches[ file-type pxcor file-write pycor file-write pcolor file-write cost file-write disturbance-counter file-type " " file-print patch-id ] file-close end to recreate-landscape ;recreates the simulated landscape from data in a text file set filename (word "run_" run-id "_landscape_rate_" change-rate "_gen_" generations-counter ".txt") ;checks to see if the user-specified file exists if (file-exists? filename = false)[ print "Missing landscape file" stop ] set landscape-data [] file-open filename set discard file-read-line ;skips column titles ;reads data from file while [ not file-at-end? ][ set landscape-data sentence landscape-data (list (list file-read file-read file-read file-read file-read file-read)) ] file-close ;assigns values to each grid cell foreach landscape-data [ ask patch item 0 ? item 1 ? [ set pcolor item 2 ? set cost item 3 ? set disturbance-counter item 4 ? set patch-id item 5 ? if (pcolor = 55)[set cell-lambda lambda] ] ] ask max-one-of patches [patch-id][set total-patch-number patch-id] set patches-list n-values total-patch-number [? + 1] end to save-final-population ;save data for each individual at the end of the simulation run set filename (word "run_" run-id "_population_rate_" change-rate "_gen_" generations-counter ".txt") file-open filename file-print "id x_cor y_cor heading dispersal_probability boundary_crossing_probability path_shape_matrix path_shape_habitat" set turtle-counter 0 ask turtles [ file-type turtle-counter file-write xcor file-write ycor file-write heading file-write pr-move file-write pr-cross file-write p-shape-m file-type " " file-print p-shape-h set turtle-counter (turtle-counter + 1) ] file-close end to repopulate-landscape ;populates the landscape from data in a text file set filename (word "run_" run-id "_population_rate_" change-rate "_gen_" generations-counter ".txt") ;checks to see if the user-specified file exists if (file-exists? filename = false)[ print "Missing population file" stop ] clear-turtles set turtle-data [] file-open filename set discard file-read-line ;skips column titles ;reads data from file while [ not file-at-end? ][ set turtle-data sentence turtle-data (list (list file-read file-read file-read file-read file-read file-read file-read file-read)) ] file-close ;creates population and assigns each individual its starting values, from the data saved in ‘turtle-data’ create-turtles pop-size foreach turtle-data[ ask turtle item 0 ? [ set xcor item 1 ? set ycor item 2 ? set heading item 3 ? set pr-move item 4 ? set pr-cross item 5 ? set p-shape-m item 6 ? set p-shape-h item 7 ? ] ] end ;CUSTOM FUNCTIONS ;=========================================================================================================================================================================================== to-report wrapped-cauchy [turn-p] ;function to calculate new headings based on a wrapped Cauchy distribution set angle (1 - turn-p) / (1 + turn-p) * tan (180 * (random-float 1 - 0.5)) set move-turn 180 - 2 * atan 1 angle set move-turn round move-turn report move-turn end to-report available-direction [] ;function to select a random heading, from the subset of headings that keep the individual within the landscape bounds set directions-list n-values 360 [?] set available [] ;identifies the headings that keep the individual within the landscape bounds foreach directions-list [ if (patch-at-heading-and-distance ? 1 != nobody)[set available lput ? available] ] ;randomly selects a heading from the list of available headings set angle one-of available report angle end to-report available-habitat-direction [] ;function to select a random heading, from the subset of headings that keep the individual within habitat set directions-list n-values 360 [?] set available [] ;identifies the headings that will not result in boundary-crossing + keep the individual within the landscape bounds foreach directions-list [ if (patch-at-heading-and-distance ? 1 != nobody)[ ask patch-at-heading-and-distance ? 1 [ if (pcolor = green)[set available lput ? available] ] ] ] ;randomly selects a heading from the list of available headings; if there are no available directions, returns -99 instead of the heading ifelse (length available > 0)[set angle one-of available][set angle -99] report angle end @#$#@#$#@ GRAPHICS-WINDOW 848 102 1304 579 -1 -1 3.512 1 10 1 1 1 0 0 0 1 0 126 0 126 1 1 1 Generation 30.0 BUTTON 38 35 135 95 SET UP set-up NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 38 103 136 163 RUN MODEL run-model NIL 1 T OBSERVER NIL NIL NIL NIL 1 INPUTBOX 335 101 474 161 run-id 1 1 0 Number INPUTBOX 182 101 326 161 output-file data 1 0 String INPUTBOX 181 34 475 94 file-directory C:\\\\ 1 0 String TEXTBOX 182 11 392 30 MODEL INPUT-OUTPUT 14 115.0 1 INPUTBOX 674 298 829 358 rate-habitat-loss 0.01 1 0 Number INPUTBOX 345 228 500 288 minimum-habitat-amount 0.1 1 0 Number INPUTBOX 345 295 500 355 minimum-fragmentation 0 1 0 Number INPUTBOX 344 364 499 424 minimum-matrix-cost 0.0060 1 0 Number INPUTBOX 342 431 497 491 minimum-disturbance-interval 5 1 0 Number INPUTBOX 507 227 662 287 maximum-habitat-amount 1 1 0 Number INPUTBOX 507 297 662 357 maximum-fragmentation 1 1 0 Number INPUTBOX 506 367 661 427 maximum-matrix-cost 0.3 1 0 Number INPUTBOX 506 433 661 493 maximum-disturbance-interval 100 1 0 Number TEXTBOX 17 178 167 197 MODEL PARAMETERS 15 115.0 1 TEXTBOX 19 208 281 238 Evolution of dispersal in the historic landscape 12 0.0 1 TEXTBOX 678 205 831 235 Response to habitat loss 12 0.0 1 INPUTBOX 13 230 168 290 initial-generations 1000 1 0 Number INPUTBOX 675 227 831 287 habitat-loss-generations 100 1 0 Number INPUTBOX 13 295 168 355 lambda 3 1 0 Number INPUTBOX 175 230 330 290 carrying-capacity 6 1 0 Number INPUTBOX 13 366 168 426 habitat-cost 0.0050 1 0 Number INPUTBOX 176 299 331 359 competition-type 1 1 0 Number INPUTBOX 14 435 169 495 mutation-rate 0.0050 1 0 Number INPUTBOX 176 368 331 428 mutation-increment 0.01 1 0 Number SWITCH 488 34 653 67 load-existing-simulation load-existing-simulation 1 1 -1000 SWITCH 488 84 652 117 save-output save-output 1 1 -1000 SWITCH 488 129 653 162 save-final-generation save-final-generation 1 1 -1000 INPUTBOX 668 33 823 93 previous-generations 1000 1 0 Number INPUTBOX 668 102 823 162 previous-rate-of-loss 0.01 1 0 Number MONITOR 850 34 944 79 habitat-amount h-amt 3 1 11 MONITOR 973 34 1066 79 fragmentation H 3 1 11 MONITOR 1090 35 1184 80 matrix-quality m-cost 3 1 11 MONITOR 1209 34 1302 79 disturbance mean-disturb 3 1 11 PLOT 1327 35 1527 203 Population size Generation Population size 0.0 10.0 0.0 10.0 true false "" "" PENS "default" 1.0 0 -16777216 true "" "if (any? turtles) [plotxy generations-counter count turtles]" PLOT 1326 213 1651 391 Dispersal characteristics Generation Mean trait value 0.0 10.0 0.0 1.0 true true "" "" PENS "dispersal probability" 1.0 0 -16777216 true "" "if any? turtles [plotxy generations-counter mean [pr-move] of turtles]" "boundary crossing" 1.0 0 -8630108 true "" "if any? turtles [plotxy generations-counter mean [pr-cross] of turtles]" "path shape (matrix)" 1.0 0 -2674135 true "" "if any? turtles [plotxy generations-counter mean [p-shape-m] of turtles]" "path shape (habitat" 1.0 0 -14835848 true "" "if any? turtles [plotxy generations-counter mean [p-shape-h] of turtles]" PLOT 1326 401 1604 578 Mobility Generation Rate 0.0 10.0 0.0 1.0 true true "" "" PENS "emigration" 1.0 0 -955883 true "" "if any? turtles [plotxy generations-counter (actual-emigrations + count turtles with [origin != destination]) / pre-disperse-n]" "immigration" 1.0 0 -13791810 true "" "if any? turtles [plotxy generations-counter count turtles with [origin-patch != destination-patch] / pre-disperse-n]" TEXTBOX 735 505 885 580 Legend\n\ngreen = habitat\nblack = matrix\nyellow = individual 12 0.0 1 @#$#@#$#@ #OVERVIEW This model was designed to simulate the evolution of dispersal characteristics and species mobility in a landscape context, and the population response to habitat loss. Here _mobility_ refers to the tendency to leave the current home range or territory (i.e. _emigration_) and the likelihood of settling in a different habitat patch (i.e. _immigration_). In particular, the model was used to test four hypotheses that might explain contradictory findings on the role of mobility in extinction risk, because in some empirical studies mobility appears to increase species extinction risk, while other studies report the opposite. The four hypotheses were: >**Metric type hypothesis**: The mobility-risk relationship depends on how you measure mobility. This is because extinction risk increases with increasing mobility when mobility is measured as emigration, but decreases with increasing mobility when mobility is measured as immigration. >**Metric context hypothesis**: The most mobile species (whether measured by emigration or immigration) in unaltered landscapes are least mobile in human-altered landscapes, so the relationship between mobility and extinction risk is opposite when mobility is measured in unaltered and altered landscapes. >**Metric range hypothesis**: The mobility-risk relationship is ∩-shaped, thus the mobility-risk relationship will be apparently positive when the study includes sedentary species to moderately mobile species, but the mobility-risk relationship will be negative when the study includes moderately mobile species to highly mobile species. >**Landscape context hypothesis**: The mobility-risk relationship depends on the landscapes of the studied species. This is because some landscape structures drive evolution of dispersal characteristics that increase both mobility and risk, while others drive evolution of characteristics that increase mobility and decrease risk. For full details, please refer to our peer-reviewed paper: * Amanda E. Martin and Lenore Fahrig. _In press_. Reconciling contradictory relationships between mobility and extinction risk in human-altered landscapes. Functional Ecology. DOI: 10.1111/1365-2435.12632 ##HOW TO CITE We ask that you cite both our peer-reviewed paper and the NetLogo software: * Amanda E. Martin and Lenore Fahrig. _In press_. Reconciling contradictory relationships between mobility and extinction risk in human-altered landscapes. Functional Ecology.DOI: 10.1111/1365-2435.12632 * Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. ##COPYRIGHT Copyright 2015 Amanda E. Martin. All rights reserved. For information on the copyright associated with the published paper, please see http://www.functionalecology.org/view/0/copyright.html # MODEL STRUCTURE This model simulates: 1. evolution of dispersal characteristics in the historic landscape, and 1. the population response to habitat loss. The model allows simulation of either the full model (parts 1 + 2), or part 2 alone. If only the habitat loss portion of the simulation model is run, the starting landscape and population are loaded from space-delimited text files saved in a previous simulation run. This feature allows the user to, for example, simulate the effects of different rates of habitat loss on a given population, because you can load the same historic population and landscape and run the simulation with different rates of habitat loss. ##EVOLUTION OF DISPERSAL CHARACTERISTICS IN THE HISTORIC LANDSCAPE A simulation run is initiated by creating an artificial landscape and populating it with individuals, each with a random set of values for its four, heritable dispersal characteristics (defined below). This part of the simulation run continues for a user-specified number of generations in the historic landscape (or until the population goes extinct). Note that we use **habitat cell** and **matrix cell** when referring to a single habitat or matrix cell, respectively. Matrix (i.e. non-habitat) differs from habitat because matrix (a) does not support reproduction, and (b) is associated with a greater risk of dispersal mortality than habitat. **Habitat patch** refers to a contiguous group of habitat cells surrounded by matrix, where habitat cells are grouped based on a Moore (8-neighbor) neighborhood rule. Each generation involves: 1. **habitat disturbance**, causing some local population extinctions, i.e. death of all individuals in a given habitat patch, 1. **reproduction**, including transfer and mutation of dispersal genotypes, and 1. **dispersal**, i.e. movement of individuals from their birth place, resulting in either dispersal mortality or settlement in a new location. Historic landscapes vary in: 1. **habitat amount**: the proportion of the grid cells in habitat; smaller values mean less habitat 1. **habitat fragmentation**: the level of patchiness of habitat, for a given habitat amount, modeled as the Hurst exponent of the midpoint displacement algorithm used to assign locations of habitat and matrix cells (Saupe 1988); smaller values produce more fragmented habitat 1. **matrix quality**: probability of mortality during movement across a matrix cell; smaller values indicate higher matrix quality 1. **disturbance frequency**: mean number of generations until local population extinction, for a Poisson distribution; smaller values indicate more frequent disturbance Four dispersal characteristics are modeled as independent, heritable traits: 1. **dispersal probability**: probability that the individual leaves its natal habitat cell and disperses 1. **probability of boundary crossing**: probability that the individual will cross from habitat to matrix, when it encounters a boundary 1. **path shape in matrix**: correlation in movement direction between successive movement steps originating in matrix, modeled as the concentration parameter for a wrapped Cauchy distribution with a mean of zero 1. **path shape in habitat**: correlation in movement direction between successive movement steps originating in habitat, modeled as the concentration parameter for a wrapped Cauchy distribution with a mean of zero ##POPULATION RESPONSE TO HABITAT LOSS Habitat loss is simulated for a user-specified number of generations, or until the population goes extinct. Habitat disturbance, reproduction, and dispersal are simulated as described above. In each generation prior to reproduction, a proportion of the remaining habitat cells is converted to matrix. This habitat loss is simulated as encroachment of matrix into habitat; cells converted from habitat to matrix are on the edges of habitat patches, i.e. they have at least one neighbouring matrix cell. # MODEL INTERFACE ## MAIN ACTIONS * **SET UP**: prepares for a simulation run; pust be pressed prior to the simulation run * **RUN MODEL**: runs a single simulation run ##MODEL INPUT-OUTPUT * **file-directory**: directory where model input and output are saved * **output-file**: name of the file where model output is saved (if **save-output** = ON, see below) * **run-id**: identifier for a simulation run; _if saving multiple runs to the same directory, the run number should be unique to each simulation run_ * **load-existing-simulation**: ON = only the habitat loss portion of the simulation model is run; the starting landscape and population are loaded from space-delimited text files (as saved by the model when **save-final-generation** = ON, see below); OFF = full simulation model is run (evolution of dispersal characteristics + response to habitat loss) * **previous-generations**: _Only used if load-existing-simulation = ON;_ identifies the number of generations simulated in the simulation data set to be loaded * **previous-rate-of-loss**: _Only used if load-existing-simulation = ON;_ identifies the rate of habitat loss in the simulation data set to be loaded * **save-output**: ON = model output is saved to a space-delimited plain text file, adding a row to the file (specified by **output-file**) in each simulated generation (see MODEL DATA below); OFF = no data are saved * **save-final-generation**: ON = data for the final landscape and population model are saved to space-delimited plain text files, at the end of a simulation run (see MODEL DATA below). If the full simulation model is run, also saves the historic landscape and population (in the generation before habitat loss begins); OFF = no data are saved ##MODEL PARAMETERS _Users must pay attention to the accepted range of values for each parameter. Acceptable parameter values are given below, in brackets. If values are invalid, the model run will be stopped, and a message identifying the problem parameter(s) will be printed to the ‘Command Center’._ ###Evolution of dispersal characteristics in the historic landscape * **initial-generations**: number of generations without habitat loss _(>= 1)_ * **lambda**: variable in the equation used to calculate the mean number of offspring produced by each adult inhabiting a habitat cell (Hassell 1975) _(>=1)_ * **carring-capacity**: variable in the equation used to calculate the mean number of offspring produced by each adult inhabiting a habitat cell (Hassell 1975); also determines whether a dispersing individual settles or continues moving (it can only settle if the habitat cell is below capacity) _(>=1)_ * **habitat-cost**: probability of mortality during movement across a habitat cell _(0 - 1)_ * **competition-type**: variable in the equation used to calculate the mean number of offspring produced by each adult inhabiting a habitat cell (Hassell 1975); 1 = contest competition, >1 = scramble competition _(>= 1)_ * **mutation-rate**: probability of mutation for a given dispersal characteristic _(0 - 1)_ * **mutation-increment**: change in the value of a dispersal characteristic, when mutation occurs _(0 - 0.5)_ * **minimum-** and **maximum-habitat-amount**: defines the range of values for habitat amount in the historic landscape _(>0 - 1)_ * **minimum-** and **maximum-fragmentation**: defines the range of values for habitat fragmentation in the historic landscape _(0 - 1)_ * **minimum-** and **maximum-matrix-cost**: defines the range of values for matrix quality in the historic landscape _(0 - 1)_ * **minimum-** and **maximum-disturbance-interval**: defines the range of values for the disturbance parameter in the historic landscape _(>=1)_ ###Response to habitat loss * **habitat-loss-generations**: number of generations with habitat loss _(>= 0)_ * **rate-habitat-loss**: proportion of habitat converted to matrix in a given generation _(0 - 1)_ ##VISUAL OUTPUT Onscreen output includes: * the value for each of the four landscape attributes * the simulated grid landscape (green = habitat, black = matrix) and population (yellow) * a plot of the population size in each generation * a plot of the population mean trait value for each of the four dispersal characteristics in each generation * a plot of the **emigration rate**, i.e. proportion of the population that left the natal habitat cell and did not return, per generation, and **immigration rate**, i.e. proportion of the population that settled in a different habitat patch, per generation # MODEL OUTPUT ##SAVE-OUTPUT _The following values are saved in a space-delimited text file (.txt) each generation, if _**save-output** = ON. A row is added to this file in each generation. * **run**: identifier for the simulation run * **generation**: current generation * **rate_habitat_loss**: rate of habitat loss; in generations prior to habitat loss, this is set to zero * **model parameters**: parameter values used in the simulation run * **evolved dispersal characteristics**: population mean dispersal trait values * **population size**: number of individuals before dispersal (**pre_disperse_n**) and after dispersal (**post_disperse_n**) * **n_patches**: number of habitat patches (i.e. continuous groupings of habitat cells, completely surrounded by matrix) * **emigration**: number of dispersers that left the natal habitat cell and did not return * **immigration**: number of dispersers that left the natal habitat patch and settled in a new habitat patch * **natal_patch_settlement**: number of dispersers that left the natal habitat cell and settled in a new habitat cell within the natal habitat patch * **natal_habitat_mortality**: number of dispersers that died during dispersal through the natal habitat patch * **new_habitat_mortality**: number of dispersers that died during dispersal through any habitat patch that was not the natal habitat patch * **matrix_mortality**: number of dispersers that died during dispersal through matrix * **recolonization**: proportion of unoccupied habitat patches that were recolonized in that generation; set as "NA" if all patches were occupied at the beginning of the generation * **local_extinction**: proportion of occupied habitat patches that became unoccupied in that generation ##SAVE-FINAL-GENERATION _Saves three space-delimited plain text files after the final simulated generation, if_ **save-final-generation** = ON. Each file is identified by the run-id, rate of habitat loss, and generation. For example, if run 50 ran for 1000 generations, and the rate of habitat loss was 0.03, the model would save files: * run_50_parameters_rate_0.03_gen_1000.txt * run_50_population_rate_0.03_gen_1000.txt * run_50_landscape_rate_0.03_gen_1000.txt These files can be used to continue a simulation run (using **load-existing-simulation** = ON). Note that these files are only saved if the population persists for the user-specified number of generations. ###PARAMETER VALUES Saves the habitat amount, fragmentation, matrix quality, disturbance frequency, habitat cost, competition type, mutation increment, mutation rate, carrying capacity, lambda, and population size for the simulation run. ###FINAL POPULATION Saves the location (x and y coordinates), heading, and evolved dispersal characteristics (dispersal probability, probability of boundary crossing, path shape in matrix, and path shape in habitat) for each individual. ###FINAL LANDSCAPE Saves the location (x and y coordinates), cell color (where habitat = color code 55, matrix = code 0), dispersal cost (with a different cost associated with habitat and matrix cells), time to disturbance, and unique habitat patch ID (identifies which habitat cells belong to each habitat patch) for each grid cell. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 5.1.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@