Added an array to track occupancy of squares, should enable perimeter checking to be simpler and more efficient.