Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Langtons-ant/Zkl/langtons-ant.zkl
Normal file
15
Task/Langtons-ant/Zkl/langtons-ant.zkl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
white:=0xff|ff|ff; black:=0;
|
||||
w:=h:=100; bitmap:=PPM(w,h,white);
|
||||
x:=w/2; y:=h/2; dir:=0; // start in middle facing east
|
||||
do{
|
||||
if(bitmap[x,y]){ dir-=1; bitmap[x,y]=black; } // white-->black, turn left
|
||||
else { dir+=1; bitmap[x,y]=white; } // black-->white, turn right
|
||||
switch(dir.bitAnd(3)){ // dir is always <0
|
||||
case(0){ x+=1; } // east
|
||||
case(1){ y-=1; } // south
|
||||
case(2){ x-=1; } // west
|
||||
case(3){ y+=1; } // north
|
||||
}
|
||||
}while((0<=x<w) and (0<=y<h));
|
||||
|
||||
bitmap.write(File("foo.ppm","wb"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue