Buggy code:
public class GameBoard { interface WolfSheepDelegate { public void wolfEatSheep ( Player wolf , Player sheep ) { } } boolean ui = false ; private final int cols ; private final int rows ; private List < Player > board = new ArrayList < Player > ( ) ; Deque < Player > players = new ArrayDeque ( ) ; private Map < Player , int [ ] > scores = new HashMap ( ) ; Map < String , Object > sheepWhiteboard = new HashMap ( ) ; GameBoard . WolfSheepDelegate wolfEatSheepDelegate = null ; public final double maxWolfDistance = 2 ; public final int wolfEatingTime = 7 ; int maxTimeStep ; final int NUMWOLVES = 1 ; int currentTimeStep = 0 ; WasGameBackend wasgamegrid = null ; GameLocation clearShot ( GameLocation a , GameLocation b ) { Move m = new Move ( ( ( b . x ) - ( a . x ) ) , ( ( b . y ) - ( a . y ) ) ) ; double maxlen = m . length ( ) ; <START_BUG> m = m . scaledToLength ( Math . sqrt ( 2 ) ) ; <END_BUG> int lastemptyX = a . x ; int lastemptyY = a . y ; double x = ( a . x ) + 0.5 ; double y = ( a . y ) + 0.5 ; double distcovered = 0 ; double perstep = Math . sqrt ( ( ( ( m . delta_x ) * ( m . delta_x ) ) + ( ( m . delta_y ) * ( m . delta_y ) ) ) ) ; while ( true ) { x += m . delta_x ; y += m . delta_y ; distcovered += perstep ; if ( distcovered > maxlen ) { break ; } int xx = ( ( int ) ( x ) ) ; int yy = ( ( int ) ( y ) ) ; if ( ( getPiece ( xx , yy ) ) == ( GamePiece . OBSTACLE ) ) { return new GameLocation ( lastemptyX , lastemptyY ) ; } if ( ( ( b . x ) == xx ) && ( ( b . y ) == yy ) ) { break ; } if ( isEmptyCell ( xx , yy ) ) { lastemptyX = xx ; lastemptyY = yy ; } } return b ; } private boolean movePlayer ( Player player , Move m ) { } void sheepSurroundWolf ( Player wolfPlayer ) { } void wolfEatSheep ( int wolfIndex , int sheepIndex ) { } GameBoard ( ) { } GameBoard ( int width , int height , boolean ui , int maxTimeStep ) { } public int getMaxTimeStep ( ) { } public int getTime ( ) { } GameLocation getLoc ( int index ) { } int getX ( int index ) { } int getY ( int index ) { } int getIndex ( GameLocation l ) { } int getIndex ( int x , int y ) { } int getIndexUnchecked ( GameLocation l ) { } int getIndexUnchecked ( int x , int y ) { } public int getRows ( ) { } public int getCols ( ) { } public GameLocation getWolfPosition ( ) { } public ArrayList < GameLocation > getSheepPositions ( ) { } public ArrayList < GameLocation > getPasturePositions ( ) { } public ArrayList < GameLocation > getObstaclePositions ( ) { } public GameLocation getPlayerPositionByID ( String playerIDString ) { } public String getPlayerIDatPosition ( GameLocation loc ) { } ArrayList < GameLocation > findAllPlayersLoc ( GamePiece type ) { } void printPlayerOverview ( ) { } public class PublicPlayerInfo { public GamePiece type ; public String id ; public String className ; public GameLocation loc ; public int timeValid ; } public Map < String , GameBoard . PublicPlayerInfo > findAllPlayers ( ) { } public boolean isEmptyCell ( int x , int y ) { } boolean isEmptyCell ( int i ) { } public GamePiece getPiece ( int x , int y ) { } GamePiece getPiece ( GameLocation i ) { } GamePiece getPiece ( int i ) { } private List < Player > getPlayers ( ) { } ArrayList < Player > findAllPlayers ( GamePiece type ) { } boolean hasPlayer ( Player p ) { } public int numPlayers ( ) { } private Player getPlayer ( int i ) { } void checkPlayerAt ( Player p , int x , int y ) { } private void swapCells ( int i1 , int i2 ) { } static Random rand = new Random ( ) ; GameLocation randomEmptyLocation ( List < GameLocation > e1 , List < GameLocation > e2 ) { } void setPlayerAt ( int i , Player p ) { } Player addPlayer ( Player p , GameLocation loc ) { } public double allowedMoveDistance ( GamePiece g ) { } public double allowedMoveDistance ( Player p ) { } static void log ( String s ) { } synchronized boolean noteMove ( Player p , Move move ) { } synchronized void logPlayerCrash ( Class pl , Exception ex ) { } synchronized void exitRequested ( ) { } Scenario scenario = null ; void gameNextTimeStep ( ) { } boolean isFinished ( ) { } Map < Player , int [ ] > playGame ( boolean pauseInitially ) { } public void print ( ) { } private void playerWins ( Player p ) { } private void playerLoses ( Player p ) { } void removePlayer ( Player p ) { } void printScores ( ) { } }

Fix:
m = m . scaledToLength ( 1.0 ) ;