I'm using netlogo for a school project. This is the first time that I'm using netlogo and I'm running into some problems.
For example I want to calculate a patch "willingness to change" based on is they are with enough fellow patches according to a senario. I now wrote this:
Ask patches [
if count patches with [pcolor = 64] > Senario1 [ set willingtochangeN True ]
if count patches with [pcolor = 14] > Senario2 [ set willingtochangeL True ]
if count patches with [pcolor = 45] > Senario3 [ set willingtochangeA True ]
if count patches with [pcolor = 35] > Senario4 [ set willingtochangeB True ]
if count patches with [pcolor = 135] > Senario5 [ set willingtochangeI True ]
But i would like to do it according to an iteration, So that I can put Willingness to change to [patches own] And than do something like:
list [
(land-use 1) (land-use 2) (land-use 3)]
foreach
ask [
if count patches > senarioX set willingnesstochange true ]
But then for senario it has to take senario1 for land-use 1 and senario2 for land-use 2 etc.
This is my code until now:
extensions [ gis ]
Patches-own
[ Land-use ;; Wat kind og landusetype a patch has
Willingstochange ;; If true a patch would like to change
atractivenesstochangein ;; if a patch type is attractive to change in <1 = yess
]
globals
[
Senario1N ;; the count of patches senario 1 describes
Senario1L
Senario1A
Senario1B
Senario1I
land-use-map ;; The land use map
]
to setup ;; The setup is divided into four procedures
clear-all
setup-constants
setup-patches
update-display
load-gis
reset-ticks
end
to load-gis ;;load the maps
clear-all
set land-use-map gis:load-dataset "a_LANDUSE_cellsize5.asc" ;;loads the land use map
gis:set-world-envelope-ds gis:envelope-of land-use-map ;;sets the envelope of the world to match that of the GIS dataset
end
to setup-constants
set Senario1N 2350 ;; the count of patches senario 1 describes
set Senario1L 847
set Senario1A 27330
set Senario1B 1625
set Senario1I 264
end
to setup-patches
gis:apply-raster land-use-map land-use ;;patches in the land-use-map have a specific land-use now
list of patches [ (land-use 1) (land-use 2) (land-use 3) (land-use 4) (land-use 6) ]
foreach
[ count patches > senarioN set WillingtoChange True
]
set atractivenesstochangein foreach
[ count patches / senarioN
]
end
to update-display
ask patches
[
if land-use = 1 [ set pcolor Green ] ; Green = Nature ;; patches have a certain color now
if land-use = 2 [ set pcolor red ] ; Dark red = Leisure
if land-use = 3 [ set pcolor yellow ] ; Yellow = Agriculture
if land-use = 4 [ set pcolor brown ] ; brouwn = Buildup
if land-use = 5 [ set pcolor grey ] ; grey = roads
if land-use = 6 [ set pcolor pink ] ; pink = industry
if land-use = 7 [ set pcolor blue ] ; Blue = water
]
end