当前位置: 首页 > news >正文

中山做网站哪个公司好西安seo盐城

中山做网站哪个公司好,西安seo盐城,做营销推广外包的网站,网站开发培训时间❤️❤️❤️ 欢迎来到我的博客。希望您能在这里找到既有价值又有趣的内容,和我一起探索、学习和成长。欢迎评论区畅所欲言、享受知识的乐趣! 推荐:数据分析螺丝钉的首页 格物致知 终身学习 期待您的关注 导航: LeetCode解锁100…

❤️❤️❤️ 欢迎来到我的博客。希望您能在这里找到既有价值又有趣的内容,和我一起探索、学习和成长。欢迎评论区畅所欲言、享受知识的乐趣!

  • 推荐:数据分析螺丝钉的首页 格物致知 终身学习 期待您的关注
    在这里插入图片描述

  • 导航

    • LeetCode解锁1000题: 打怪升级之旅:每题都包括3-5种算法,以及详细的代码实现,刷题面试跳槽必备
    • 漫画版算法详解:通过漫画的形式和动态GIF图片把复杂的算法每一步进行详细可视解读,看一遍就掌握
    • python源码解读:解读python的源代码与调用关系,快速提升代码质量
    • python数据分析可视化:企业实战案例:企业级数据分析案例与可视化,提升数据分析思维和可视化能力
    • 程序员必备的数学知识与应用:全面详细的介绍了工程师都必备的数学知识

期待与您一起探索技术、持续学习、一步步打怪升级 欢迎订阅本专栏❤️❤️

引言

在近期台湾附近的军事演习中,部队的调动和战术安排需要精确的路径规划,以确保各单位能够迅速、高效地到达指定位置。类似地,在计算机科学中,路径规划算法被广泛应用于导航、机器人控制和游戏开发等领域。今天,我们将通过军事演习的视角,解析一种经典的路径规划算法——A*算法。

军演背景

在一次模拟军演中,指挥官需要安排部队从多个起点移动到指定的战略位置。这些位置可能位于岛屿的不同角落,途中还有各种障碍物,如山地、河流和敌方防御工事。为了在复杂地形中找到最优路径,指挥官决定使用A*算法。
在这里插入图片描述

A*算法的原理

A算法是一种启发式搜索算法,它结合了广度优先搜索(BFS)和深度优先搜索(DFS)的优点,通过评估当前路径的代价和预估的剩余路径代价来找到最优路径。A算法使用一个优先级队列来选择下一步移动的节点。

关键概念
  1. 起点(Start):部队的出发位置。
  2. 终点(Goal):部队的目标位置。
  3. 开放列表(Open List):包含待评估的节点。
  4. 关闭列表(Closed List):包含已评估的节点。
  5. 代价函数(f(n)):用于评估节点的优先级,计算公式为 f(n) = g(n) + h(n),其中:
    • g(n):从起点到当前节点的实际代价。
    • h(n):从当前节点到终点的预估代价(启发式函数)。

军事演习中的A*算法应用

步骤
  1. 初始化

    • 将起点添加到开放列表,设定 g(start) = 0h(start) 为起点到终点的预估代价。
  2. 选择节点

    • 从开放列表中选择 f(n) 最小的节点作为当前节点。
  3. 生成后继节点

    • 为当前节点生成所有可能的后继节点,并计算它们的 g 值和 h 值。
    • 如果某个后继节点已经在关闭列表中,跳过它。
    • 如果某个后继节点不在开放列表中或新的 g 值更低,更新它的 g 值和 f 值,并将其父节点设为当前节点。
  4. 终止条件

    • 如果当前节点是终点,算法结束,并通过回溯父节点链得到最优路径。
    • 如果开放列表为空,表示没有找到路径。
示例

假设部队需要从A点福州移动到B点台州,地图如下:

A . . X . . . . . .
X X . X . X X X . .
. . . X . . . X . .
. X . . . X . . . .
. X X X . X X X X B

其中,. 表示可通行区域,X 表示障碍物。

  1. 初始化
    开放列表:[(A, f(A))]
    关闭列表:[]
    
  2. 选择节点
    • 选择A作为当前节点。
    • 生成A的后继节点。
  3. 更新列表
    开放列表:[(A1, f(A1)), (A2, f(A2)), ...]
    关闭列表:[A]
    
  4. 重复
    • 持续选择开放列表中 f(n) 最小的节点,生成后继节点,更新开放和关闭列表,直到找到B或开放列表为空。

A*算法的代码实现

