use std.process_bar; use std.runtime; use std.os; use std.io; use std.unix; var new_map = func(width,height) { var tmp=[]; setsize(tmp,height); forindex(var i;tmp) { tmp[i]=[]; setsize(tmp[i],width); } return tmp; } var prt = func(map) { var s='\e[H'; foreach(var line;map) { foreach(var elem;line) s~=elem~' '; s~='\n'; } print(s); unix.sleep(1/160); } var run = func(width,height) { var check = func(_width,_height) { if (_height>=height) _height=0; if (_width>=width) _width=0; return map[_height][_width]=='O'; } # enable ANSI escape sequence if (os.platform()=="windows") system("color"); print("\ec"); rand(time(0)); var map=new_map(width,height); var tmp=new_map(width,height); forindex(var i;map) forindex(var j;map[i]) map[i][j]=rand()<0.45?'O':'.'; for(var r=0;r<100;r+=1) { prt(map); for(var i=0;i=height) _height=0; if (_width>=width) _width=0; return map[_height*width+_width]==1; } for(var r=0;r<1001;r+=1) { ts.stamp(); for(var i=0;i