资源简介
此代码是本团队参加2019届华为软件精英挑战赛时所写代码,代码内容包括车辆行驶地图模型建立、路径选择A*算法实现
代码片段和文件信息
import re
import numpy as np
import copy
def read_file(road_file_name):
fi = open(“{}“.format(road_file_name) “r“ encoding=“utf-8“)
information_txt = fi.read()
p1 = r“(.+)“
pattern1 = re.compile(p1)
information = pattern1.findall(information_txt)
information.pop(0)
return information
def information_list_transform_dict(information_list):
information_dict = {}
for i in range(len(information_list)):
information_dict[‘{}‘.format(eval(information_list[i])[0])] =list(eval(information_list[i]))
return information_dict
def creat_dict_sideweight_oritation(road_information_dictcross_information_dict):
cross_sideweight_dict={}
cross_oritation_dict={}
for key in cross_information_dict.keys():
cross_sideweight_list = [0 0 0 0 0]
cross_oritation_list = [0 0 0 0 0]
cross_sideweight_list[0]=int(key)
cross_oritation_list[0]=int(key)
for i in range(15):
cross_road_id = cross_information_dict[‘{}‘.format(key)][i]
if cross_road_id != -1:
cross_road_information = road_information_dict[‘{}‘.format(cross_road_id)]
cross_road_information_length = cross_road_information[1]
cross_road_information_isDuplex = cross_road_information[6]
cross_road_information_from=cross_road_information[4]
cross_road_information_to=cross_road_information[5]
if cross_road_information_isDuplex == 1 :
cross_sideweight_list[i] = cross_road_information_length
if cross_road_information_from == int(key):
cross_oritation_list[i] =cross_road_information_to
else:
cross_oritation_list[i] = cross_road_information_from
else:
if cross_road_information_from == int(key):
cross_sideweight_list[i] = cross_road_information_length
cross_oritation_list[i] = cross_road_information_to
cross_sideweight_dict[‘{}‘.format(key)]=cross_sideweight_list
cross_oritation_dict[‘{}‘.format(key)]=cross_oritation_list
return cross_sideweight_dictcross_oritation_dict
def orientational_x_y_dict(road_information_dictcross_information_listcross_information_dict ):
m = []
point_site = {}
flg_cross_information_dict = copy.deepcopy(cross_information_dict)
close_flag_cross_information_dict = copy.deepcopy(cross_information_dict)
first_cross =eval(cross_information_list[0])[0]
point_site[‘{}‘.format(first_cross)] = (0 0)
close_flag_cross_information_dict[‘{}‘.format(first_cross)][0] =0
m.append(cross_information_dict[‘{}‘.format(first_cross)])
while len(m) != 0:
first_item = m.pop(0)
flg_cross_information_dict[‘{}‘.format(first_item[0])][0] = 0
for i in range(1 5)
- 上一篇:12306火车班次.zip
- 下一篇:opencv+Python的教程大全
相关资源
- opencv+Python的教程大全
- 12306火车班次.zip
- SIFT源码python实现
- python+pyqt5+百度AI+车牌识别.rar
- python pygame 自制飞机大战游戏(加入
- Python-gzipencoding如何压缩HTTP请求发送到
- Python-DeepMoji模型的pyTorch实现
- Python-京东抢购助手包含登录查询商品
- RSA_python
- 《升级》扑克牌游戏——Python实现
- python分析国家统计局数据网站本情况
- 用python绘制txt文本中中文汉字的词云
- 图像分割-snake算法 python版本
- 毕业设计压缩包.zip(基于Python飞机大
- Python-本项目基于yolo3与crnn实现中文自
- python数据分析源代码Ivan Idris
- Python项目案例开发从入门到实战源代
- Python袖珍指南_第五版高清完整版
- python火焰检测颜色模型代码
- python网络爬虫获取景点信息源码
- 用python的pyecharts模块绘制世界地图疫
- GitHack-python3.zip
- ROF图像降噪处理python程序
- 微信跳一跳资源包
- Python 数据挖掘入门与实践--代码与文
- 电力窃漏电用户自动识别 源码
- Python3.x+PyQtChart实现数据可视化界面
- python3根据模板图片批量自动制作个性
- 蚁狮算法(Ant Lion AlgorithmPython实现和
- 跳一跳辅助—用Python来玩微信跳一跳
评论
共有 条评论