Simulace zasněžování
globals [
temperature humidity wind-speed total-water-used total-energy-used total-cost natural-snow
]
breed [snow-cannons snow-cannon] patches-own [
snow-depth slope-angle is-skiable
]
to setup
clear-all setup-slope setup-snow-cannons setup-weather reset-ticks
end
to setup-slope
ask patches [ set snow-depth 0 set slope-angle random 50 set is-skiable false set pcolor scale-color white snow-depth 0 100 ]
end
to setup-snow-cannons
create-snow-cannons number-of-cannons [ setxy random-xcor random-ycor set shape "circle" set color blue set size 2 ]
end
to setup-weather
set temperature random-float 20 - 10 set humidity random-float 100 set wind-speed random-float 10 set natural-snow random-float 40
end
to go
update-weather make-snow natural-snowfall melt-snow update-display calculate-costs tick
end
to update-weather
set temperature temperature + random-float 2 - 1 if temperature > 10 [ set temperature 10 ] if temperature < -20 [ set temperature -20 ]
set humidity humidity + random-float 10 - 5 if humidity > 100 [ set humidity 100 ] if humidity < 0 [ set humidity 0 ]
set wind-speed wind-speed + random-float 2 - 1 if wind-speed < 0 [ set wind-speed 0 ] if wind-speed > 10 [ set wind-speed 10 ]
end
to make-snow
ask snow-cannons [ if can-make-snow? [ let efficiency calculate-efficiency let snow-amount 6 * efficiency ask patches in-radius 12 [ set snow-depth snow-depth + snow-amount * (1 - distance myself / 10) update-skiable-status ] set total-water-used total-water-used + (snow-amount * 0.5) set total-energy-used total-energy-used + (snow-amount * 0.8) ] ]
end
to-report can-make-snow?
report temperature < 0 and humidity < 90 and wind-speed < 8 and snow-depth < 70
end
to-report calculate-efficiency
let temp-effect (1 - temperature / 10) let humid-effect (1 - humidity / 100) let wind-effect (1 - wind-speed / 10) report temp-effect * humid-effect * wind-effect
end
to natural-snowfall
if random-float 100 < 20 and temperature < 0 and humidity > 40 [ set natural-snow random-float 5 ask patches [ set snow-depth snow-depth + natural-snow * humidity / 100 update-skiable-status ] ]
end
to melt-snow
if temperature > 0 [ ask patches [ let base-melt-rate 0.2 let temperature-factor temperature * 0.3 let wind-factor wind-speed * 0.1 let melt-amount (base-melt-rate + temperature-factor + wind-factor) if snow-depth > 0 [ set snow-depth max (list 0 (snow-depth - melt-amount)) update-skiable-status ] ] ]
end
to update-skiable-status
set is-skiable snow-depth >= 30
end
to update-display
ask patches [ if is-skiable [set pcolor scale-color white snow-depth 50 100] if not is-skiable [set pcolor black] ]
end
to calculate-costs
let w-price water-price let e-price energy-price set total-cost (total-water-used * w-price) + (total-energy-used * e-price)
end