March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
25
Task/Forest-fire/PARI-GP/forest-fire.pari
Normal file
25
Task/Forest-fire/PARI-GP/forest-fire.pari
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
step(M,p,f)={
|
||||
my(m=matsize(M)[1],n=matsize(M)[2]);
|
||||
matrix(m,n,i,j,
|
||||
if(M[i,j]=="*",
|
||||
" "
|
||||
,
|
||||
if(M[i,j]=="t",
|
||||
my(nbr="t");
|
||||
for(x=max(1,i-1),min(m,i+1),
|
||||
for(y=max(1,j-1),min(n,j+1),
|
||||
if(M[x,y]=="*",nbr="*";break(2))
|
||||
)
|
||||
);
|
||||
if(random(1.)<f,"*",nbr)
|
||||
,
|
||||
if(random(1.)<p,"t"," ")
|
||||
)
|
||||
)
|
||||
)
|
||||
};
|
||||
burn(n,p,f)={
|
||||
my(M=matrix(n,n,i,j,if(random(2)," ","t")),N);
|
||||
while(1,print(M=step(M,p,f)))
|
||||
};
|
||||
burn(5,.1,.03)
|
||||
Loading…
Add table
Add a link
Reference in a new issue