Created attachment 9 [details] Bug if(board.getPiece(target_x, target_y).getColor()){ if(x==4){ if(target_x-x==1&&Math.abs(target_y-y)==1){ Piece piece=board.getPiece(x,target_y); if(piece!=null) if(piece instanceof Pawn&&((Pawn) piece).bepassant()){ return true; } } } } In board.getPiece() function, there should be (x,y) instead of target_x and target_y. Or it will result in nullpointer exception.