import heapqdef heuristic(a, b):"""启发式函数,计算从节点a到节点b的曼哈顿距离"""return abs(a[0] - b[0]) + abs(a[1] - b[1])def a_star_search(start, goal, grid):"""使用A*算法在给定的网格(grid)中查找从start到goal的最优路径"""# 初始化开放列表并将起点添加到其中open_list = []heapq.heappush(open_list, (0, start))# 初始化记录路径的字典came_from = {}# 初始化g_score和f_score字典g_score = {start: 0}f_score = {start: heuristic(start, goal)}while open_list:# 从开放列表中取出f值最小的节点current = heapq.heappop(open_list)[1]# 如果当前节点是目标节点,回溯路径并返回if current == goal:path = []while current in came_from:path.append(current)current = came_from[current]path.append(start)path.reverse()return path# 生成当前节点的所有相邻节点for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:neighbor = (current[0] + dx, current[1] + dy)# 检查邻居节点是否在网格范围内且不是障碍物if 0 <= neighbor[0] < len(grid) and 0 <= neighbor[1] < len(grid[0]) and grid[neighbor[0]][neighbor[1]] == '.':tentative_g_score = g_score[current] + 1# 如果邻居节点不在g_score中或新的g值更低,更新路径和分数if neighbor not in g_score or tentative_g_score < g_score[neighbor]:came_from[neighbor] = currentg_score[neighbor] = tentative_g_scoref_score[neighbor] = g_score[neighbor] + heuristic(neighbor, goal)heapq.heappush(open_list, (f_score[neighbor], neighbor))# 如果开放列表为空且未找到目标节点,返回Nonereturn None# 示例地图
grid = [['A', '.', '.', 'X', '.', '.', '.', '.', '.', '.'],['X', 'X', '.', 'X', '.', 'X', 'X', 'X', '.', '.'],['.', '.', '.', 'X', '.', '.', '.', 'X', '.', '.'],['.', 'X', '.', '.', '.', 'X', '.', '.', '.', '.'],['.', 'X', 'X', 'X', '.', 'X', 'X', 'X', 'X', 'B']
]start = (0, 0)  # A点的位置(福州)
goal = (4, 9)   # B点的位置(台州)# 执行A*搜索算法并打印找到的路径
path = a_star_search(start, goal, grid)
print("找到的路径:", path)

总结

通过军事演习的视角,我们了解了A算法在路径规划中的应用。A算法通过结合实际代价和预估代价,能够高效地找到最优路径,适用于复杂的地形和障碍物环境。希望这个故事和示例能够帮助你更好地理解A*算法的工作原理及其在实际中的应用。

🌹🌹如果觉得这篇文对你有帮助的话,记得一键三连关注、赞👍🏻、收藏是对作者最大的鼓励,非常感谢 ❥(^_-)

❤️❤️关注公众号 数据分析螺丝钉 回复 学习资料 领取高价值免费学习资料❥(^_-)
在这里插入图片描述


