(* this draws a random perculation grid with the given perameters*) h=20; (* height*) w=20;a (* width *) p=.5; (* probability of including edge*) j=0; (*intial positions*) k=0; a={Line[{{0,0},{0,h},{w,h},{w,0},{0,0}}]}; For[j=0, j Automatic]