/ Published in: Ruby
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 #!/usr/bin/env ruby $><<"\e[2J";s,o,f,c,u=20,"#"," ";b,m=(z=0..s).map{z.map{(rand<0.3)?o:f}},[-1,0,1]*3;until c==b;c=b.map{|z|z.dup};$><<"\e[H"<<b.map{|x|x*f}*"";s.times{|i|s.times{|e|n=(m.sort.zip(m)-[[0,0]]).select{|x,z|o==(c[i+x]||[])[e+z]}.size;n!=2?b[i][e]=n==3?o:f:f}};sleep 0.2;end
Comments
                    Subscribe to comments
                
                