mirror of
https://github.com/zhm-real/PathPlanning.git
synced 2026-08-30 00:50:46 +08:00
update
This commit is contained in:
@@ -132,21 +132,21 @@ class QLEARNING:
|
||||
:return: simulation path
|
||||
"""
|
||||
|
||||
plt.figure(1) # path animation
|
||||
tools.show_map(xI, xG, self.obs, self.lose, self.name1) # show background
|
||||
plt.figure(1) # path animation
|
||||
tools.show_map(xI, xG, self.obs, self.lose, self.name1) # show background
|
||||
|
||||
x, path = xI, []
|
||||
while True:
|
||||
u = self.u_set[policy[x]]
|
||||
x_next = (x[0] + u[0], x[1] + u[1])
|
||||
if x_next in self.obs:
|
||||
print("Collision!") # collision: simulation failed
|
||||
print("Collision!") # collision: simulation failed
|
||||
else:
|
||||
x = x_next
|
||||
if x_next == xG:
|
||||
break
|
||||
else:
|
||||
tools.plot_dots(x) # each state in optimal path
|
||||
tools.plot_dots(x) # each state in optimal path
|
||||
path.append(x)
|
||||
plt.show()
|
||||
self.message()
|
||||
|
||||
@@ -132,21 +132,21 @@ class SARSA:
|
||||
:return: simulation path
|
||||
"""
|
||||
|
||||
plt.figure(1) # path animation
|
||||
tools.show_map(xI, xG, self.obs, self.lose, self.name1) # show background
|
||||
plt.figure(1) # path animation
|
||||
tools.show_map(xI, xG, self.obs, self.lose, self.name1) # show background
|
||||
|
||||
x, path = xI, []
|
||||
while True:
|
||||
u = self.u_set[policy[x]]
|
||||
x_next = (x[0] + u[0], x[1] + u[1])
|
||||
if x_next in self.obs:
|
||||
print("Collision!") # collision: simulation failed
|
||||
print("Collision!") # collision: simulation failed
|
||||
else:
|
||||
x = x_next
|
||||
if x_next == xG:
|
||||
break
|
||||
else:
|
||||
tools.plot_dots(x) # each state in optimal path
|
||||
tools.plot_dots(x) # each state in optimal path
|
||||
path.append(x)
|
||||
plt.show()
|
||||
self.message()
|
||||
|
||||
Reference in New Issue
Block a user