How to get fundamental frequency of a signal using autocorrelation?
The value of the peak of the autocorrelation function (maximum) is not really important - though it can be used as a basic feature for voiced/unvoiced classification or more generally for "pitchedness".

What matters is the index at which the function takes its maximum (arg-maximum). This is very intuitive to understand: if the signal has a period of $\tau$ samples, the original signal and the signal shifted by $\tau$ samples should be very similar, so the autocorrelation function will have a peak when evaluated at $\tau$.

Thus, the interesting variable is max_i in your code. One thing I notice is that you search through the whole autocorrelation_values vector. But the autocorrelation function is maximum at 0, so your maximum will always be 0! I advise you to think about a meaningful range for the fundamental frequency you want to detect, and restrict the search in this range to get a meaningful result.

I hadn't checked the rest of your code in details, I don't think it is the purpose of this site to dive into coding/implementation problems.