The terrain is generated using MATLAB code from the following link:
Cost function of the terrain is defined as the difference in altitude and it is always positive numbers.
Check the following documents for more explanations:
Auralius Manurung (2020). Finding optimal path on a terrain (https://www.mathworks.com/matlabcentral/fileexchange/39034-finding-optimal-path-on-a-terrain), MATLAB Central File Exchange. Retrieved .
Bugs fixed on the termination critera
Added more comments.
Added links to download more detailed explanations.