import java.util.*;

public class Robot
{
    public static final char UP = '^';
    public static final char DOWN = 'v';
    public static final char LEFT = '<';
    public static final char RIGHT = '>';

    public static final int LEFT_TURN_90 = 0;
    public static final int RUGHT_TURN_90 = 1;

    public static final int DEFAULT_START_X = 0;
    public static final int DEFAULT_START_Y = 0;

    public static final int NUMBER_OF_PANELS_TO_MOVE = 1;

    public Robot (Vector<String> instructions, int x, int y, boolean debug)
    {
        // any input instructions at this point should be provided 0

        _theComputer = new Intcode(instructions, 0, debug);
        _debug = debug;
        _currentDirection = UP;  // The robot starts facing up.
        _currentPanel = new Panel(x, y);
        _panelsPainted = new Stack<Panel>();

        _panelsPainted.push(_currentPanel);
    }

    public Robot (Vector<String> instructions, boolean debug)
    {
        this(instructions, DEFAULT_START_X, DEFAULT_START_Y, debug);
    }

    public void paint ()
    {
        Vector<String> output = null;

        while (!_theComputer.hasHalted())
        {
            output = _theComputer.executeProgram();

            /*
             * Should return two outputs:
             * 
             * First, it will output a value indicating the color to paint the panel the
             * robot is over: 0 means to paint the panel black, and 1 means to paint the panel white.
             * 
             * Second, it will output a value indicating the direction the robot should turn: 0 means
             * it should turn left 90 degrees, and 1 means it should turn right 90 degrees.
             * 
             * After the robot turns, it should always move forward exactly one panel. The robot
             * starts facing up.
             */

             String colour = output.get(0);
             String direction = output.get(1);

             if (Integer.parseInt(colour) == Panel.BLACK)
                _currentPanel.paint(Panel.BLACK);
            else
                _currentPanel.paint(Panel.WHITE);

            int newDirection = Integer.parseInt(direction);

            switch (_currentDirection)
            {
                case UP:
                {
                    if (newDirection == LEFT_TURN_90)
                        _currentDirection = LEFT;
                    else
                        _currentDirection = RIGHT;
                }
                break;
                case DOWN:
                {
                    if (newDirection == LEFT_TURN_90)
                        _currentDirection = RIGHT;
                    else
                        _currentDirection = LEFT;
                }
                break;
                case LEFT:
                {
                    if (newDirection == LEFT_TURN_90)
                        _currentDirection = DOWN;
                    else
                        _currentDirection = UP;
                }
                break;
                case RIGHT:
                {
                    if (newDirection == LEFT_TURN_90)
                        _currentDirection = UP;
                    else
                        _currentDirection = DOWN;
                }
                break;
                default:
                    System.out.println("Unknown current direction: "+_currentDirection);
                    break;
            }
        }
    }

    public final char currentDirection ()
    {
        return _currentDirection;
    }

    @Override
    public String toString ()
    {
        return "Robert current direction: "+_currentDirection+" and current panel: "+_currentPanel;
    }

    private Intcode _theComputer;
    private boolean _debug;
    private char _currentDirection;
    private Panel _currentPanel;
    Stack<Panel> _panelsPainted;
}
@@ -2172,16 +2172,259 @@
 ection);
+%0A            Coordinate currentPosition = _currentPanel.getPosition();%0A            int xCoord = currentPosition.getX();%0A            int yCoord = currentPosition.getY();%0A%0A            // figure out which direction we're supposed to point in next
 %0A%0A      
@@ -2559,32 +2559,54 @@
 = LEFT_TURN_90)%0A
+                    %7B%0A
                 
@@ -2631,32 +2631,88 @@
 rection = LEFT;%0A
+                        xCoord--;%0A                    %7D%0A
                 
@@ -2712,32 +2712,54 @@
            else%0A
+                    %7B%0A
                 
@@ -2785,32 +2785,89 @@
 ection = RIGHT;%0A
+                        xCoord ++;%0A                    %7D%0A
                 
@@ -2982,32 +2982,54 @@
 = LEFT_TURN_90)%0A
+                    %7B%0A
                 
@@ -3055,32 +3055,88 @@
 ection = RIGHT;%0A
+                        xCoord++;%0A                    %7D%0A
                 
@@ -3136,32 +3136,54 @@
            else%0A
+                    %7B%0A
                 
@@ -3208,32 +3208,88 @@
 rection = LEFT;%0A
+                        xCoord--;%0A                    %7D%0A
                 
@@ -3404,32 +3404,54 @@
 = LEFT_TURN_90)%0A
+                    %7B%0A
                 
@@ -3476,32 +3476,88 @@
 rection = DOWN;%0A
+                        yCoord--;%0A                    %7D%0A
                 
@@ -3557,32 +3557,54 @@
            else%0A
+                    %7B%0A
                 
@@ -3627,32 +3627,88 @@
 Direction = UP;%0A
+                        yCoord++;%0A                    %7D%0A
                 
@@ -3824,32 +3824,54 @@
 = LEFT_TURN_90)%0A
+                    %7B%0A
                 
@@ -3894,32 +3894,88 @@
 Direction = UP;%0A
+                        yCoord++;%0A                    %7D%0A
                 
@@ -3975,32 +3975,54 @@
            else%0A
+                    %7B%0A
                 
@@ -4047,32 +4047,88 @@
 rection = DOWN;%0A
+                        yCoord++;%0A                    %7D%0A
                 
@@ -4285,32 +4285,32 @@
          break;%0A
-
             %7D%0A  
@@ -4298,32 +4298,104 @@
 k;%0A            %7D
+%0A%0A            Panel nextPanel = new Panel(xCoord, yCoord);%0A%0A            
 %0A        %7D%0A    %7D

Update Robot.java