I am creating an urban environment that is robust from interruption for my university project.
The problem I am facing is that I am not sure how to make each turtle follow a specific network line. The black line represents the electricity cable and the blue line represent the underground water pipe. I am not sure how to create a turtle to follow the network line to be consumed by the house or the big buildings. Also, please bear in mind that I only just started learning Netlogo so any improvements in the coding itself are much appreciated.
This is the current code for the urban environment model. Also, is it even possible for a turtle to follow a specific line?
breed [ houses house ]
breed [ big-buildings big-building ]
breed [ commercial-buildings commercial-building ]
breed [ water-pumping-stations water-pumping-station ]
breed [ sewage-plant-stations sewage-plant-station ]
breed [ electricity-power-stations electricity-power-station ]
breed [ overhead-cable-stations overhead-cable-station ]
to setup
clear-all
reset-ticks
setup-landscape
setup-network
if (show-grid = true ) [
draw-grid ;for the switch to hide or show the gride
]
if (show-eletricity = true) [
draw-electricity ; for the swtich to hide or show the gride
]
if (show-sewage = true) [
draw-sewage ; for the swtich to hide or show the gride
]
if (show-water = true) [
draw-water ; for the swtich to hide or show the gride
]
end
to setup-network
draw-networks ; designing lines and colour coordinate them to show what each network are.
end
to draw-networks ; list of networks that has been drawn.
draw-electricity
draw-sewage
draw-water
end
to draw-water
create-turtles 1 [ ;FOR THE HOUSE AND BIG BUILDINGS
setxy 37 -18
set heading 90
set color blue
set pen-size 2.5
pen-down
left 180
fd 10
right 90
fd 9
right 90
fd 3
right 90
fd 3
back 6
fd 3
right 90
fd 7
right 90
fd 3
back 6
fd 3
left 90
fd 7
right 90
fd 3
back 6
fd 3
left 90
fd 3
right 90
fd 19
right 90
fd 3
right 90
fd 4
back 9
fd 5
left 90
fd 4
right 90
fd 8
back 8
left 90
fd 3
right 90
fd 4
back 9
fd 5
left 90
fd 4
right 90
fd 8
back 8
left 90
fd 3
right 90
fd 4
back 9
die
]
create-turtles 1 [ ;FOR THE COMMERICAL BUILDING
setxy -37 -18
set heading 90
set color blue
set pen-size 2.5
pen-down
left 90
fd 14
right 90
fd 12
right 90
fd 3
back 6
fd 3
left 90
fd 10
left 90
fd 3
back 6
fd 3
right 90
fd 10
right 90
fd 3
back 6
fd 3
die
]
end
to draw-sewage
create-turtles 1 [ ;FOR HOUSE AND BIG BUILDINGS
setxy 38 -1
set heading 90
set color green
set pen-size 2.5
pen-down
right 90
fd 8
right 90
fd 8
right 90
fd 3
back 6
fd 3
left 90
fd 7
right 90
fd 3
back 6
fd 3
left 90
fd 7
right 90
fd 3
back 6
fd 3
left 90
fd 3
right 90
fd 19
right 90
fd 3
right 90
fd 4
back 9
fd 5
left 90
fd 4
right 90
fd 8
back 8
left 90
fd 3
right 90
fd 4
back 9
fd 5
left 90
fd 4
right 90
fd 8
back 8
left 90
fd 3
right 90
fd 4
back 9
die
]
create-turtles 1 [ ;FOR COMMERICAL BUILDING
setxy -18 -18
set heading 90
set color green
set pen-size 2.5
pen-down
right 180
back 7
right 90
fd 7
right 90
fd 9
left 90
fd 7
left 90
fd 3
right 90
fd 3
back 6
fd 3
left 90
fd 10
right 90
fd 3
back 6
fd 3
left 90
fd 10
right 90
fd 3
back 6
fd 3
die
]
end
to draw-electricity
;HOUSE
create-turtles 1 [ ;house 1
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
fd 54
right 90
fd 3
die
]
create-turtles 1 [ ;house 2
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 61
right 90
fd 3
die
]
create-turtles 1 [ ; house 3
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 68
right 90
fd 3
die
]
create-turtles 1 [ ; house 4
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 2
left -90
back 4
die
]
create-turtles 1 [ ; house 5
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 9
left -90
back 4
die
]
create-turtles 1 [ ; house 6
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 16
left -90
back 4
die
]
create-turtles 1 [ ; house 7
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 18
left 90
back 5
right 90
back 2
die
]
create-turtles 1 [ ; house 8
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 18
left 90
back 12
right 90
back 2
die
]
; BIG BUILDINGS ROW
create-turtles 1 [ ; building 1
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 3
right 90
back 3
die
]
create-turtles 1 [ ; building 2
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 10
right 90
back 3
die
]
create-turtles 1 [ ; building 3
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 17
right 90
back 3
die
]
create-turtles 1 [ ; building 4
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 3
right 90
fd 3
die
]
create-turtles 1 [ ; building 5
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 10
right 90
fd 3
die
]
create-turtles 1 [ ; building 6
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
forward 70
right 90
fd 8
right 90
fd 19
left -90
back 19
right 90
fd 17
right 90
fd 3
die
]
;COMMERICAL BUILDINGS
create-turtles 1 [ ;COMMERICAL BUILDINGS 1
setxy -38 18
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
fd 22
left 90
fd 33
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 2
setxy -25 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
fd 2
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 3
setxy -25 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
back 3
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 4
setxy -15 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
fd 2
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 5
setxy -15 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
back 3
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 6
setxy -5 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
fd 2
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 7
setxy -5 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
back 3
die
]
create-turtles 1 [ ;COMMERICAL BUILDINGS 8
setxy -25 -4
set heading 90
set color black
set pen-size 2.5
pen-down
right 90
fd 2
die
]
end
to setup-landscape
ask patches [
set pcolor pink
]
draw-entities
end
to draw-entities
draw-houses
draw-big-buildings
draw-water-pumping-stations
draw-sewage-plant-stations
draw-electricity-power-stations
draw-commercial-buildings
end
to draw-houses ; setting house as stationary not going to move at all
ask patch 30 15 [ sprout-houses 1 ]
ask patch 23 15 [ sprout-houses 1 ]
ask patch 16 15 [ sprout-houses 1 ]
ask patch 30 6 [ sprout-houses 1 ]
ask patch 23 6 [ sprout-houses 1 ]
ask patch 16 6 [ sprout-houses 1 ]
ask patch 20 2 [ sprout-houses 1 ]
ask patch 27 2 [ sprout-houses 1 ]
ask houses [
set size 1.5
set shape "house"
set color red
]
end
to draw-big-buildings ; setting big buildings as stationary not going to move at all
ask patch 30 -6 [ sprout-big-buildings 2 ]
ask patch 23 -6 [ sprout-big-buildings 2 ]
ask patch 16 -6 [ sprout-big-buildings 2 ]
ask patch 30 -12 [ sprout-big-buildings 3 ]
ask patch 23 -12 [ sprout-big-buildings 3 ]
ask patch 16 -12 [ sprout-big-buildings 3 ]
ask big-buildings [
set size 2
set shape "bigbuildings"
set color white
]
end
to draw-water-pumping-stations ; setting water pumping statoins as stationary not going to move at all
ask patch 37 -18 [ sprout-water-pumping-stations 3 ]
ask patch -37 -18 [ sprout-water-pumping-stations 3 ] ;FOR THE COMMERICAL BUILDINGS
ask water-pumping-stations [
set size 2
set shape "producewater"
set color blue
]
end
to draw-sewage-plant-stations ; setting sewage plant station as stationary not going to move at all
ask patch 38 -1 [ sprout-sewage-plant-stations 4 ]
ask patch -18 -18 [sprout-sewage-plant-stations 4] ;FOR THE COMMERICAL BUILDING
ask sewage-plant-stations [
set size 2
set shape "sewage"
set color green
]
end
to draw-electricity-power-stations ; setting eletricity power station as stationary not going to move at all
ask patch -38 18 [ sprout-electricity-power-stations 5]
ask electricity-power-stations [
set size 2
set shape "electrcitystation"
set color 44
]
end
to draw-commercial-buildings ; setting commerical buildings as stationary not going to move at all
ask patch -5 -1 [ sprout-commercial-buildings 7 ]
ask patch -5 -6 [ sprout-commercial-buildings 7 ]
ask patch -15 -6 [ sprout-commercial-buildings 7 ]
ask patch -15 -1 [ sprout-commercial-buildings 7 ]
ask patch -25 -1 [ sprout-commercial-buildings 7 ]
ask patch -25 -6 [ sprout-commercial-buildings 7 ]
ask commercial-buildings [
set size 2
set shape "commercialbuilding"
set color orange
]
end
to draw-grid ; allows me to pinpoint where each turtle is properly ( helps me to debug the code)
ask patches [
sprout 1 [
set heading 0
set color black
set pen-size 1
forward 3
right 90
pen-down
repeat 8 [
forward 3 right 90 fd 3
]
die
]
]
end
to go
end
This is the image of what my model currently looks like and NetLogo whole image is what I imagine how my model will work as I haven't started doing the go procedure.
The model can be found in the following GitHub repo: