private double getCost(int n, int m, int nextLevelCalls, int[][] newBoard, double cost) {
        int emptyCnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (newBoard[i][j] == 0) {
                    emptyCnt++;
                    newBoard[i][j] = 2;
                    cost += findBestMoveInternal(newBoard, nextLevelCalls).cost * 0.9;
                    newBoard[i][j] = 4;
                    cost += findBestMoveInternal(newBoard, nextLevelCalls).cost * 0.1;
                    newBoard[i][j] = 0;
                }
            }
        }
        cost /= emptyCnt;
        return cost;
    }