代码拉取完成,页面将自动刷新
同步操作将从 朱洪君/monte-carlo-AGV 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import matplotlib.pyplot as plt
from gl import MAPSIZE
from change import switch_to_xy,ro2xy
import math
def DRAW_MAP(): # 绘制地图
# 绘制地图
x = range(0, 21, 1)
y = range(0, 21, 1)
plt.xticks(x, x)
plt.yticks(y, y)
# plt.style.use('ggplot') # bmh seaborn classic ggplot grayscale
for i in range(MAPSIZE.shape[0]):
for j in range(MAPSIZE.shape[1]):
plt.plot([0, MAPSIZE.shape[0]], [j, j], 'gray', linewidth=0.1)
plt.plot([i, i], [0, MAPSIZE.shape[1]], 'gray', linewidth=0.1)
#绘制箭头的方法 plt.annotate('', xy=(0.5, 0.5), xytext=(0.5, 1.5),
# arrowprops=dict(facecolor='black',arrowstyle="->", connectionstyle="arc3"))
tmpx = [i, i + 1]
tmpy1 = j
tmpy2 = j + 1
if MAPSIZE[i][j] == 0:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='white')
elif MAPSIZE[i][j] == 1:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='red')
elif MAPSIZE[i][j] == 2:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='red')
elif MAPSIZE[i][j] == 3:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='green')
elif MAPSIZE[i][j] == 4:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='yellow')
elif MAPSIZE[i][j] == 5:
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='black')
# for i in range(len(SCHE_PLAN)):
# [tmpx1,tmpy1]=switch_to_xy(SCHE_PLAN[i][0])
# [tmpx1,tmpy1]=[tmpx1+0.2,tmpy1+0.2]
# tmpy2=tmpy1+0.6
# tmpx2=tmpx1+0.6
# tmpx=[tmpx1,tmpx2]
# plt.fill_between(tmpx,tmpy1,tmpy2,facecolor='blue')
plt.plot([0, MAPSIZE.shape[0]], [MAPSIZE.shape[1], MAPSIZE.shape[1]], 'gray')
plt.plot([MAPSIZE.shape[0], MAPSIZE.shape[0]], [0, MAPSIZE.shape[1]], 'gray')
# plt.show()
def DRAW_PATH_BY_TREE(tree):
DRAW_MAP()
for i in range(len(tree)):
[tmpx1, tmpy1] = switch_to_xy(tree[i].location)
[tmpx1, tmpy1] = [tmpx1 + 0.2, tmpy1 + 0.2]
tmpy2 = tmpy1 + 0.6
tmpx2 = tmpx1 + 0.6
tmpx = [tmpx1, tmpx2]
# if tree[i].AGV==0:
# plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='blue')
# if tree[i].AGV==1:
# plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='gray')
# if tree[i].AGV==2:
# plt.fill_between(tmpx, tmpy1, tmpy2, facecolor='purple')
plot_path(tree[i])
def rotate_arrow(treenode,color):
[x, y] = switch_to_xy(treenode.location)
[xflag,yflag] = ro2xy(treenode.rotation)
if xflag==1:
plt.annotate('', xy=(x + 1, y + 0.5), xytext=(x, y + 0.5),
arrowprops=dict(color=color, arrowstyle="->", connectionstyle="arc3"))
if xflag==-1:
plt.annotate('', xy=(x, y + 0.5), xytext=(x+1, y + 0.5),
arrowprops=dict(color=color, arrowstyle="->", connectionstyle="arc3"))
if yflag==1:
plt.annotate('', xy=(x + 0.5, y + 1), xytext=(x+ 0.5, y ),
arrowprops=dict(color=color, arrowstyle="->", connectionstyle="arc3"))
if yflag==-1:
plt.annotate('', xy=(x + 0.5, y ), xytext=(x+ 0.5, y + 1),
arrowprops=dict(color=color, arrowstyle="->", connectionstyle="arc3"))
def plot_path(self):
if len(self.children) != 0:
for i in range(len(self.children)):
plot_path(self.children[i])
if self.AGV==0:
rotate_arrow(self,'blue')
if self.AGV == 1:
rotate_arrow(self, 'gray')
if self.AGV == 2:
rotate_arrow(self,'purple')
return 0
else:
if self.AGV == 0:
rotate_arrow(self, 'blue')
if self.AGV == 1:
rotate_arrow(self, 'gray')
if self.AGV == 2:
rotate_arrow(self, 'purple')
return 0
def plot_AGV(location,color):
[x,y]=switch_to_xy(location)
tmpx=[x+0.2,x+0.8]
tmpy1=y+0.2
tmpy2=tmpy1+0.8
plt.fill_between(tmpx, tmpy1, tmpy2, facecolor=color)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。