This commit is contained in:
zhm-real
2020-06-19 17:37:53 -07:00
parent 8549bd00d3
commit e477cb2e4c
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -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()
+4 -4
View File
@@ -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()