部分代码:
%CA driver
%HPP-gas
clear all
clf
nx=52;
ny=100;
z=zeros(nx,ny);
o=ones(nx,ny);
sand=z;
sandNew=z;
gnd=z;
diag1=z;
diag2=z;
and12=z;
or12=z;
sums=z;
orsum=z;
gnd(1:nx,ny-3)=1 ; % right ground line
gnd(1:nx,3)=1 ; % left ground line
gnd(nx/4:nx/2-2,ny/2)=1; %the hole line
gnd(nx/2+2:nx,ny/2)=1; %the hole line
gnd(nx/4, 1:ny) = 1; %top line
gnd(3*nx/4, 1:ny) = 1 ;%bottom line
%fill the left side
r = rand(nx,ny);
sand(nx/4+1:3*nx/4-1, 4:ny/2-1) = r(nx/4+1:3*nx/4-1, 4:ny/2-1)<0.3;
1