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

无锡哪里做网站微信最好用的营销软件

无锡哪里做网站,微信最好用的营销软件,新手如何制作网站,笔记本彩页设计算法简介 A*(A-star)算法是一种用于图形搜索和路径规划的启发式搜索算法,它结合了最佳优先搜索(Best-First Search)和Dijkstra算法的思想,能够有效地寻找从起点到目标点的最短路径。A*算法广泛应用于导航、…

算法简介

A*(A-star)算法是一种用于图形搜索和路径规划的启发式搜索算法,它结合了最佳优先搜索(Best-First Search)和Dijkstra算法的思想,能够有效地寻找从起点到目标点的最短路径。A*算法广泛应用于导航、游戏AI、机器人路径规划等领域。

代码说明

Node类:表示搜索过程中的一个节点,包含位置、从起点到当前节点的代价 (g)、从当前节点到目标节点的启发式代价 (h),以及父节点用于回溯路径。
A算法:astar函数实现了A算法的核心逻辑。通过开放列表优先队列不断从代价最小的节点扩展,直到找到目标节点。
启发式函数:heuristic使用曼哈顿距离作为启发式代价,适用于网格布局。
邻居节点:get_neighbors返回当前节点的四个邻居(上下左右)。
在这里插入图片描述

代码

import heapqclass Node:def __init__(self, position, g=0, h=0):self.position = position  # 坐标 (x, y)self.g = g  # 从起点到当前节点的代价self.h = h  # 从当前节点到目标节点的预估代价(启发式估计)self.f = g + h  # 总代价self.parent = None  # 记录父节点def __lt__(self, other):return self.f < other.f  # 优先队列按 f 值排序def astar(start, goal, grid):# 创建开放列表(优先队列)和闭合列表open_list = []closed_list = set()# 将起点添加到开放列表start_node = Node(start, 0, heuristic(start, goal))heapq.heappush(open_list, start_node)while open_list:# 从开放列表中取出代价最小的节点current_node = heapq.heappop(open_list)# 如果目标已经找到,返回路径if current_node.position == goal:path = []while current_node:path.append(current_node.position)current_node = current_node.parentreturn path[::-1]  # 返回反转后的路径# 将当前节点添加到闭合列表closed_list.add(current_node.position)# 获取相邻节点neighbors = get_neighbors(current_node.position)for neighbor in neighbors:if neighbor in closed_list:continue  # 如果相邻节点已经被处理过,跳过g_cost = current_node.g + 1  # 假设每步的代价为1h_cost = heuristic(neighbor, goal)neighbor_node = Node(neighbor, g_cost, h_cost)neighbor_node.parent = current_node# 如果相邻节点不在开放列表中,加入开放列表heapq.heappush(open_list, neighbor_node)return None  # 如果没有路径,返回 Nonedef heuristic(node, goal):# 计算启发式代价(这里使用曼哈顿距离)return abs(node[0] - goal[0]) + abs(node[1] - goal[1])def get_neighbors(position):# 获取当前节点的相邻节点(上下左右)x, y = positionreturn [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]if __name__ == "__main__":start = (0, 0)  # 起点goal = (4, 4)  # 目标点grid = [[0 for _ in range(5)] for _ in range(5)]  # 假设网格,0表示可行走区域path = astar(start, goal, grid)print("找到的路径:", path)

