import java.util.*;

public class MovementLogic
{
    public static final int ROUTINE_A = 0;
    public static final int ROUTINE_B = 1;
    public static final int ROUTINE_C = 2;
    public static final int ROUTINE_D = 3;

    public static final String MOVE_LEFT = "L";
    public static final String MOVE_RIGHT = "R";

    public MovementLogic (Map theMap, boolean debug)
    {
        _theMap = theMap;
        _path = new Stack<String>();
        _robotFacing = CellId.ROBOT_FACING_UP;
        _debug = debug;
    }

    public void createMovementFunctions ()
    {

    }

    public void createMovementRoutine ()
    {
        
    }

    /*
     * Create path using only L and R.
     */

    private void createPath ()
    {
        Coordinate currentPosition = new Coordinate(_theMap.findStartingPoint());
        
        if (currentPosition != null)
        {
            // try R then L

        }
        else
            System.out.println("Robot not found!");
    }

    private Coordinate leftPosition (Coordinate coord)
    {
        int x = coord.getX();
        int y = coord.getY();

        switch (_robotFacing)
        {
            case CellId.ROBOT_FACING_DOWN:
            {
                x++;
            }
            break;
            case CellId.ROBOT_FACING_UP:
            {

            }
            case CellId.ROBOT_FACING_LEFT:
            {

            }
            case CellId.ROBOT_FACING_RIGHT:
            default:
        }
    }

    private Map _theMap;
    private Stack<String> _path;
    private String _robotFacing;
    private boolean _debug;
}
@@ -483,16 +483,88 @@
 ING_UP;%0A
+        _currentPosition = new Coordinate(_theMap.findStartingPoint());%0A
         
@@ -806,27 +806,21 @@
         
-Coordinate 
+if (_
 currentP
@@ -831,53 +831,462 @@
 ion 
+!
 = n
-ew Coordinate(_theMap.findStartingPoin
+ull)%0A        %7B%0A            // try R then L%0A%0A            if (!tryMoveRight())%0A                tryMoveLeft();%0A        %7D%0A        else%0A            System.out.println(%22Robot not found!%22);%0A    %7D%0A%0A    private boolean tryMoveRight ()%0A    %7B%0A        Coordinate coord = rightPosition(_currentPosition);%0A%0A        if (_theMap.isScaffold(coord))%0A        %7B%0A            _path.push(MOVE_RIGHT);%0A            _currentPosition = coord;%0A%0A            return tryMoveRigh
 t()
-)
 ;%0A  
@@ -1287,24 +1287,25 @@
 ();%0A        
+%7D
 %0A        if 
@@ -1305,148 +1305,1038 @@
     
-if (currentPosition != null)%0A        %7B%0A            // try R then L%0A%0A        %7D%0A        else%0A            System.out.println(%22Robot not found!%22
+else%0A            return false;%0A    %7D%0A%0A    private boolean tryMoveLeft ()%0A    %7B%0A        Coordinate coord = leftPosition(_currentPosition);%0A%0A        if (_theMap.isScaffold(coord))%0A        %7B%0A            _path.push(MOVE_LEFT);%0A            _currentPosition = coord;%0A%0A            return tryMoveLeft();%0A        %7D%0A        else%0A            return false;%0A    %7D%0A%0A    private final Coordinate rightPosition (Coordinate coord)%0A    %7B%0A        int x = coord.getX();%0A        int y = coord.getY();%0A%0A        switch (_robotFacing)%0A        %7B%0A            case CellId.ROBOT_FACING_DOWN:%0A            %7B%0A                x--;%0A            %7D%0A            break;%0A            case CellId.ROBOT_FACING_UP:%0A            %7B%0A                x++;%0A            %7D%0A            break;%0A            case CellId.ROBOT_FACING_LEFT:%0A            %7B%0A                y++;%0A            %7D%0A            break;%0A            case CellId.ROBOT_FACING_RIGHT:%0A            default:%0A            %7B%0A                y--;%0A            %7D%0A            break;%0A        %7D%0A%0A        return new Coordinate(x, y
 );%0A 
@@ -2353,16 +2353,22 @@
 private 
+final 
 Coordina
@@ -2671,38 +2671,77 @@
           %7B%0A
-%0A            %7D
+                x--;%0A            %7D%0A            break;
 %0A           
@@ -2786,30 +2786,69 @@
       %7B%0A
-%0A            %7D
+                y--;%0A            %7D%0A            break;
 %0A       
@@ -2909,25 +2909,131 @@
 lt:%0A        
-%7D
+    %7B%0A                y++;%0A            %7D%0A            break;%0A        %7D%0A%0A        return new Coordinate(x, y);
 %0A    %7D%0A%0A    
@@ -3119,16 +3119,57 @@
 Facing;%0A
+    private Coordinate _currentPosition;%0A
     priv

Update MovementLogic.java