src/gamemechanics/Util.java
public static boolean tryMove(Direction dir, float degreeOffset, int checksPerSide, float distance)
			throws GameActionException {

		if (distance > rc.getType().strideRadius) {
			distance = rc.getType().strideRadius;
		}

		if (dir == null) {
			dir = Direction.NORTH;
		}

		// First, try intended direction
		if (rc.canMove(dir, distance)) {
			rc.move(dir, distance);
			return true;
		}

		// Now try a bunch of similar angles
		int currentCheck = 1;

		while (currentCheck <= checksPerSide) {
			// Try the offset of the left side
			if (rc.canMove(dir.rotateLeftDegrees(degreeOffset * currentCheck), distance)) {
				rc.move(dir.rotateLeftDegrees(degreeOffset * currentCheck), distance);
				return true;
			}
			// Try the offset on the right side
			if (rc.canMove(dir.rotateRightDegrees(degreeOffset * currentCheck), distance)) {
				rc.move(dir.rotateRightDegrees(degreeOffset * currentCheck), distance);
				return true;
			}
			// No move performed, try slightly further
			currentCheck++;
		}

		// A move never happened, so return false.
		return false;
	}
/**
	 * Attempts to move in a given direction, while avoiding small obstacles
	 * direction in the path.
	 *
	 * @param dir
	 *            The intended direction of movement
	 * @param degreeOffset
	 *            Spacing between checked directions (degrees)
	 * @param checksPerSide
	 *            Number of extra directions checked on each side, if intended
	 *            direction was unavailable
	 * @return true if a move was performed
	 * @throws GameActionException
	 */
Attempts to move in a given direction, while avoiding small obstacles
direction in the path.


Attempts to move in a given direction while avoiding small obstacles direction in the path .
public static boolean tryMove(Direction dir, float degreeOffset, int checksPerSide, float distance)
			throws GameActionException {
		if (distance > rc.getType().strideRadius) {
			distance = rc.getType().strideRadius;
		}
		if (dir == null) {
			dir = Direction.NORTH;
		}
		if (rc.canMove(dir, distance)) {
			rc.move(dir, distance);
			return true;
		}
		int currentCheck = 1;
		while (currentCheck <= checksPerSide) {
			if (rc.canMove(dir.rotateLeftDegrees(degreeOffset * currentCheck), distance)) {
				rc.move(dir.rotateLeftDegrees(degreeOffset * currentCheck), distance);
				return true;
			}
			if (rc.canMove(dir.rotateRightDegrees(degreeOffset * currentCheck), distance)) {
				rc.move(dir.rotateRightDegrees(degreeOffset * currentCheck), distance);
				return true;
			}
			currentCheck++;
		}
		return false;
	}
public static boolean tryMove ( Direction dir , float degreeOffset , int checksPerSide , float distance ) throws GameActionException { if ( distance > rc . getType ( ) . strideRadius ) { distance = rc . getType ( ) . strideRadius ; } if ( dir == null ) { dir = Direction . NORTH ; } if ( rc . canMove ( dir , distance ) ) { rc . move ( dir , distance ) ; return true ; } int currentCheck = 1 ; while ( currentCheck <= checksPerSide ) { if ( rc . canMove ( dir . rotateLeftDegrees ( degreeOffset * currentCheck ) , distance ) ) { rc . move ( dir . rotateLeftDegrees ( degreeOffset * currentCheck ) , distance ) ; return true ; } if ( rc . canMove ( dir . rotateRightDegrees ( degreeOffset * currentCheck ) , distance ) ) { rc . move ( dir . rotateRightDegrees ( degreeOffset * currentCheck ) , distance ) ; return true ; } currentCheck ++ ; } return false ; }
Attempts to move in a given direction, while avoiding small obstacles
 direction in the path.
Attempts to move in a given direction while avoiding small obstacles direction in the path .
// First, try intended direction // Now try a bunch of similar angles // Try the offset of the left side // Try the offset on the right side // No move performed, try slightly further // A move never happened, so return false.