import java.util.function.IntConsumer;

import java.util.*;

public class GameEngine
{
    public GameEngine (Vector<String> instructions, boolean debug)
    {
        _computer = new Intcode(instructions, INITIAL_INPUT, debug);
        _debug = debug;
    }

    public final boolean playGame ()
    {
        int x = 0;
        int y = 0;
        int id = TileId.EMPTY;

        while (!_computer.hasHalted())
        {
            _computer.singleStepExecution(INITIAL_INPUT);

            if (_computer.hasOutput())
            {
                x = Integer.parseInt(_computer.getOutput());
            }
            else
            {
                System.out.println("Error - no x value given!");

                return false;
            }

            if (!_computer.hasHalted())
            {
                _computer.singleStepExecution(INITIAL_INPUT);

                if (_computer.hasOutput())
                {
                    y = Integer.parseInt(_computer.getOutput());
                }
                else
                {
                    System.out.println("Error - no y value given!");

                    return false;
                }

                if (!_computer.hasHalted())
                {
                    _computer.singleStepExecution(INITIAL_INPUT);

                    if (_computer.hasOutput())
                    {
                        id = Integer.parseInt(_computer.getOutput());
                    }
                    else
                    {
                        System.out.println("Error - no id value given!");

                        return false;
                    }
                }

                System.out.println("**got "+x+" "+y+" "+TileId.idToString(id));
            }
            else
            {
                System.out.println("Error - computer halted after x!");

                return false;
            }
        }

        return true;
    }

    private Intcode _computer;
    private boolean _debug;

    private static final int INITIAL_INPUT = 0; // nothing specified in the overview
}
@@ -419,32 +419,40 @@
   %7B%0A            
+while (!
 _computer.single
@@ -449,44 +449,34 @@
 ter.
-singleStepExecution(INITIAL_INPUT);%0A
+hasOutput())%0A            %7B
 %0A   
@@ -476,36 +476,36 @@
   %7B%0A            
-if (
+    
 _computer.hasOut
@@ -494,36 +494,59 @@
   _computer.
-hasOutput())
+singleStepExecution(INITIAL_INPUT);
 %0A           
@@ -538,38 +538,35 @@
 T);%0A            
-%7B%0A    
+%7D%0A%0A
             x = 
@@ -610,178 +610,84 @@
 ));%0A
-            %7D%0A            else%0A            %7B%0A                System.out.println(%22Error - no x value given!%22);%0A%0A                return false;%0A            %7D%0A%0A            if
+%0A            if (!_computer.hasHalted())%0A            %7B%0A                while
  (!_
@@ -690,38 +690,38 @@
  (!_computer.has
-Halted
+Output
 ())%0A            
@@ -712,34 +712,42 @@
 ())%0A            
-%7B%0A
+    %7B%0A    
                 
@@ -784,33 +784,32 @@
 INITIAL_INPUT);%0A
-%0A
                 
@@ -812,57 +812,11 @@
     
-if (_computer.hasOutput())%0A                %7B%0A    
+%7D%0A%0A
     
@@ -876,168 +876,70 @@
 ));%0A
-                %7D%0A                else%0A                %7B%0A                    System.out.println(%22Error - no y value given!%22);%0A%0A                    return false;
+%0A                if (!_computer.hasHalted())%0A                %7B
 %0A   
@@ -955,29 +955,17 @@
     
-%7D%0A%0A
     
-            if
+while
  (!_
@@ -968,38 +968,38 @@
  (!_computer.has
-Halted
+Output
 ())%0A            
@@ -994,34 +994,42 @@
                 
-%7B%0A
+    %7B%0A    
                 
@@ -1078,17 +1078,16 @@
 INPUT);%0A
-%0A
         
@@ -1102,61 +1102,11 @@
     
-if (_computer.hasOutput())%0A                    %7B%0A    
+%7D%0A%0A
     
@@ -1179,34 +1179,26 @@
             
-    %7D%0A    
+%7D%0A
             
@@ -1198,36 +1198,32 @@
            else%0A
-    
                 
@@ -1236,36 +1236,32 @@
                 
-    
 System.out.print
@@ -1276,35 +1276,37 @@
 r - 
-no id value given
+computer halted after y
 !%22);%0A%0A
-    
     
@@ -1335,38 +1335,16 @@
  false;%0A
-                    %7D%0A
         

Update GameEngine.java