private double [] calcMoveProbs(double [] neighboursCPGrad, boolean [] connectedNeighbours){
        int l = nLength;
        double [] probOfMoves = new double[nLength];
        
        double totalGrad = 0.0;
        
        for (int i = 0; i < nLength; i++) {
            if(connectedNeighbours[i] == false){
                l--;
            }else{ totalGrad = totalGrad + Math.abs(neighboursCPGrad[i]);}
            
        }
        double probSoFar = 0.0;
        for (int i = 0; i < nLength; i++) {
            if(connectedNeighbours[i] == false){
                probOfMoves[i] = -1.0;
            }else{
                if (totalGrad == 0.0){
                    probOfMoves[i] = 1.0/l + probSoFar;
                    probSoFar = probOfMoves[i];
                }else if(Math.abs(neighboursCPGrad[i]) < 0.01){
                    probOfMoves[i] = (0.01/l/totalGrad)+ probSoFar;
                    probSoFar = probOfMoves[i];
                }else{
                    probOfMoves[i] = (Math.abs(neighboursCPGrad[i])/l/totalGrad) + probSoFar;
                    probSoFar = probOfMoves[i];
                }
            }
            //System.out.println("prob of move: "+probOfMoves[i]+","+connectedNeighbours[i]+","+neighboursCPGrad[i]);
        }
        
        for (int i = 0; i < nLength; i++) {
            if(connectedNeighbours[i] == true){
                probOfMoves[i] = probOfMoves[i]/probSoFar;
            }
        //System.out.println("prob of move: "+probOfMoves[i]+","+connectedNeighbours[i]+","+neighboursCPGrad[i]);
        }
        
        //System.out.println("");
        return probOfMoves;
    }