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;
        _theScreen = new Screen(_debug);
        _paddlePosition = null;
        _ballPosition = null;
    }

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

        /*
         * Initialise the screen.
         */

        while (!_computer.hasHalted())
        {
            while (!_computer.hasHalted() && !_computer.hasOutput())
            {
                _computer.singleStepExecution(INITIAL_INPUT);
            }

            if (!_computer.hasHalted())
            {
                x = Integer.parseInt(_computer.getOutput());

                while (!_computer.hasHalted() && !_computer.hasOutput())
                {
                    _computer.singleStepExecution(INITIAL_INPUT);
                }

                if (!_computer.hasHalted())
                {
                    y = Integer.parseInt(_computer.getOutput());

                    while (!_computer.hasHalted() && !_computer.hasOutput())
                    {
                        _computer.singleStepExecution(INITIAL_INPUT);
                    }

                    id = Integer.parseInt(_computer.getOutput());
                }
                else
                {
                    System.out.println("Error - computer halted after outputing x value!");

                    return false;
                }

                if (_debug)
                    System.out.println("Tile information: <"+x+", "+y+"> and "+TileId.idToString(id));

                Tile theTile = new Tile(new Coordinate(x, y), id));

                _theScreen.updateTile(theTile);

                if(theTile.getId() == TileId.BALL)
                    _ballPosition = theTile.getPosition();
                else
                {
                    if (theTile.getId() == TileId.PADDLE)
                        _paddlePosition = theTile.getPosition();
                }
            }
            else
            {
                if (_debug)
                    System.out.println("Computer halted.");

                return true;
            }
        }

        return true;
    }

    public final int getNumberOfBlocks ()
    {
        return _theScreen.numberOfBlocks();
    }

    private final int[] getInformation ()
    {
        int[] values = new int[3];
        
        while (!_computer.hasHalted() && !_computer.hasOutput())
            {
                _computer.singleStepExecution(INITIAL_INPUT);
            }

            if (!_computer.hasHalted())
            {
                x = Integer.parseInt(_computer.getOutput());

                while (!_computer.hasHalted() && !_computer.hasOutput())
                {
                    _computer.singleStepExecution(INITIAL_INPUT);
                }

                if (!_computer.hasHalted())
                {
                    y = Integer.parseInt(_computer.getOutput());

                    while (!_computer.hasHalted() && !_computer.hasOutput())
                    {
                        _computer.singleStepExecution(INITIAL_INPUT);
                    }

                    id = Integer.parseInt(_computer.getOutput());
                }
                else
                {
                    System.out.println("Error - computer halted after outputing x value!");

                    return false;
                }

                if (_debug)
                    System.out.println("Tile information: <"+x+", "+y+"> and "+TileId.idToString(id));
    }

    private Intcode _computer;
    private boolean _debug;
    private Screen _theScreen;
    private Coordinate _paddlePosition;
    private Coordinate _ballPosition;

    private static final int INITIAL_INPUT = 0; // nothing specified in the overview
}
@@ -2512,16 +2512,25 @@
 mation (
+int input
 )%0A    %7B%0A
@@ -2564,24 +2564,16 @@
 int%5B3%5D;%0A
-        
 %0A       
@@ -2634,34 +2634,26 @@
 ())%0A        
-    %7B%0A    
+%7B%0A
             
@@ -2678,37 +2678,29 @@
 epExecution(
-INITIAL_INPUT
+input
 );%0A         
@@ -2690,36 +2690,32 @@
 input);%0A        
-    
 %7D%0A%0A            i
@@ -2701,36 +2701,32 @@
      %7D%0A%0A        
- 
-   
 if (!_computer.h
@@ -2737,36 +2737,32 @@
 lted())%0A        
-    
 %7B%0A              
@@ -2751,37 +2751,41 @@
   %7B%0A            
-    x
+values%5B0%5D
  = Integer.parse
@@ -2805,36 +2805,32 @@
 .getOutput());%0A%0A
-    
             whil
@@ -2886,36 +2886,32 @@
 ())%0A            
-    
 %7B%0A              
@@ -2904,36 +2904,32 @@
                 
- 
-   
 _computer.single
@@ -2942,36 +2942,24 @@
 ecution(
-INITIAL_INPUT);%0A    
+input);%0A
         
@@ -2957,36 +2957,32 @@
 %0A            %7D%0A%0A
-    
             if (
@@ -3009,36 +3009,32 @@
 ())%0A            
- 
-   
 %7B%0A              
@@ -3027,37 +3027,41 @@
                 
-    y
+values%5B1%5D
  = Integer.parse
@@ -3097,36 +3097,32 @@
                 
-   
- 
 while (!_compute
@@ -3174,34 +3174,26 @@
             
-    %7B%0A    
+%7B%0A
             
@@ -3230,35 +3230,24 @@
 ecution(
-INITIAL_INPUT);%0A   
+input);%0A
         
@@ -3246,33 +3246,32 @@
                 
- 
 %7D%0A%0A             
@@ -3265,38 +3265,41 @@
                 
-    id
+values%5B2%5D
  = Integer.parse
@@ -3318,36 +3318,32 @@
 r.getOutput());%0A
-    
             %7D%0A  
@@ -3344,36 +3344,32 @@
   %7D%0A            
-    
 else%0A           
@@ -3365,34 +3365,26 @@
             
-    %7B%0A    
+%7B%0A
             
@@ -3451,33 +3451,32 @@
 ing x value!%22);%0A
-%0A
                 
@@ -3475,43 +3475,18 @@
     
-        return false;%0A     
+%7D%0A
         
    %7D
@@ -3473,35 +3473,32 @@
       %7D%0A        
-   
 %7D%0A%0A             
@@ -3496,129 +3496,20 @@
     
-        if (_debug)%0A                    System.out.println(%22Tile information: %3C%22+x+%22, %22+y+%22%3E and %22+TileId.idToString(id))
+retrn values
 ;%0A  

Update GameEngine.java