csss-beedza/Source/helper-functions.nls

118 lines
2.9 KiB
Text
Raw Normal View History

2013-07-17 11:33:47 +02:00
;;;;;;;;;;;;;;;;;;;;;;
;; Helper functions ;;
;;;;;;;;;;;;;;;;;;;;;;
; beekeep-utility = honey-quant * (honey-price - prod-cost) - (travel-cost * distance * vehicles) - moving-cost
2013-07-17 21:12:45 +02:00
to-report beekeep-utility [hi ah d]
report (honey-quant hi ah) * ((honey-price hi) - prod-cost) - (travel-cost * d)
2013-07-17 11:33:47 +02:00
end
to-report honey-price [ hi ]
if hi = "PF" [ report 3.48 ] ; Polyflower
if hi = "AC" [ report 4.65 ] ; Accacia
if hi = "LM" [ report 4.65 ] ; Lime
if hi = "SF" [ report 2.32 ] ; Sunflower
; the following shouldn't happen
error 1
end
to-report prod-cost
report 100 / 25000 ; 1 hive = 25000 bees
end
; honey-quant = (bees-quant - 10000) * harv-index * uncertainty
2013-07-17 21:12:45 +02:00
to-report honey-quant [ hi amount-h ]
report (bees-quant - 10000) * (harv-index hi) * amount-h * uncertainty
2013-07-17 11:33:47 +02:00
end
to-report harv-index [ hi ]
2013-07-17 17:17:09 +02:00
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 ]
2013-07-17 11:33:47 +02:00
; the following shouldn't happen
error 1
end
2013-07-17 16:10:47 +02:00
to-report acacia-season
2013-07-17 17:17:09 +02:00
if yearly-ticks > 119 + abegin-uncertainty and yearly-ticks < 150 + aend-uncertainty
2013-07-17 16:10:47 +02:00
[ report true ]
report false
end
to-report lime-season
2013-07-17 17:17:09 +02:00
if yearly-ticks > 150 + lbegin-uncertainty and yearly-ticks < 180 + lend-uncertainty
2013-07-17 16:10:47 +02:00
[ report true ]
report false
end
to-report sunflower-season
2013-07-17 17:17:09 +02:00
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
2013-07-17 16:10:47 +02:00
[ report true ]
report false
end
2013-07-17 11:33:47 +02:00
to-report uncertainty
report random-normal 1.0 harvesting-uncertainty
end
2013-07-17 21:12:45 +02:00
to-report bees-quant
ifelse ticks <= 21
[ report 2000 * ticks + 27000 ]
[ report 500 * ticks + 65000 ]
2013-07-17 11:33:47 +02:00
end
2013-07-17 16:10:47 +02:00
2013-07-17 11:33:47 +02:00
to-report color-flower [ hi ]
if hi = "PF" [ report VIOLET ] ; Polyflower
if hi = "AC" [ report RED ] ; Accacia
2013-07-17 16:10:47 +02:00
if hi = "LM" [ report LIME ] ; Lime
2013-07-17 11:33:47 +02:00
if hi = "SF" [ report YELLOW ] ; Sunflower
; the following shouldn't happen
error 1
end
2013-07-18 00:33:43 +02:00
to dailyRevenue
let N count beekeepers
2013-07-18 01:14:36 +02:00
; ifelse old-spot not empty? [
set old-spot min-one-of spots [distance myself]
2013-07-18 00:33:43 +02:00
2013-07-18 01:14:36 +02:00
let travel-distance distance old-spot
; ]
;[
; set travel-distance 0
;]
2013-07-18 00:33:43 +02:00
if any? spots-here [;flower-type [amount-of-hives] of myself (distance myself)
set sumOfallBeekeepersProfit (sumOfallBeekeepersProfit + beekeep-utility ([flower-type] of one-of spots-here) amount-of-hives travel-distance )
]
set averageProfit sumOfallBeekeepersProfit / N
end
to evaluation-procedure
dailyRevenue
2013-07-18 01:14:36 +02:00
individual-caract
2013-07-18 00:33:43 +02:00
2013-07-18 01:14:36 +02:00
end
to individual-caract
let travel-distance distance old-spot
set profit (profit + beekeep-utility ([flower-type] of one-of spots-here) amount-of-hives travel-distance )
set total-travel-distance (total-travel-distance + travel-distance )
2013-07-18 00:33:43 +02:00
end