Vacancy Chains
Model was written in NetLogo 5.0.4
•
Viewed 343 times
•
Downloaded 14 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
;; These are global variables: globals [ ;; The following two boolean variables take the values 0 and 1 instead of true and false because they must be able ;; to generate error messages even if they have not been initialized. positions-made? ;; positions must be made before vacancies can be made; vacancies-made? ;; vacancies must be made before vacancy chains can be made; wall-length ;; is the length of walls; meter ;; measures the length of walls; direction ;; tells where walls are expanded; x-target ;; the x-coordinate of a position to be reached; y-target ;; the y-coordinate of a position to be reached; reachable? ;; whether the target position can be actually reached; x y ;; scan the screen in search for patches where new turtles can be posed; cum-num-chains-by-length-list ;; a list for the cumulative number of chains, where each element refers to a different chain length max-chain-length-attained ;; the maximum length vacancy chains actually reached. ] ;; These variables belong to patches: patches-own [elevation] ;; the stratum of a patch, with 0 as the lowest stratum. ;; These variables belong to turtles: turtles-own [cl] ;; the length of a vacancy chain. ;; Repeats the sequence "setup-hierarchy" - "setup-vacancies" - "go" so many times as the parameter "times". ;; At the end, it prints on the Command Center the average number of chains for each chain length. to iterate ;; The list is filled up with values. Counters are in order because this list may entail several instances of the same value. repeat times [ setup-positions setup-vacancies go ;; The list of the cumulative number of chains of each length is initialized. set cum-num-chains-by-length-list [] repeat max-chain-length [set cum-num-chains-by-length-list fput 0 cum-num-chains-by-length-list] ;; Introduces a counter. let i 0 ;; Updates the list of the cumulative number of chains of each length. foreach cum-num-chains-by-length-list [ set cum-num-chains-by-length-list replace-item i cum-num-chains-by-length-list (? + count turtles with [cl = i + 1]) set i (i + 1) ] ] ;; The list is stripped of all last 0 values. set cum-num-chains-by-length-list reverse cum-num-chains-by-length-list let first-non-zero-value-found? false foreach cum-num-chains-by-length-list [ ifelse (? = 0 and first-non-zero-value-found? = false) [set cum-num-chains-by-length-list remove ? cum-num-chains-by-length-list] [set first-non-zero-value-found? true] ] set cum-num-chains-by-length-list reverse cum-num-chains-by-length-list set max-chain-length-attained length cum-num-chains-by-length-list ;; Output is printed on the screen let i 0 foreach cum-num-chains-by-length-list [ set i (i + 1) type "Percent of chains of length " type i type ": " ifelse (sum cum-num-chains-by-length-list > 0) [print ? * 100 / sum cum-num-chains-by-length-list] [print 0] ] print "" let cum-num-chains-by-length-except-length-one-list remove-item 0 cum-num-chains-by-length-list type "Number of chains of length greater than 1: " print (sum cum-num-chains-by-length-except-length-one-list) / times type "Percent of chains of length greater than 1: " ifelse (sum cum-num-chains-by-length-list > 0) [print (sum cum-num-chains-by-length-except-length-one-list) * 100 / (sum cum-num-chains-by-length-list)] [print 0] print "" print "" print "" end to setup-positions clear-all ;; Patches are assigned an "elevation" either according to a decreasing exponential or a uniform or an increasing exponential ;; distribution. Elevation takes integer values. ;; The elevation is reflected by a gray scale. Patches with highest elevation are white, patches with lowest elevation are black. ask turtles [die] ask patches [ ;; Decreasing exponential distribution. if (strata-distribution = "hierarchical") [ set elevation n-of-strata + 1 while [elevation > n-of-strata] [set elevation round random-exponential ((1 + n-of-strata) / 4)] ] ;; The complement of a decreasing exponential distribution. if (strata-distribution = "inverse") [ set elevation -1 while [elevation < 0] [set elevation n-of-strata - round random-exponential ((1 + n-of-strata) / 4)] ] ;; Uniform distribution. if (strata-distribution = "linear") [set elevation random (1 + n-of-strata)] ;; Mixed: decreasing exponential for high strata, the complement of a poisson distribution for low strata. if (strata-distribution = "lean") [ ifelse (random 2 = 0) [ set elevation n-of-strata + 1 while [elevation > n-of-strata] [set elevation round random-exponential (1 + n-of-strata) / 4] ][ set elevation -1 while [elevation < 0] [set elevation n-of-strata - round random-poisson (1 + n-of-strata) / 4] ] ] if (elevation <= n-of-strata) [set pcolor scale-color black elevation 0 n-of-strata] ] ;; Builds walls. if (n-walls > 0) [ while [count patches with [pcolor = red] < n-walls] [ ask patch (random-pxcor) (random-pycor) [ set pcolor red set elevation n-of-strata + 1 ] ] ask patches with [pcolor = red] [ set wall-length (random max (list max-pxcor max-pycor) + 1) if (wall-length > 1) [ set meter 1 set direction random 360 add-brick ] ] ] ;; Global variables keep track of the fact that positions have been made, whereas vacancies are still waiting. set positions-made? 1 set vacancies-made? 0 end ;; Bricks are added to walls. This procedure is called by "setup-positions". to add-brick let next-brick patch-at-heading-and-distance direction 1 let reach 1 while [[pcolor] of next-brick = red and any? patches with [pcolor != red]] [ set reach reach + 1 if (random 10 <= 1) [set direction random 360] set next-brick patch-at-heading-and-distance direction reach ] ask next-brick [ set pcolor red set elevation n-of-strata + 1 set meter meter + 1 if (meter < wall-length) [add-brick] ] end to setup-vacancies ifelse (starting-stratum > n-of-strata) [ print "The starting stratum cannot be greater than the number of strata." ][ ifelse (positions-made? = 0) [ print "Please press the Setup Positions button." ][ ;; Two nested WHILEs in order to scan the screen. ;; If a free patch of the required elevation is found, a new turtle is created and posed there. set x min-pxcor while [x <= max-pxcor] [ set y min-pycor while [y <= max-pycor] [ if ([elevation] of patch x y = starting-stratum) [ set-default-shape turtles "vacancy" crt 1 [ set color green set xcor x set ycor y set cl 0 ] ] set y (y + 1) ] set x (x + 1) ] ;; A global variable keeps track of the fact that vacancies have been made available. set vacancies-made? 1 ] ] reset-ticks end to go ifelse (starting-stratum > n-of-strata) [ print "The starting stratum cannot be greater than the number of strata." ][ if (positions-made? = 0) [print "Please press the 'Setup Positions' button."] if (vacancies-made? = 0) [print "Please press the 'Setup Vacancies' button."] if (positions-made? = 1 and vacancies-made? = 1) [ ask turtles [form-chains] ;; Vacancy chains cannot be formed again. set positions-made? 0 set vacancies-made? 0 ] ] tick end to form-chains ;; This procedure calls itself recursively with decreasing values of elevation until two or more patches with equal elevation are found. ;; Elevation in neighboring patches. Angles are measured clockwise from pi/2. ;; Turtles are the heads of vacancy chains. Eventually, turtles move. ;; First, they look for a patch among the closest neighbors (4- or 8- or 24-neighborhood). In a second turn, they will look among the second-tier neighbors (24-neighborhood). ;; Each time the procedure "form-chains" is called, the chain lenght is increased by one unit. set cl (cl + 1) ;; If the 4-neighborhood has been chosen. if (neighborhood = 4) [ ;; Look north. ifelse (any? turtles-on patch-at 0 1 = false and ([elevation] of patch-at 0 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor + 1 form-chains ][ ;; Look east. ifelse (any? turtles-on patch-at 1 0 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 1 form-chains ][ ;; Look south. ifelse (any? turtles-on patch-at 0 -1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor - 1 form-chains ][ ;; Look west. ifelse (any? turtles-on patch-at -1 0 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 = [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor - 1 form-chains ][ if (verbose?) [ type "Vacancy " type who type " produced a chain of length " print cl ] ] ] ] ] ] ;; If the 8-neighborhood has been chosen. if (neighborhood = 8) [ ;; Look north. ifelse (any? turtles-on patch-at 0 1 = false and ([elevation] of patch-at 0 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor + 1 form-chains ][ ;; Look north-east. ifelse (any? turtles-on patch-at 1 1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor + 1) form-chains ][ ;; Look east. ifelse (any? turtles-on patch-at 1 0 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 1 form-chains ][ ;; Look south-east. ifelse (any? turtles-on patch-at 1 -1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor - 1) form-chains ][ ;; Look south. ifelse (any? turtles-on patch-at 0 -1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor - 1 form-chains ][ ;; Look south-west. ifelse (any? turtles-on patch-at -1 -1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor - 1) form-chains ][ ;; Look west. ifelse (any? turtles-on patch-at -1 0 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor - 1 form-chains ][ ;; Look north-west. ifelse (any? turtles-on patch-at -1 1 = false and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 = [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor + 1) form-chains ][ if (verbose?) [ type "Vacancy " type who type " produced a chain of length " print cl ] ] ] ] ] ] ] ] ] ] ;; If the 24-neighborhood has been chosen. if (neighborhood = 24) [ ;; Look north. ;; North, first tier. set x-target xcor set y-target ycor + 1 check-reachability ifelse (any? (turtles-on patch-at 0 1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 1 form-chains ][ ;; North, second tier. set x-target xcor set y-target ycor + 2 check-reachability ifelse (any? (turtles-on patch-at 0 2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 2 form-chains ][ ;; Look north-northeast (only the second tier). set x-target xcor + 1 set y-target ycor + 2 check-reachability ifelse (any? (turtles-on patch-at 1 2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 = [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor + 2) form-chains ][ ;; Look north-east. ;; North-East, first tier. set x-target xcor + 1 set y-target ycor + 1 check-reachability ifelse (any? (turtles-on patch-at 1 1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor + 1) form-chains ][ ;; North-East, second tier. set x-target xcor + 2 set y-target ycor + 2 check-reachability ifelse (any? (turtles-on patch-at 2 2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 = [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 2) (ycor + 2) form-chains ][ ;; Look east-northeast (only the second tier). set x-target xcor + 2 set y-target ycor + 1 check-reachability ifelse (any? (turtles-on patch-at 2 1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 2) (ycor + 1) form-chains ][ ;; Look east. ;; East, first tier. set x-target xcor + 1 set y-target ycor check-reachability ifelse (any? (turtles-on patch-at 1 0) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 1 form-chains ][ ;; East, second tier. set x-target xcor + 2 set y-target ycor check-reachability ifelse (any? (turtles-on patch-at 2 0) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor + 2 form-chains ][ ;; Look east-southeast (only the second tier). set x-target xcor + 2 set y-target ycor - 1 check-reachability ifelse (any? (turtles-on patch-at 2 -1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 2) (ycor - 1) form-chains ][ ;; Look southeast. ;; South-East, first tier. set x-target xcor + 1 set y-target ycor - 1 check-reachability ifelse (any? (turtles-on patch-at 1 -1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor - 1) form-chains ][ ;; South-East, second tier. set x-target xcor + 2 set y-target ycor - 2 check-reachability ifelse (any? (turtles-on patch-at 2 -2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 = [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 2) (ycor - 2) form-chains ][ ;; Look south-southeast (only the second tier). set x-target xcor + 1 set y-target ycor - 2 check-reachability ifelse (any? (turtles-on patch-at 1 -2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 = [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor + 1) (ycor - 2) form-chains ][ ;; Look south. ;; South, first tier. set x-target xcor set y-target ycor - 1 check-reachability ifelse (any? (turtles-on patch-at 0 -1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor - 1 form-chains ][ ;; South, second tier. set x-target xcor set y-target ycor - 2 check-reachability ifelse (any? (turtles-on patch-at 0 -2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set ycor ycor - 2 form-chains ][ ;; Look south-southwest (only the second tier). set x-target xcor - 1 set y-target ycor - 2 check-reachability ifelse (any? (turtles-on patch-at -1 -2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 = [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor - 2) form-chains ][ ;; Look south-west. ;; South-West, first tier. set x-target xcor - 1 set y-target ycor - 1 check-reachability ifelse (any? (turtles-on patch-at -1 -1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor - 1) form-chains ][ ;; South-West, second tier. set x-target xcor - 2 set y-target ycor - 2 check-reachability ifelse (any? (turtles-on patch-at -2 -2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 = [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 2) (ycor - 2) form-chains ][ ;; Look west-southwest (only the second tier). set x-target xcor - 2 set y-target ycor - 1 check-reachability ifelse (any? (turtles-on patch-at -2 -1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 2) (ycor - 1) form-chains ][ ;; Look west. ;; West, first tier. set x-target xcor - 1 set y-target ycor check-reachability ifelse (any? (turtles-on patch-at -1 0) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor - 1 form-chains ][ ;; West, second tier. set x-target xcor - 2 set y-target ycor check-reachability ifelse (any? (turtles-on patch-at -2 0) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 = [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] set xcor xcor - 2 form-chains ][ ;; Look west-northwest (only the second tier). set x-target xcor - 2 set y-target ycor + 1 check-reachability ifelse (any? (turtles-on patch-at -2 1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 2) (ycor + 1) form-chains ][ ;; Look northwest. ;; North-West, first tier. set x-target xcor - 1 set y-target ycor + 1 check-reachability ifelse (any? (turtles-on patch-at -1 1) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 = [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor + 1) form-chains ][ ;; North-West, second tier. set x-target xcor - 2 set y-target ycor + 2 check-reachability ifelse (any? (turtles-on patch-at -2 2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 = [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 != [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 2) (ycor + 2) form-chains ][ ;; Look north-northwest (only the second tier). set x-target xcor - 1 set y-target ycor + 2 check-reachability ifelse (any? (turtles-on patch-at -1 2) with [color = green] = false and reachable? and ([elevation] of patch-at 0 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at 2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at 0 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 -1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 0 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 1 != [elevation] of patch-here - 1) and ([elevation] of patch-at -2 2 != [elevation] of patch-here - 1) and ([elevation] of patch-at -1 2 = [elevation] of patch-here - 1)) [ ask patch-here [set pcolor yellow] setxy (xcor - 1) (ycor + 2) form-chains ][ if (verbose?) [ type "Vacancy " type who type " produced a chain of length " print cl ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ;; Although the turtles at the head of vacancy chains are green, showing a green patch looks nicer. ask patch-here [set pcolor green] end ;; This procedure checks that a position in the 24-neighborhood is not forbidden by a wall. to check-reachability set reachable? false foreach sort neighbors [ if ([pcolor] of ? != red and any? turtles-on ? = false) [ hatch 1 [ setxy [pxcor] of ? [pycor] of ? set color blue set hidden? true repeat 20 [ set heading random 360 if ([pcolor] of patch-ahead 1 != red and member? (patch-ahead 1) ([patches in-radius 3] of myself)) [ setxy ([pxcor] of patch-ahead 1) ([pycor] of patch-ahead 1) if (xcor = x-target and ycor = y-target) [ set reachable? true stop ] ] ] die ] ] ] end
There is only one version of this model, created almost 12 years ago by Guido Fioretti.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Vacancy Chains.png | preview | Preview for 'Vacancy Chains' | almost 12 years ago, by Guido Fioretti | Download |
This model does not have any ancestors.
This model does not have any descendants.