sped up the per-tick generation by doing loop in one dimension.