I am trying to create a patch that will be a bottleneck structure in the middle of a path where the turtles have to go through.
I have created the parabolas but I would like to add a slider so that the size of the bottleneck can be changed but I don't know how to create a code that will move it.
Here is the code (I am very bad with the maths of the parabola so I had help with the top one and I just manually created the down one)
to setup-road
;; patch procedure
;; colour patches to paint a horizontal road
let bound (max-pycor / 3)
ifelse (pycor < (max-pycor - bound)) and (pycor > (min-pycor + bound))
[ set pcolor red - 3 ]
[ set pcolor green ]
set upper-road-bound (max-pycor - bound - 2 )
set lower-road-bound (min-pycor + bound + 2 )
setup-top-parabola-on-road
setup-down-parabola-on-road
end
;; I want to be able to expand the parabolas so that the opening between them will be wider as well as narrow according a slider.
to setup-top-parabola-on-road
ask patches with
[pxcor > -25 and pxcor < 25] [
if pycor > ((pxcor ^ 2) / 20 + 10)
[ set pcolor green ]
]
end
to setup-down-parabola-on-road
ask patches with [pxcor >= -4 and pxcor <= 4 and pycor = -11][set pcolor green]
ask patches with [pxcor >= -5 and pxcor <= 5 and pycor = -12][set pcolor green]
ask patches with [pxcor >= -6 and pxcor <= 6 and pycor = -13][set pcolor green]
ask patches with [pxcor >= -7 and pxcor <= 7 and pycor = -14][set pcolor green]
ask patches with [pxcor >= -8 and pxcor <= 8 and pycor = -15][set pcolor green]
ask patches with [pxcor >= -9 and pxcor <= 9 and pycor = -16][set pcolor green]
ask patches with [pxcor >= -10 and pxcor <= 10 and pycor = -17][set pcolor green]
ask patches with [pxcor >= -11 and pxcor <= 11 and pycor = -18][set pcolor green]
ask patches with [pxcor >= -12 and pxcor <= 12 and pycor = -19][set pcolor green]
ask patches with [pxcor >= -13 and pxcor <= 13 and pycor = -20][set pcolor green]
ask patches with [pxcor >= -14 and pxcor <= 14 and pycor = -21][set pcolor green]
ask patches with [pxcor >= -15 and pxcor <= 15 and pycor = -22][set pcolor green]
ask patches with [pxcor >= -16 and pxcor <= 16 and pycor = -23][set pcolor green]
ask patches with [pxcor >= -17 and pxcor <= 17 and pycor = -24][set pcolor green]
ask patches with [pxcor >= -18 and pxcor <= 18 and pycor = -25][set pcolor green]
end
Can anyone help?
Here you go.
This assumes you have a button called setup
and a slider for variable "width" that ranges from 0 to 11.
I added an "ask patches [ ]" in near the top where you are setting red and green.
to setup
clear-all
setup-road
reset-ticks
end
to setup-road
;; patch procedure
;; colour patches to paint a horizontal road
let bound (max-pycor / 3)
ask patches [
ifelse (pycor < (max-pycor - bound)) and (pycor > (min-pycor + bound))
[ set pcolor red - 3 ]
[ set pcolor green ]
]
let upper-road-bound (max-pycor - bound - 2 )
let lower-road-bound (min-pycor + bound + 2 )
setup-top-parabola-on-road
setup-down-parabola-on-road
end
;; I want to be able to expand the parabolas so that the opening between them will be wider as well as narrow according a slider.
to setup-top-parabola-on-road
ask patches with
[pxcor > -25 and pxcor < 25] [
if pycor > ((pxcor ^ 2) / 20 + width)
[ set pcolor blue ]
]
end
to setup-down-parabola-on-road
ask patches with
[pxcor > -25 and pxcor < 25] [
if pycor < (-1 * (pxcor ^ 2) / 20) - width + 1
[ set pcolor yellow ]
]
end
I am modelling an evacuation behaviour from one floor I wrote my code and there isn't any error from Netlogo, but I didn't know why my model doesn't work.
to go
ask turtles with [pcolor = yellow] [walk]
tick
end
to walk
;room1
ask turtles with [pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50]
[ face one-of patches with [pxcor <= 58.57 and pxcor >= 49.42 and pycor = 50]]
;room2
ask turtles with [pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50]
[ face one-of patches with [pxcor <= 108.57 and pxcor >= 99.42 and pycor = 50]]
;room3
ask turtles with [pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0]
[face one-of patches with [pxcor <= 79.575 and pxcor >= 70.425 and pycor = 36]]
;room4
ask turtles with [pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0]
[face one-of patches with [pxcor <= 93.575 and pxcor >= 84.425 and pycor = 36]]
fd 0.5
;corridor
ask turtles with [pxcor < 132 and pycor < 50 and pxcor > 0 and pycor > 36]
[face one-of patches with [pxcor <= 132 and pxcor >= 112 and pycor = 50]]
;exit
ask turtles with [pxcor < 132 and pycor < 79 and pxcor >= 112 and pycor >= 50]
[face one-of patches with [pxcor <= 129.57 and pxcor >= 120.42 and pycor = 79]]
fd 1
end
Your question is not particularly clear because 'doesn't work' doesn't provide enough information about the problem. To get a more useful answer, you should describe the behaviour you expect and the behaviour you actually get. Having said that, however, there's an obvious problem with your code that is probably what you are asking about.
In your go statement, you have the turtles call the walk procedure. In your walk procedure, you have the face command inside the ask turtles brackets, but the fd command outside the brackets. I am assuming that is intentional and that what you are trying to do is have the four if statements make the turtle face the direction you want and then the fd move it.
However, within the walk procedure you are repeating the ask turtles. What you probably want to do is only change the heading of one turtle (the one that is being asked to walk).
to go
ask turtles with [pcolor = yellow] [walk]
tick
end
to walk
;room1
if pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50
[ face one-of patches with [pxcor <= 58.57 and pxcor >= 49.42 and pycor = 50]
]
;room2
if pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50
[ face one-of patches with [pxcor <= 108.57 and pxcor >= 99.42 and pycor = 50]
]
;room3
if pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0
[ face one-of patches with [pxcor <= 79.575 and pxcor >= 70.425 and pycor = 36]
]
;room4
if pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0
[ face one-of patches with [pxcor <= 93.575 and pxcor >= 84.425 and pycor = 36]
]
fd 0.5
;corridor
if pxcor < 132 and pycor < 50 and pxcor > 0 and pycor > 36
[ face one-of patches with [pxcor <= 132 and pxcor >= 112 and pycor = 50]
]
;exit
if pxcor < 132 and pycor < 79 and pxcor >= 112 and pycor >= 50
[face one-of patches with [pxcor <= 129.57 and pxcor >= 120.42 and pycor = 79]
]
fd 1
end
There's some other issues in this code. The first is that you appear to be mixing up xcor and pxcor (and similarly for y coordinates). xcor is the turtle coordinate and pxcor is the patch coordinate. A turtle does have access to the patch's variables, including coordinates, so the code won't generate an error. But I am concerned by statements like face one-of patches with [pxcor <= 108.57 and pxcor >= 99.42 and pycor = 50]. This is equivalent to face one-of patches with [pxcor <= 108 and pxcor >= 100 and pycor = 50] because pxcor and pycor are integers. The fact that you have decimals in this is what makes me think you are confused about coordinates.
The second is that all turtles who are asked to walk are going to move forward by 1.5 but I think you want some to move 0.5 and others to move 1. Once the turtle has entered the walk procedure, the if statements (or the with in your version) only change the heading. The fd statements apply to all turtles.
Third, I'd be tempted to use patch-sets to simplify the readability of this code. Something like:
to go
ask turtles with [pcolor = yellow] [walk]
tick
end
to walk
let room1 patches with [pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50]
let room2 patches with [pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50]
let room3 patches with [pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0]
let room4 patches with [pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0]
let corridor patches with [pxcor < 132 and pycor < 50 and pxcor > 0 and pycor > 36]
let exitpoint patches with [pxcor < 132 and pycor < 79 and pxcor >= 112 and pycor >= 50]
ask turtles-on room1
[ face one-of patches with [pxcor <= 58 and pxcor >= 50 and pycor = 50
fd 0.5
]
ask turtles-on room2
[ face one-of patches with [pxcor <= 108 and pxcor >= 100 and pycor = 50
fd 0.5
]
ask turtles-on room3
[ face one-of patches with [pxcor <= 79 and pxcor >= 71 and pycor = 36
fd 0.5
]
ask turtles-on room4
[ face one-of patches with [pxcor <= 93 and pxcor >= 85 and pycor = 36
fd 0.5
]
ask turtles on corridor
[ face one-of patches with [pxcor <= 132 and pxcor >= 112 and pycor = 50]
fd 1
]
ask turtles-on exitpoint
[ face one-of patches with [pxcor <= 129 and pxcor >= 121 and pycor = 79]
fd 1
]
end
Note that this is not the same as yours because I don't know what patches are yellow. You would have to modify to deal with this issue.
The reason I moved the ask turtles inside the procedure was so the patch-sets are only created once. If you are going to use these rooms etc in other places, it would be worth having them as global variables and putting the construction into your setup.
I am modelling an evacuation model from a simple plan with 4 rooms and one corridor. I have a problem for navigate agents from rooms to corridor and from corridor to main exit. would you please guide me.
The codes that I wrote are there:
globals [
wall
window
door
goal-x goal-y
n
]
patches-own [path?]
turtles-own [direction
fast?
other-nearby]
to setup
clear-all
setup-patches
set-default-shape turtles "person" ;makes them look like people
ask n-of number-room1 patches with [pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50 and pcolor = black] ; makes turtles sprout on black patches = room1
[
sprout 1 [
set size 5 ;; setting turtle size
facexy 124 79 ; initial direction faceing
set direction 1
set color yellow ;initial color
]
]
ask n-of number-room2 patches with [pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50 and pcolor = black] ; makes turtles sprout on black patches= room2
[
sprout 1 [
set size 5 ;; setting turtle size
facexy 124 79 ; initial direction faceing
set direction 1
set color yellow ;initial color
]
]
ask n-of number-room3 patches with [pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0 and pcolor = black] ; makes turtles sprout on black patches= room3
[
sprout 1 [
set size 5 ;; setting turtle size
facexy 124 79 ; initial direction faceing
set direction 1
set color yellow ;initial color
]
]
ask n-of number-room4 patches with [pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0 and pcolor = black] ; makes turtles sprout on black patches= room4
[
sprout 1 [
set size 5 ;; setting turtle size
facexy 124 79 ; initial direction faceing
set direction 1
set color yellow ;initial color
]
]
reset-ticks
end
to setup-patches
draw-wall;wall, Windows and Doors
draw-exit
;Labels
ask patch 35 54[
set plabel-color white
set plabel "Room1"
]
ask patch 90 54[
set plabel-color white
set plabel "Room2"
]
ask patch 77 44[
set plabel-color white
set plabel "Corridor"
]
ask patch 41 13[
set plabel-color white
set plabel "Room3"
]
ask patch 105 13[
set plabel-color white
set plabel "Room4"
]
end
to draw-wall
ask patches with [pxcor <= 120.42 and pxcor >= 0 and pycor = 79]
[set pcolor blue]
ask patches with [pxcor <= 132 and pxcor >= 129.57 and pycor = 79]
[set pcolor blue]
ask patches with [pycor <= 79 and pycor >= 0 and pxcor = 132]
[set pcolor blue]
ask patches with [pycor <= 79 and pycor >= 0 and pxcor = 0]
[set pcolor blue]
ask patches with [pxcor <= 34.43 and pxcor >= 0 and pycor = 0]
[set pcolor blue]
ask patches with [pxcor <= 132 and pxcor >= 43.58 and pycor = 0]
[set pcolor blue]
ask patches with [pxcor <= 112 and pxcor >= 108.57 and pycor = 50]
[set pcolor blue]
ask patches with [pxcor <= 49.42 and pxcor >= 0 and pycor = 50]
[set pcolor blue]
ask patches with [pxcor <= 84.425 and pxcor >= 79.575 and pycor = 36]
[set pcolor blue]
ask patches with [pxcor <= 70.425 and pxcor >= 0 and pycor = 36]
[set pcolor blue]
ask patches with [pxcor <= 132 and pxcor >= 93.575 and pycor = 36]
[set pcolor blue]
ask patches with [pycor <= 79 and pycor >= 50 and pxcor = 71]
[set pcolor blue]
ask patches with [pycor <= 79 and pycor >= 50 and pxcor = 112]
[set pcolor blue]
ask patches with [pycor <= 36 and pycor >= 0 and pxcor = 82]
[set pcolor blue]
ask patches with [pxcor <= 99.42 and pxcor >= 58.57 and pycor = 50]
[set pcolor blue]
end
to draw-exit
;room1
ask patches with [pxcor <= 58.57 and pxcor >= 49.42 and pycor = 50]
[set pcolor green]
;room2
ask patches with [pxcor <= 108.57 and pxcor >= 99.42 and pycor = 50]
[set pcolor green]
;room3
ask patches with [pxcor <= 79.575 and pxcor >= 70.425 and pycor = 36]
[set pcolor green]
;room4
ask patches with [pxcor <= 93.575 and pxcor >= 84.425 and pycor = 36]
[set pcolor green]
;main exit
ask patches with [pxcor <= 129.57 and pxcor >= 120.42 and pycor = 79]
[set pcolor red]
;second exit
ask patches with [pxcor <= 43.58 and pxcor >= 34.43 and pycor = 0]
[set pcolor red]
end
to go
ask turtles [walk]
tick
end
to walk
let room1 patches with [pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50]
let room2 patches with [pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50]
let room3 patches with [pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0]
let room4 patches with [pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0]
let corridor patches with [pxcor < 132 and pycor < 50 and pxcor > 0 and pycor > 36]
let exitpoint patches with [pxcor < 132 and pycor < 79 and pxcor > 112 and pycor > 50]
ask turtles-on room1
[face one-of patches with [pxcor <= 58.6 and pxcor >= 49.42 and pycor = 50]
fd 0.5
]
ask turtles-on room2
[ face one-of patches with [pxcor <= 108.6 and pxcor >= 99.5 and pycor = 50]
fd 0.5
]
ask turtles-on room3
[ face one-of patches with [pxcor <= 79 and pxcor >= 71 and pycor = 36]
fd 0.5
]
ask turtles-on room4
[ face one-of patches with [pxcor <= 93.6 and pxcor >= 84.5 and pycor = 36]
fd 0.5
]
ask turtles-on corridor
[ face one-of patches with [pxcor <= 132 and pxcor >= 112 and pycor = 50]
fd 1
]
ask turtles-on exitpoint
[ face one-of patches with [pxcor <= 129 and pxcor >= 121 and pycor = 79]
fd 1
]
end
I could navigate agents from rooms to door of each room but I want to enter them in the corridor then from corridor to main exit.
I just modified your code by adding a "doors" variable underneath "walk". This tells the turtles that touch a green patch - your doors - to take two steps forward into the corridor. Once they are in the corridor they already have commands to move toward the exitpoint.
to walk
let room1 patches with [pxcor < 71 and pycor < 79 and pxcor > 0 and pycor > 50]
let room2 patches with [pxcor < 112 and pycor < 79 and pxcor > 71 and pycor > 50]
let room3 patches with [pxcor < 82 and pycor < 36 and pxcor > 0 and pycor > 0]
let room4 patches with [pxcor < 132 and pycor < 36 and pxcor > 82 and pycor > 0]
let corridor patches with [pxcor < 123 and pycor < 50 and pxcor > 0 and pycor > 36]
let exitpoint patches with [pxcor < 130 and pycor < 80 and pxcor > 122 and pycor > 38]
let doors patches with [pcolor = green]
ask turtles-on room1
[face one-of patches with [pxcor <= 58.6 and pxcor >= 49.42 and pycor = 50]
fd 0.5
]
ask turtles-on room2
[ face one-of patches with [pxcor <= 108.6 and pxcor >= 99.5 and pycor = 50]
fd 0.5
]
ask turtles-on room3
[ face one-of patches with [pxcor <= 79 and pxcor >= 71 and pycor = 36]
fd 0.5
]
ask turtles-on room4
[ face one-of patches with [pxcor <= 93.6 and pxcor >= 84.5 and pycor = 36]
fd 0.5
]
ask turtles-on corridor
[ face one-of patches with [pxcor <= 130 and pxcor >= 125 and pycor = 45]
fd 1
]
ask turtles-on exitpoint
[ face one-of patches with [pxcor <= 129 and pxcor >= 121 and pycor = 79]
fd 1
]
ask turtles-on doors
[ face one-of patches with [pxcor = 77 and pycor = 44 ]
fd 2
]
Can we count number of turtles on a set of patches or on a single patch at some particular time instance (say for in a tick).
set turtle-at-setpatches count turtle-on patches with [ (pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)]
I gets the count with this code, but is this count is on the basis of ticks by default. what i need is number count on a particular tick(or instance). Thanks in advance.
Answer to question as asked:
if (ticks = 10) [
set turtle-at-setpatches
count turtles-on patches with [
(pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)
]
A possibly better answer: collect the data for every tick in a table. E.g.,
extensions [table]
globals [setpatches turtles-on-setpatches]
to setup
;compute setpatches only once
set setpatches patches with [ (pxcor >= 9 and pxcor <= 13) and (pycor <= 9 and pycor >= 2)]
crt 500
set turtles-on-setpatches table:make
reset-ticks
end
to go
ask turtles [setxy random-xcor random-ycor]
table:put turtles-on-setpatches ticks (count turtles-on setpatches)
tick
end
Hi, I'm wondering if anyone knows the exact code to not let the patches enter the gymnasium. I closed all the gates labeled as red patches and the black patches are the walls.
The problem here is that I tried these different codes yet the patches still pass through the walls. Can anyone help me?
Do take note that I tried these methods one at a time to determine if any of the ff. worked.
Much help would be appreciated to the person/people that can help me.
ask turtles[
ifelse [pcolor] of patch-left-and-ahead 1 1 = red [rt random-float 180 ]
[ let f random 5
ifelse [pcolor] of patch-right-and-ahead 1 1 = black [rt random-float 180 ]
[ let g random 5
ifelse [pcolor] of patch-at-heading-and-distance 1 1 = red [rt random-float 180 ]
[let h random 5
ifelse [pcolor] of patch-at-heading-and-distance 1 1 = black [rt random-float 180]
[let i random 5
ifelse [pcolor] of patch-ahead 1 = red [rt random-float 180 ]
[let h random 5
ifelse [pcolor] of patch-ahead 1 = black [rt random-float 180 ]
[let i random 5
ifelse [pcolor] of patch-left-and-ahead 1 1 = red [fd random-float 5]
[fd f]
ifelse [pcolor] of patch-right-and-ahead 1 1 = red [fd random-float 5]
[fd g]
ifelse [pcolor] of patch-at-heading-and-distance 1 1 = red [fd random-float 5]
[fd h]
ifelse [pcolor] of patch-at-heading-and-distance 1 1 = black [fd random-float 5]
[fd i]
ifelse [pcolor] of patch-ahead 1 = red [fd random-float 5]
[fd h]
ifelse [pcolor] of patch-ahead 1 = black [fd random-float 5]
[fd i]
]
]
]
]
]
As requested here's the code for the patch:
to setup-world
set pcolor white
;;FLOOR------------------------------------------------------------------------------
if ( pycor < 91 and pycor > 10) and ( pxcor < 91 and pxcor > 7 ) [ set pcolor 8]
if ( pycor < 90 and pycor > 11) and ( pxcor = 7 ) [ set pcolor 8]
if ( pycor < 89 and pycor > 12) and ( pxcor = 6 ) [ set pcolor 8]
if ( pycor < 88 and pycor > 13) and ( pxcor = 5 ) [ set pcolor 8]
if ( pycor < 87 and pycor > 14) and ( pxcor = 4 ) [ set pcolor 8]
if ( pycor < 86 and pycor > 15) and ( pxcor = 3 ) [ set pcolor 8]
if ( pycor < 85 and pycor > 16) and ( pxcor = 2 ) [ set pcolor 8]
if ( pycor < 84 and pycor > 17) and ( pxcor = 1 ) [ set pcolor 8]
if ( pycor < 83 and pycor > 18) and ( pxcor = 0 ) [ set pcolor 8]
if ( pycor < 82 and pycor > 19) and ( pxcor = -1 ) [ set pcolor 8]
if ( pycor < 81 and pycor > 20) and ( pxcor = -2 ) [ set pcolor 8]
if ( pycor < 80 and pycor > 21) and ( pxcor = -3 ) [ set pcolor 8]
if ( pycor < 79 and pycor > 22) and ( pxcor = -4 ) [ set pcolor 8]
if ( pycor < 78 and pycor > 23) and ( pxcor = -5 ) [ set pcolor 8]
if ( pycor < 77 and pycor > 24) and ( pxcor = -6 ) [ set pcolor 8]
if ( pycor < 76 and pycor > 25) and ( pxcor = -7 ) [ set pcolor 8]
;;basketball -----------------------------------------------------------------------
if ( pycor < 68 and pycor > 33) and ( pxcor < 85 and pxcor > 9 ) [ set pcolor 37]
;;UP --------------------------------------------------------------------------------
if ( pycor = 90 ) and ( pxcor < 85 and pxcor > 7 ) [ set pcolor brown ]
if ( pycor = 88 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 88 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 88 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 86 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 86 ) and ( pxcor < 15 and pxcor > 10 ) [ set pcolor grey ]
if ( pycor = 86 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 84 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 84 ) and ( pxcor < 15 and pxcor > 10 ) [ set pcolor grey ]
if ( pycor = 84 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 82 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 82 ) and ( pxcor < 15 and pxcor > 10 ) [ set pcolor grey ]
if ( pycor = 82 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 80 ) and ( pxcor < 36 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 80 ) and ( pxcor < 15 and pxcor > 10 ) [ set pcolor grey ]
if ( pycor = 80 ) and ( pxcor < 81 and pxcor > 60 ) [ set pcolor brown ]
if ( pycor = 80 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 78 ) and ( pxcor < 36 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 78 ) and ( pxcor < 15 and pxcor > 10 ) [ set pcolor grey ]
if ( pycor = 78 ) and ( pxcor < 81 and pxcor > 60 ) [ set pcolor brown ]
if ( pycor = 78 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
;;DOWN -------------------------------------------------------------------------
if ( pycor = 11 ) and ( pxcor < 85 and pxcor > 7 ) [ set pcolor brown ]
if ( pycor = 13 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 13 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 13 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 15 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 15 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 15 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 17 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 17 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 17 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 19 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 19 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 19 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 21 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 21 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 21 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
if ( pycor = 23 ) and ( pxcor < 82 and pxcor > 14 ) [ set pcolor brown ]
if ( pycor = 23 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 23 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]
;;CORNER DOWN RIGHT--------------------------------------------------------------------
if ( pycor = 12 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 13 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 14 and pxcor = 5) [ set pcolor brown ]
if ( pycor = 13 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 13 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 14 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 15 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 16 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 15 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 16 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 17 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 18 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 18 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 19 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 20 and pxcor = 8) [ set pcolor brown ]
;;CORNER UP RIGHT---------------------------------------------------------
if ( pycor = 87 and pxcor = 5) [ set pcolor brown ]
if ( pycor = 88 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 89 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 88 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 88 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 87 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 86 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 85 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 86 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 85 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 84 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 83 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 83 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 82 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 81 and pxcor = 8) [ set pcolor brown ]
;;CENTER CORNER DOWN----------------------------------------------------------------
if ( pycor = 29 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 28 and pxcor = 0) [ set pcolor brown ]
if ( pycor = 27 and pxcor = 1) [ set pcolor brown ]
if ( pycor = 29 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 28 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 27 and pxcor = -2) [ set pcolor brown ]
if ( pycor = 26 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 29 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 28 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 27 and pxcor = -5) [ set pcolor brown ]
if ( pycor = 26 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 25 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 26 and pxcor = -7) [ set pcolor brown ]
if ( pycor = 25 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 24 and pxcor = -5) [ set pcolor brown ]
;;CENTER CORNER UP-------------------------------------------------------
if ( pycor = 72 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 73 and pxcor = 0) [ set pcolor brown ]
if ( pycor = 74 and pxcor = 1) [ set pcolor brown ]
if ( pycor = 72 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 73 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 74 and pxcor = -2) [ set pcolor brown ]
if ( pycor = 75 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 72 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 73 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 74 and pxcor = -5) [ set pcolor brown ]
if ( pycor = 75 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 76 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 75 and pxcor = -7) [ set pcolor brown ]
if ( pycor = 76 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 77 and pxcor = -5) [ set pcolor brown ]
;;center -------------------------------------------------------------------------
if ( pxcor = -8 ) and ( pycor < 75 and pycor > 26 ) [ set pcolor brown ]
if ( pxcor = -6 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor brown ]
if ( pxcor = -6 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = -6 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = -4 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor brown ]
if ( pxcor = -4 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = -4 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = -2 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor brown ]
if ( pxcor = -2 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = -2 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = 0 ) and ( pycor < 47 and pycor > 34 ) [ set pcolor brown ]
if ( pxcor = 0 ) and ( pycor < 67 and pycor > 54 ) [ set pcolor brown ]
if ( pxcor = 0 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = 0 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = 2 ) and ( pycor < 62 and pycor > 54 ) [ set pcolor brown ]
if ( pxcor = 2 ) and ( pycor < 47 and pycor > 38 ) [ set pcolor brown ]
if ( pxcor = 2 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = 2 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = 4 ) and ( pycor < 62 and pycor > 54 ) [ set pcolor brown ]
if ( pxcor = 4 ) and ( pycor < 47 and pycor > 38 ) [ set pcolor brown ]
if ( pxcor = 4 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = 4 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
if ( pxcor = 6 ) and ( pycor < 62 and pycor > 54 ) [ set pcolor brown ]
if ( pxcor = 6 ) and ( pycor < 47 and pycor > 38 ) [ set pcolor brown ]
if ( pxcor = 6 ) and ( pycor < 35 and pycor > 29 ) [ set pcolor grey ]
if ( pxcor = 6 ) and ( pycor < 72 and pycor > 66 ) [ set pcolor grey ]
;;WaLL----------------------------------------------------------------------
if ( pycor = 10 ) and ( pxcor < 85 and pxcor > 7 ) [ set pcolor black ]
if ( pycor = 91 ) and ( pxcor < 85 and pxcor > 7 ) [ set pcolor black ]
if ( pxcor = -9 ) and ( pycor < 76 and pycor > 25 ) [ set pcolor black ]
if ( pxcor = 91 ) and ( pycor < 34 and pycor > 9 ) [ set pcolor black ]
if ( pxcor = 91 ) and ( pycor < 92 and pycor > 67 ) [ set pcolor black ]
;;stage
if ( pxcor = 98) and ( pycor < 68 and pycor > 33 ) [ set pcolor black ]
if ( pycor = 33 ) and ( pxcor < 99 and pxcor > 91 ) [ set pcolor black ]
if ( pycor = 68 ) and ( pxcor < 99 and pxcor > 91 ) [ set pcolor black ]
if ( pycor = 11 and pxcor = 7) [ set pcolor black ]
if ( pycor = 12 and pxcor = 6) [ set pcolor black ]
if ( pycor = 13 and pxcor = 5) [ set pcolor black ]
if ( pycor = 14 and pxcor = 4) [ set pcolor black ]
if ( pycor = 15 and pxcor = 3) [ set pcolor black ]
if ( pycor = 22 and pxcor = -4) [ set pcolor black ]
if ( pycor = 23 and pxcor = -5) [ set pcolor black ]
if ( pycor = 24 and pxcor = -6) [ set pcolor black ]
if ( pycor = 25 and pxcor = -7) [ set pcolor black ]
if ( pycor = 26 and pxcor = -8) [ set pcolor black ]
if ( pycor = 90 and pxcor = 7) [ set pcolor black ]
if ( pycor = 89 and pxcor = 6) [ set pcolor black ]
if ( pycor = 88 and pxcor = 5) [ set pcolor black ]
if ( pycor = 87 and pxcor = 4) [ set pcolor black ]
if ( pycor = 86 and pxcor = 3) [ set pcolor black ]
if ( pycor = 79 and pxcor = -4) [ set pcolor black ]
if ( pycor = 78 and pxcor = -5) [ set pcolor black ]
if ( pycor = 77 and pxcor = -6) [ set pcolor black ]
if ( pycor = 76 and pxcor = -7) [ set pcolor black ]
if ( pycor = 75 and pxcor = -8) [ set pcolor black ]
;;stage--------------------------------------------------------------------------------
if ( pycor < 68 and pycor > 33) and ( pxcor < 98 and pxcor > 90 ) [ set pcolor 37 ]
;;lines-------------------------------------------------------------------------------
if ( pycor = 66 ) and ( pxcor < 82 and pxcor > 11 ) [ set pcolor yellow ]
if ( pycor = 35 ) and ( pxcor < 82 and pxcor > 11 ) [ set pcolor yellow ]
if ( pxcor = 12 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]
if ( pxcor = 82 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]
if ( pxcor = 47 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]
;;gates are closed initially ----------------------------------------------------------
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower left, right door
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower right, right door
if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower left, right door
if lower-left = "Half"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower left, right door
]
if lower-left = "Close"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower left, right door
]
;;-------------------------------------------------------------------------------------
;; lower right-------------------------------------------------------------------------
if lower-right = "Open"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower right, right door
]
if lower-right = "Half"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower right, right door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower right, left door
]
if lower-right = "Close"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower right, right door
]
;;-------------------------------------------------------------------------------------
;; upper left--------------------------------------------------------------------------
if upper-left = "Open"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor green ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor green ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor green ] ; upper left , left door
]
if upper-left = "Half"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
if upper-left = "Close"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
;; ------------------------------------------------------------------------------
;; upper right-------------------------------------------------------------------
if upper-right = "Open"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor green ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor green ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor green ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , left door
]
if upper-right = "Half"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , left door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , left door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , left door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , right door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , right door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , right door
]
if upper-right = "Close"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door
]
;; ----------------------------------------------------------------------------
end
to setupgate
ask patches [
;;exits--------------------------------------------------------------------------------
;; Point of view is when the agents are outside the Gymnasium.
;; lower left--------------------------------------------------------------------------
if lower-left = "Open"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower left, right door
]
if lower-left = "Half"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower left, right door
]
if lower-left = "Close"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower left, right door
]
;;-------------------------------------------------------------------------------------
;; lower right-------------------------------------------------------------------------
if lower-right = "Open"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor green ]
; lower right, right door
]
if lower-right = "Half"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor green ]
; lower right, right door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower right, left door
]
if lower-right = "Close"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84 ) [ set pcolor red ]
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87 ) [ set pcolor red ]
; lower right, right door
]
;;-------------------------------------------------------------------------------------
;; upper left--------------------------------------------------------------------------
if upper-left = "Open"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor green ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor green ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor green ] ; upper left , left door
]
if upper-left = "Half"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
if upper-left = "Close"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
;; ------------------------------------------------------------------------------
;; upper right-------------------------------------------------------------------
if upper-right = "Open"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor green ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor green ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor green ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , left door
]
if upper-right = "Half"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , left door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , left door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , left door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , right door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , right door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , right door
]
if upper-right = "Close"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door
]
;; ----------------------------------------------------------------------------
]
end
its a nice design :)
The way you want to do it should work only in cases that you check exactly the patch which FD moves the turtle on that patch. I have noticed that you check patch-ahead 1 but you ask your turtle to fd random 5 which does not check the patch-ahead random 5 and jumps from red patches.
There might be many other way to do what you want, and most often I have seen the same approach that you used, if you want that method to work you should check the patch in correct distance not just patch ahead.
There is another way to do same thing, I am not sure how agents are choosing the door they want to move toward to but I have assigned a property called closest-door and filled it with one of patches with [Pcolor = green], then I have asked agent to check the patches with its walking-speed and see if they are white and they are in right direction the agent will move to those patches.
turtles-own
[closest-door]
to setup
....
create-turtles [
.....
set closest-door min-one-of patches with [pcolor = green][ distance myself] ; nearest door
set closest-door one-of patches with [pcolor = green] ; any open door
]
to go
ask turtles
[move-toward-gym closest-door random 5]
end
to move-toward-gym [my-door walking-speed]
if my-door!= nobody [
face my-door
let possible-moves patches with [distance myself = walking-speed and pcolor = white]
let t min-one-of possible-moves [distance my-door]
if t != nobody [move-to t ]
]
end
Update:
First, for a version control you can use Github and you will never get lost with changes in your code :)
Second, let me know what kind of errors you get,
the function move-toward-gym only works if there is a green patch available for agents.
https://www.dropbox.com/s/j8qe7omoediwysw/out.mov
Update:
I have just noticed you asked for my entire code:
turtles-own
[closest-door
]
globals
[lower-left
lower-right
upper-left
upper-right
]
to setup
clear-all
movie-cancel
movie-start "out.mov"
ask patches [setup-world]
set lower-left "Open"
set lower-right "Open"
set upper-left "Open"
set upper-right "Open"
set upper-left "Open"
create-turtles 100 [
set size 2
move-to one-of patches with [
pcolor = white
]
set closest-door min-one-of patches with [pcolor = green][ distance myself] ; nearest door
set closest-door one-of patches with [pcolor = green] ; any open door
]
reset-ticks
end
to go
if ticks < 50
[
movie-grab-view
]
ask turtles
[move-toward-gym closest-door random 5]
if ticks = 50 [movie-close]
tick
end
to move-toward-gym [my-door walking-speed]
if my-door != nobody
[
face my-door
let possible-moves patches with [distance myself = walking-speed and pcolor = white]
let t min-one-of possible-moves [distance my-door]
ifelse t != nobody [move-to t] []
if any? patches with [distance myself = walking-speed and pcolor = green]
[move-to one-of patches with [pcolor = green]
]]
end
A couple relevant code examples (in the Code Examples section of the NetLogo Models Library) are Look Ahead Example and Next Patch Example.
Look Ahead Example shows one way to keep your turtles from bumping into walls. It might also be useful as a testbed for trying out more complicated rules for turtle motion in the presence of walls.
Next Patch Example should help improve your understanding of why the math and logic of turtles moving "continuously" over a patch grid is more complicated than you might expect at first.