Completed tile generation based on ruleset.

Move a lot of things around. Everything works correctly except for
sometimes the incorrect tile is switched and sometimes the correct tile
isn't counted correctly.