Buggy code:
public class Eviline2AI extends AbstractAI implements Configurable { protected static final Constant < Boolean > DROPS_ONLY = new Constant ( PropertyConstant . BOOLEAN , ".eviline.drops_only" , true ) ; protected static final Constant < Integer > LOOKAHEAD = new Constant ( PropertyConstant . INTEGER , ".eviline.lookahead" , 3 ) ; protected static final Constant < Integer > PRUNE_TOP = new Constant ( PropertyConstant . INTEGER , ".eviline.prune_top" , 5 ) ; protected static final Constant < Integer > MAX_THREADS = new Constant ( PropertyConstant . INTEGER , ".eviline.max_threads" , 64 ) ; protected static final Constant < String > FITNESS = new Constant < String > ( PropertyConstant . STRING , ".eviline.fitness" , "NextFitness" ) ; protected static final Constant < Integer > PIPELINE_LENGTH = new Constant ( PropertyConstant . INTEGER , ".eviline.pipeline_length" , 3 ) ; protected static class EvilineAIConfigurator implements Configurable . Configurator { private JCheckBox dropsOnly ; private JSpinner lookahead ; private JSpinner pruneTop ; private JSpinner maxThreads ; private JSpinner pipelineLength ; private JComboBox < String > fitness ; private JPanel panel ; public EvilineAIConfigurator ( ) { } @ Override public JComponent getConfigurationComponent ( ) { } @ Override public void applyConfiguration ( CustomProperties p ) { } @ Override public void reloadConfiguration ( CustomProperties p ) { } } private static Eviline2AI . EvilineAIConfigurator configurator = new Eviline2AI . EvilineAIConfigurator ( ) ; protected static final ThreadPoolExecutor POOL = new ThreadPoolExecutor ( 1 , 1 , 10 , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) , new ThreadPoolExecutor . DiscardPolicy ( ) ) ; protected class PathPipeline { public ExecutorService exec ; public LinkedBlockingDeque < Eviline2AI . PathTask > pipe = new LinkedBlockingDeque < Eviline2AI . PathTask > ( ) ; public PathPipeline ( ) { } public void exec ( Runnable task ) { } public synchronized boolean extend ( final GameEngine gameEngine ) { } public synchronized Eviline2AI . PathTask discardUntil ( GameEngine engine ) { } public synchronized byte [ ] currentPath ( GameEngine engine ) { } public synchronized int desiredXYShape ( GameEngine engine ) { } public synchronized Field expectedField ( GameEngine engine ) { } public synchronized boolean isDirty ( GameEngine engine ) { } public synchronized void shutdown ( ) { } } protected class PathTask { public Eviline2AI . PathPipeline pipeline ; public int seq ; public Field field ; public Field after ; public int xystart ; public int xydest ; public ShapeType [ ] next ; public FutureTask < Boolean > task ; public byte [ ] path ; public PathTask ( final GameEngine gameEngine , final Eviline2AI . PathPipeline pipeline , int seq , Field field , int xystart , ShapeType [ ] next ) { } public Boolean get ( ) { } public Eviline2AI . PathTask extend ( GameEngine gameEngine ) { } } protected SubtaskExecutor subtasks ; protected DefaultAIKernel ai ; protected Command shifting = null ; protected int lookahead = 3 ; protected Eviline2AI . PathPipeline pipeline ; protected int pipeLength = 1 ; protected byte [ ] createCommandPath ( CommandGraph g ) { } protected ShapeType [ ] createGameNext ( GameEngine engine , int seq ) { <START_BUG> int size = Math . min ( ( ( engine . nextPieceArraySize ) - seq ) , ( ( ( lookahead ) + ( pipeLength ) ) + 2 ) ) ; <END_BUG> ShapeType [ ] nextShapes = new ShapeType [ size ] ; for ( int i = 0 ; i < size ; i ++ ) nextShapes [ i ] = XYShapeAdapter . toShapeType ( engine . getNextObject ( ( seq + i ) ) ) ; return nextShapes ; } public Eviline2AI ( ) { } protected void resetPipeline ( GameEngine engine ) { } @ Override public String getName ( ) { } @ Override public void init ( GameEngine engine , int playerID ) { } @ Override public void shutdown ( GameEngine engine , int playerID ) { } protected int lastxy = - 1 ; @ Override public void setControl ( GameEngine engine , int playerID , Controller ctrl ) { } @ Override public void onFirst ( GameEngine engine , int playerID ) { } @ Override public void onLast ( GameEngine engine , int playerID ) { } @ Override public void renderState ( GameEngine engine , int playerID ) { } @ Override public void newPiece ( GameEngine engine , int playerID ) { } @ Override public void renderHint ( GameEngine engine , int playerID ) { } @ Override public Configurator getConfigurator ( ) { } }

Fix:
int size = Math . min ( ( ( engine . nextPieceArraySize ) - ( seq % ( engine . nextPieceArraySize ) ) ) , ( ( ( lookahead ) + ( pipeLength ) ) + 2 ) ) ;