I know that this will sound a bit fussy, but you really have to work on your java naming conventions. This will improve the readability and quality of your code so much in the long term! things i recognised:
Objects = lowercase (Script s)
use the final keyword (final Script s, final boolean direction, ....) Things i don't understand:
if(direction) {
for(int u = 0; u < fullPath.size(); u++) {
Position p = fullPath.get(u);
if(S.distance(p) < 11) {
int xOffSet = MethodProvider.random(3)-1;
int yOffSet = MethodProvider.random(3)-1;
return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());
}
}
} else {
for(int u = fullPath.size()-1; u > 0; u=u-1) {
Position p = fullPath.get(u);
if(S.distance(p) < 10) {
int xOffSet = MethodProvider.random(5)-2;
int yOffSet = MethodProvider.random(5)-2;
return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());
}
}
}
why do you have different offset based on the direction your walking? why do you have different conditions? (S.distance(p) < 10 ...... S.distance(p) < 11) please rework the things i told you and post again Edit: make Script private and rethink private/public on your methods...