Cellular Automata by Muncher16th Feb 2005 20:39
|
---|
Summary Works with DBPro! * At least, I think it will Description Uses: Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com set display mode 1024,768,32 rem set manual screen refreshing on at fastest speed sync on sync rate 0 rem upr is the amount of grid pixels to be created vertically upr=768 rem sde is the amount of grid pixels to be created horizontally sde=1024 rem how many times to loop timestep=2 rem grid dim grid(sde,upr) hide mouse rem set random seed wait rnd(20) randomize timer() rem fill grid with random pixels, and show them for x=0 to sde for y=0 to upr grid(x,y)=rnd(1) col=255*grid(x,y) ink rgb(col,col,col),0 dot x,y next y Rem Good random formula e=timer()^sin(x)-timer()/cos(x) randomize e next x for t=0 to timestep for x=1 to sde-1 for y=1 to upr-1 rem use moore neighborhood logic add=grid(x-1,y-1)+grid(x,y-1)+grid(x+1,y-1) add=add+grid(x-1,y)+grid(x,y)+grid(x+1,y) add=add+grid(x-1,y+1)+grid(x,y+1)+grid(x+1,y+1) if add=4 or add=6 or add=7 or add=8 or add=9 grid(x,y)=1 else grid(x,y)=0 endif next y next x rem Actually draw bitmap for x=1 to sde-1 for y=1 to upr-1 rem color grid pixel black for 0, and white for 1 col=255*grid(x,y) ink rgb(col,col,col),0 rem draw pixel dot x-1,y-1 next y next x next t sync ex: rem Wait for key wait key end |