RosettaCodeData/Task/Forest-fire/EasyLang/forest-fire.easy
2025-06-11 20:16:52 -04:00

58 lines
1.1 KiB
Text

p_fire = 0.00002
p_tree = 0.002
#
len f[] 102 * 102
len p[] len f[]
gbackground 100
gclear
for r = 0 to 99 : for c = 0 to 99
i = r * 102 + c + 104
if randomf < 0.5 : f[i] = 1
.
timer 0
#
subr show
for r = 0 to 99 : for c = 0 to 99
i = r * 102 + c + 104
h = f[i]
if h <> p[i]
if h = 0
gcolor 100
gcircle c + 0.5 r + 0.5 0.6
elif h = 1
gcolor 151
gcircle c + 0.5 r + 0.5 0.5
else
gcolor 9 * 100 + (18 - 2 * h) * 10
gcircle c + 0.5 r + 0.5 0.5
.
.
.
.
subr update
swap f[] p[]
for r = 0 to 99 : for c = 0 to 99
i = r * 102 + c + 104
if p[i] = 0
f[i] = 0
if randomf < p_tree : f[i] = 1
elif p[i] = 1
f[i] = 1
s = p[i - 103] + p[i - 102] + p[i - 101]
s += p[i - 1] + p[i + 1]
s += p[i + 101] + p[i + 102] + p[i + 103]
if s >= 9 or randomf < p_fire
f[i] = 9
.
elif p[i] = 4
f[i] = 0
else
f[i] = p[i] - 1
.
.
.
on timer
show
update
timer 0.2
.