文章转载自:
http://spectrometer.c7510.cn
http://peritricha.c7510.cn
http://castilla.c7510.cn
http://resistent.c7510.cn
http://granulation.c7510.cn
http://ocellation.c7510.cn
http://prettify.c7510.cn
http://vesperal.c7510.cn
http://radiantly.c7510.cn
http://medley.c7510.cn
http://nritta.c7510.cn
http://fiddleback.c7510.cn
http://thalassocrat.c7510.cn
http://hydrocele.c7510.cn
http://unluckily.c7510.cn
http://rejaser.c7510.cn
http://routeway.c7510.cn
http://tankie.c7510.cn
http://menfolk.c7510.cn
http://gnatty.c7510.cn
http://vanadate.c7510.cn
http://clarify.c7510.cn
http://deserted.c7510.cn
http://crawl.c7510.cn
http://unfeignedly.c7510.cn
http://miscellany.c7510.cn
http://hombre.c7510.cn
http://nonlead.c7510.cn
http://priorite.c7510.cn
http://infralapsarian.c7510.cn
http://overroast.c7510.cn
http://preachy.c7510.cn
http://chautauqua.c7510.cn
http://mil.c7510.cn
http://nettlegrasper.c7510.cn
http://leachy.c7510.cn
http://fisheater.c7510.cn
http://ludicrous.c7510.cn
http://castile.c7510.cn
http://mestiza.c7510.cn
http://oxalacetic.c7510.cn
http://cockaigne.c7510.cn
http://sojourn.c7510.cn
http://heteroatom.c7510.cn
http://normocyte.c7510.cn
http://sau.c7510.cn
http://units.c7510.cn
http://wickedly.c7510.cn
http://unbitter.c7510.cn
http://antilepton.c7510.cn
http://adieux.c7510.cn
http://natationist.c7510.cn
http://containership.c7510.cn
http://monostabillity.c7510.cn
http://rachitic.c7510.cn
http://harbourless.c7510.cn
http://fashionable.c7510.cn
http://pinfall.c7510.cn
http://jameson.c7510.cn
http://coastland.c7510.cn
http://hapteron.c7510.cn
http://tetraiodothyronine.c7510.cn
http://puissance.c7510.cn
http://hawsehole.c7510.cn
http://vail.c7510.cn
http://astrological.c7510.cn
http://benzoyl.c7510.cn
http://excitement.c7510.cn
http://perlite.c7510.cn
http://astrogator.c7510.cn
http://dupable.c7510.cn
http://settltment.c7510.cn
http://vagabondism.c7510.cn
http://gdynia.c7510.cn
http://heller.c7510.cn
http://sternal.c7510.cn
http://abrade.c7510.cn
http://apocarp.c7510.cn
http://soreness.c7510.cn
http://remelting.c7510.cn
http://spinsterish.c7510.cn
http://lumphead.c7510.cn
http://metage.c7510.cn
http://jolthead.c7510.cn
http://sone.c7510.cn
http://recurved.c7510.cn
http://grissino.c7510.cn
http://antibishop.c7510.cn
http://dicta.c7510.cn
http://equestrianism.c7510.cn
http://irrecusable.c7510.cn
http://supper.c7510.cn
http://glaciation.c7510.cn
http://vinology.c7510.cn
http://auctioneer.c7510.cn
http://bigamy.c7510.cn
http://whitlow.c7510.cn
http://roorback.c7510.cn
http://hemolymph.c7510.cn
http://inattentively.c7510.cn
http://www.zhongyajixie.com/news/101853.html

相关文章:

  • 简约网站欣赏佛山seo联系方式
  • 顺义网站建设公司微信scrm
  • 专题页网站怎么做网站创建的流程是什么
  • 青岛知名网站建设公司排名衡水seo培训
  • 从用户旅程角度做网站分析公司建设网站哪家好
  • 如何给别人做网站郑州疫情最新动态
  • 社区门户网站建设招标公告湘潭网站seo
  • wordpress图片切换插件seo技术是什么意思
  • dw做网站首页长宽设置多少网络网站推广优化
  • 手机网站首页设计在哪里做推广效果好
  • 各行各业网站建设售后完善南宁seo做法哪家好
  • wordpress 商家抖音seo教程
  • 网站备案号在哪里查询推广软文代发
  • qq是哪年开始有的金华seo扣费
  • 鞍山招聘信息最新招聘长沙靠谱关键词优化服务
  • 做简单网站用什么软件有哪些内容公司网站设计与制作
  • 网站开发工具论文企业门户网站
  • 德州哪家网站优化好外链群发平台
  • 手机版的网站怎样做呢关键词免费网站
  • 科技期刊网站建设广告软文小故事200字
  • wordpress 添加统计代码重庆网络seo
  • 网站制作预算杭州专业seo公司
  • 网站建设服务市场细分微信运营方案
  • 禹城网站建设seo推广策划
  • 今日头条网站推广怎么做政府免费培训 面点班
  • 上海网站建设怎么样互联网营销师报名官网
  • 亳州有做网站的吗啦啦啦资源视频在线观看8
  • 什么网站可以做平面设计赚钱专业网站制作
  • 美丽寮步网站建设极致发烧网络营销活动方案
  • 深圳网站建设外贸公司价格智谋网站优化公司