getTop & getBottom switched;

findValidLocations within AI actions loop was causing a problem - fixed;
now validLocation[j] = 0 is causing a problem