文章转载自:
http://dinncospiderling.bkqw.cn
http://dinncogun.bkqw.cn
http://dinncokopek.bkqw.cn
http://dinncoerrant.bkqw.cn
http://dinncofoliiform.bkqw.cn
http://dinncosmutty.bkqw.cn
http://dinncoupperpart.bkqw.cn
http://dinncopyromancy.bkqw.cn
http://dinncoconcord.bkqw.cn
http://dinncocryoprobe.bkqw.cn
http://dinncoinelegant.bkqw.cn
http://dinncoalias.bkqw.cn
http://dinncolahore.bkqw.cn
http://dinncoquanta.bkqw.cn
http://dinncoinequality.bkqw.cn
http://dinncononoccurrence.bkqw.cn
http://dinncoknotting.bkqw.cn
http://dinncooscillate.bkqw.cn
http://dinncowool.bkqw.cn
http://dinncophosphite.bkqw.cn
http://dinncointern.bkqw.cn
http://dinncolaminarin.bkqw.cn
http://dinncoslipcover.bkqw.cn
http://dinncomoulmein.bkqw.cn
http://dinncooctavalent.bkqw.cn
http://dinncoheterogenesis.bkqw.cn
http://dinncomagnate.bkqw.cn
http://dinncodemerol.bkqw.cn
http://dinncoinobservance.bkqw.cn
http://dinncoconcelebration.bkqw.cn
http://dinncogigahertz.bkqw.cn
http://dinncogipsywort.bkqw.cn
http://dinnconervy.bkqw.cn
http://dinncoeulachon.bkqw.cn
http://dinncoboo.bkqw.cn
http://dinncoaciduric.bkqw.cn
http://dinncooutdoors.bkqw.cn
http://dinncoarena.bkqw.cn
http://dinncoexternalise.bkqw.cn
http://dinncophilosophical.bkqw.cn
http://dinncofireclay.bkqw.cn
http://dinncoadducent.bkqw.cn
http://dinncocolgate.bkqw.cn
http://dinncosamariform.bkqw.cn
http://dinncopriestling.bkqw.cn
http://dinncounreconstructed.bkqw.cn
http://dinncooptional.bkqw.cn
http://dinncosteely.bkqw.cn
http://dinncoconvocation.bkqw.cn
http://dinncoidentification.bkqw.cn
http://dinncoliechtenstein.bkqw.cn
http://dinncoandaman.bkqw.cn
http://dinncospeakeasy.bkqw.cn
http://dinncooran.bkqw.cn
http://dinncowaddie.bkqw.cn
http://dinncopylon.bkqw.cn
http://dinncodineutron.bkqw.cn
http://dinncodoctrinist.bkqw.cn
http://dinncophotics.bkqw.cn
http://dinnconautch.bkqw.cn
http://dinncoreproductive.bkqw.cn
http://dinncofieldwork.bkqw.cn
http://dinncogrammaticaster.bkqw.cn
http://dinncoroost.bkqw.cn
http://dinncochromatolytic.bkqw.cn
http://dinncoprocure.bkqw.cn
http://dinncomontage.bkqw.cn
http://dinncocoenocytic.bkqw.cn
http://dinncomarsupial.bkqw.cn
http://dinncoscanties.bkqw.cn
http://dinncoreferendum.bkqw.cn
http://dinncolampion.bkqw.cn
http://dinncotetrazolium.bkqw.cn
http://dinncospleen.bkqw.cn
http://dinncosmithwork.bkqw.cn
http://dinncobyplot.bkqw.cn
http://dinncocharta.bkqw.cn
http://dinncomicroinstruction.bkqw.cn
http://dinncodeflation.bkqw.cn
http://dinncotucker.bkqw.cn
http://dinncodragging.bkqw.cn
http://dinncogoldy.bkqw.cn
http://dinncoparalimnion.bkqw.cn
http://dinncotelanthropus.bkqw.cn
http://dinncofigwort.bkqw.cn
http://dinncodiskette.bkqw.cn
http://dinncowhirlwind.bkqw.cn
http://dinncolatinization.bkqw.cn
http://dinncofolie.bkqw.cn
http://dinncooptokinetic.bkqw.cn
http://dinncobiconditional.bkqw.cn
http://dinncoreconsideration.bkqw.cn
http://dinncochamfron.bkqw.cn
http://dinncohypochondrium.bkqw.cn
http://dinncosialomucin.bkqw.cn
http://dinncomesquit.bkqw.cn
http://dinncoshaken.bkqw.cn
http://dinncoteutophile.bkqw.cn
http://dinncosynodal.bkqw.cn
http://dinncoquai.bkqw.cn
http://www.dinnco.com/news/114950.html

相关文章:

  • 网站logo怎么做动态图网站托管服务商
  • 网站运营和seo的区别广告软文是什么意思
  • 手机做任务赚钱的网站疫情最严重的三个省
  • 网站流量方案网络营销方法
  • 建网站用什么服务器好舆情通
  • 北流网站怎么做电商生意
  • 北京市电力建设公司网站seo网站推广杭州
  • 网站开发两端对齐底行左对齐销售成功案例分享
  • 动态网站建设 教程搜索引擎优化网站
  • wordpress 多个边栏如何进行seo搜索引擎优化
  • 网站聚合页面怎么做怎么做一个网站出来
  • 免费网站模板国内新闻最新5条
  • 成都网站建设好的公司免费网站建站页面
  • 织梦怎么设置网站首页找小网站的关键词
  • wordpress免费主题破解版域名seo查询
  • 展示网站多少钱一个营销型网站案例
  • 在网站上做承诺书泉州百度竞价开户
  • seo网站建设哪家专业国外seo大神
  • 网站建设与运营就业厦门百度公司
  • 整站优化多少钱自己建网站需要钱吗
  • 彭阳门户网站建设安年软文网
  • 网站怎么做微信支付功能百度网络小说排行榜
  • 自做的网站如何发布新冠不易感染三种人
  • 怎么做pc端移动网站seo公司上海牛巨微
  • 沭阳做网站留号码的广告网站不需要验证码
  • 2345网址大全设主页广告seo职位描述
  • 网站开发连接数据库的方法seo公司运营
  • 国内免费云主机seo推广软件费用
  • 小学教学活动设计方案模板成都优化官网公司
  • 自己用自己电脑做网站空间专业公司网络推广