From f65708f28ee1aceaf86065abb28e4bcc6bd0944d Mon Sep 17 00:00:00 2001 From: EEva Date: Wed, 17 Jul 2013 17:17:09 +0200 Subject: [PATCH] Adding yearly seasons --- Source/helper-functions.nls | 24 ++++++++++++++++-------- Source/main.nlogo | 26 +++++++++++++++++++++++--- Source/vmodel-strategies.nls | 2 +- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Source/helper-functions.nls b/Source/helper-functions.nls index f6f5b36..ee3c09b 100644 --- a/Source/helper-functions.nls +++ b/Source/helper-functions.nls @@ -26,29 +26,37 @@ to-report honey-quant [ ha hi ] end to-report harv-index [ hi ] - if hi = "AC" and acacia-season [ report 0.0000135 ] ; Acacia - if hi = "LM" and lime-season [ report 0.000018 ] ; Lime - if hi = "SF" and sunflower-season [ report 0.000006 ] ; Sunflower - - report 0.000004 ; Polyflower + ifelse flower-season + [ if hi = "AC" and acacia-season [ report 0.0000135 ] ; Acacia + if hi = "LM" and lime-season [ report 0.000018 ] ; Lime + if hi = "SF" and sunflower-season [ report 0.000006 ] ; Sunflower + report 0.000004 ; Polyflower + ] + [ report 0.0 ] ; the following shouldn't happen error 1 end to-report acacia-season - if ticks > 30 + abegin-uncertainty and ticks < 61 + aend-uncertainty + if yearly-ticks > 119 + abegin-uncertainty and yearly-ticks < 150 + aend-uncertainty [ report true ] report false end to-report lime-season - if ticks > 61 + lbegin-uncertainty and ticks < 91 + lend-uncertainty + if yearly-ticks > 150 + lbegin-uncertainty and yearly-ticks < 180 + lend-uncertainty [ report true ] report false end to-report sunflower-season - if ticks > 91 + sbegin-uncertainty and ticks < 122 + send-uncertainty + if yearly-ticks > 180 + sbegin-uncertainty and yearly-ticks < 211 + send-uncertainty + [ report true ] + report false +end + +to-report flower-season + if yearly-ticks > 89 and yearly-ticks < 241 [ report true ] report false end diff --git a/Source/main.nlogo b/Source/main.nlogo index 41d609c..6f03486 100644 --- a/Source/main.nlogo +++ b/Source/main.nlogo @@ -3,6 +3,7 @@ extensions [ gis ] globals [ romanian-county-borders-dataset county-names + yearly-ticks abegin-uncertainty aend-uncertainty sbegin-uncertainty @@ -40,13 +41,17 @@ to go ; move to a better spot (with different strategies) ask beekeepers - [ move-to with-strategy-maximize-profit ] + [ let s with-strategy-maximize-profit + if any? spots with [s = self] + [ move-to s]] ; collect honey and make money - if ticks > 153 [ stop ] tick + set yearly-ticks ticks mod 365 + if yearly-ticks = 0 [ setup-seasons-uncertainty ] + end @#$#@#$#@ GRAPHICS-WINDOW @@ -217,7 +222,7 @@ PENS "Accacia" 1.0 0 -2674135 true "" "plot count beekeepers-on spots with [ flower-type = \"AC\" and acacia-season ]" "Sunflower" 1.0 0 -1184463 true "" "plot count beekeepers-on spots with [ flower-type = \"SF\" and sunflower-season ]" "Lime" 1.0 0 -13840069 true "" "plot count beekeepers-on spots with [ flower-type = \"LM\" and lime-season ]" -"Polyflower" 1.0 0 -8630108 true "" "plot count beekeepers-on spots with [ flower-type = \"PF\" ]" +"Polyflower" 1.0 0 -8630108 true "" "plot count beekeepers-on spots with [ flower-type = \"PF\" and flower-season]" PLOT 364 @@ -255,6 +260,21 @@ season-uncertainty NIL VERTICAL +SLIDER +215 +50 +253 +246 +d-max +d-max +0 +30 +30 +1 +1 +NIL +VERTICAL + @#$#@#$#@ ## WHAT IS IT? diff --git a/Source/vmodel-strategies.nls b/Source/vmodel-strategies.nls index 587a2df..b51761b 100644 --- a/Source/vmodel-strategies.nls +++ b/Source/vmodel-strategies.nls @@ -1,4 +1,4 @@ to-report with-strategy-maximize-profit ;; to explode. beekeeper do not know in advance - report max-one-of spots with [ not any? beekeepers-on self] [ beekeep-utility 5 flower-type (distance myself) ] + report max-one-of spots in-radius d-max with [ not any? beekeepers-on self] [ beekeep-utility 5 flower-type (distance myself) ] end \ No newline at end of file