Skip to main content
. 2024 Nov 25;24(23):7514. doi: 10.3390/s24237514
Algorithm 1 Our proposed Q-learning algorithm for the UAV path planning problem.
Input: Source location, destination location, and solution space
Output: Optimal path for UAV from source to destination
1: Initialize Q(γ,λ)0(Γstates,Λactions);
2: for each episode do 
3:    set γtλ random state from state set Γ;
4:    while (γttarget)do
5:       for each λtiΛ where i[up,down,left,right] do
6:          Determine location locλti of agent by doing action λti
7:          Calculate distance disttidistt from locλti to 
Target location.
8:          Choose locλti corresponds to smallest distti from
distt
9:         Choose λti corresponds to locλti which makes the
agent move closer to Target location
10:       end
11:       Perform action λti and receive penalty or reward
12:      Update Q(γt,λt)
13:   end
14: end