Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
38
Task/Forest-fire/BASIC256/forest-fire.basic
Normal file
38
Task/Forest-fire/BASIC256/forest-fire.basic
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
N = 150 : M = 150 : P = 0.03 : F = 0.00003
|
||||
|
||||
dim f(N+2,M+2) # 1 tree, 0 empty, 2 fire
|
||||
dim fn(N+2,M+2)
|
||||
graphsize N,M
|
||||
fastgraphics
|
||||
|
||||
for x = 1 to N
|
||||
for y = 1 to M
|
||||
if rand<0.5 then f[x,y] = 1
|
||||
next y
|
||||
next x
|
||||
|
||||
while True
|
||||
for x = 1 to N
|
||||
for y = 1 to M
|
||||
if not f[x,y] and rand<P then fn[x,y]=1
|
||||
if f[x,y]=2 then fn[x,y]=0
|
||||
if f[x,y]=1 then
|
||||
fn[x,y] = 1
|
||||
if f[x-1,y-1]=2 or f[x,y-1]=2 or f[x+1,y-1]=2 then fn[x,y]=2
|
||||
if f[x-1,y]=2 or f[x+1,y]=2 or rand<F then fn[x,y]=2
|
||||
if f[x-1,y+1]=2 or f[x,y+1]=2 or f[x+1,y+1]=2 then fn[x,y]=2
|
||||
end if
|
||||
# Draw
|
||||
if fn[x,y]=0 then color black
|
||||
if fn[x,y]=1 then color green
|
||||
if fn[x,y]=2 then color yellow
|
||||
plot x-1,y-1
|
||||
next y
|
||||
next x
|
||||
refresh
|
||||
for x = 1 to N
|
||||
for y = 1 to M
|
||||
f[x,y] = fn[x,y]
|
||||
next y
|
||||
next x
|
||||
end while
|
||||
Loading…
Add table
Add a link
Reference in a new issue