Reputation: 21
I'm having some trouble with my netlogo model and I was hoping someone might be able to help me get through it.
I have a world with patch with specific attributes that represents parks, buildings, streets (2 types small and large), etc. I want my turtles to move towards a specific point (I managed to do that). But I'd like the turtles to move only on patches representing the streets, the have attributes specific to them, the color blue and a value 3 or 4. Is thee a way to do that ?
Here is how I set up my world :
extensions
[
gis
]
globals
[
Batiments
ChemindeFer
Cimetiere
Densite
Eau
Ponts
Routes
TerrainSports
Vegetations
]
patches-own
[
Cheminferroviaire
Bati
pont
TerraindeSport
Vege
cimetary
water
road
densitepop
Npatchvert
]
breed [ Renards renard]
breed [ Proies proie]
Renards-own
[
stress
poids
]
Proies-own
[
weight
]
to setup
ca
initialiserGIS
creerRenard
creerProie
move
reset-ticks
end
to initialiserGIS
; ---------------------- chargement densité ----------------------------
set Densite gis:load-dataset "desite_ind_g.asc"
gis:apply-raster Densite densitepop
let min-Densite gis:minimum-of Densite
let max-Densite gis:maximum-of Densite
ask patches
[
ifelse densitepop >= 1.5
[ set pcolor scale-color grey densitepop 1.5 6]
[ set pcolor white ]
]
;------------------- chargement des chemin de fer ----------------
set ChemindeFer gis:load-dataset "chdefer_g.asc"
gis:apply-raster ChemindeFer Cheminferroviaire
ask patches with [Cheminferroviaire = 1]
[set pcolor grey]
;--------------------- chargement batiments --------------------
set Batiments gis:load-dataset "batiment_g.asc"
gis:apply-raster Batiments Bati
ask patches with [Bati = 1]
[set pcolor brown]
;--------------------- chargement des ponts --------------------
set Ponts gis:load-dataset "ponts_g.asc"
gis:apply-raster Ponts pont
ask patches with [ pont = 1]
[set pcolor 87]
;--------------------- chargement de l'eau ----------------------
set Eau gis:load-dataset "eau_g.asc"
gis:apply-raster Eau water
ask patches with [ water = 1]
[set pcolor blue]
;--------------------- sports field -----------------
set TerrainSports gis:load-dataset "terrain_sport_g.asc"
gis:apply-raster TerrainSports TerraindeSport
ask patches with [ TerraindeSport = 1]
[set pcolor green]
;--------------------- végétation --------------------
set Vegetations gis:load-dataset "vegetation_g.asc"
gis:apply-raster Vegetations Vege
ask patches with [ vege = 1 ]
[set pcolor green]
;--------------------- cimetary --------------------
set Cimetiere gis:load-dataset "cimetiere_g.asc"
gis:apply-raster Cimetiere cimetary
ask patches with [ cimetary = 1 ]
[set pcolor green]
;---------------------- roads ---------------------------
set Routes gis:load-dataset "routes_g.asc"
gis:apply-raster Routes road
ask patches with
[ road = 4] [set pcolor 87]
ask patches with
[ road = 3] [set pcolor 104]
ask patches with
[ road = 0] [set pcolor green]
end
to creerRenard
create-Renards 10
end
to move
; --- 1st mouvement (towards campus) ---
ask renards
[ set heading towardsxy 10 101
fd 1 ]
end
Upvotes: 0
Views: 454
Reputation: 30453
To prevent a turtle from stepping onto anything but a blue patch, you can do:
ifelse [pcolor = blue] of patch-ahead 1
[ fd 1 ]
[ ...do something else here... ]
but you'll need to decide what the "do something else" part is. What do you want to happen in that case...?
Upvotes: 0