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

大良建网站seo长尾关键词排名

大良建网站,seo长尾关键词排名,2023年合肥市最新疫情,网站开发招商计划书戴克斯特拉算法(英语:Dijkstras algorithm),又称迪杰斯特拉算法、Dijkstra算法,是由荷兰计算机科学家艾兹赫尔戴克斯特拉在1956年发现的算法。 算法过程: 1.首先设置开始节点的成本值为0,并将…

戴克斯特拉算法(英语:Dijkstra's algorithm),又称迪杰斯特拉算法、Dijkstra算法,是由荷兰计算机科学家艾兹赫尔·戴克斯特拉在1956年发现的算法。

算法过程:

1.首先设置开始节点的成本值为0,并将开始节点放入检测列表中。

2.将检测列表中的所有点按到目标点所需的成本值排序,选择成本最小的节点作为当前节点,并将其移出检测列表。

3.将当前点周围的点中不包含在检测列表中的点加入到检测列表,将周围点加入到已检测列表中。

4.更新检测列表中的节点到当前节点的成本值。

5.重复2,3,4直到找到目标点。

代码实现:

public class Dijkstra : FindPathAlgorithm
{public Dijkstra(int[,] mapData, int xCount, int zCount) : base(mapData, xCount, zCount){}public override List<Vector2Int> FindPath(Vector2Int startPos, Vector2Int goalPos){DataNode dataNode = this.DijkstraFind(startPos, goalPos);if (dataNode == null){Debug.LogError("寻路有误,请检查参数是否正确");return null;}return Utils.GetPath(dataNode);}DataNode DijkstraFind(Vector2Int startPos, Vector2Int goalPos){//存储要检测的点List<DataNode> frontier = new List<DataNode>();//存储已经检测的点List<Vector2Int> reached = new List<Vector2Int>();DataNode startNode = new DataNode(startPos, null);startNode.gCost = 0;frontier.Add(startNode);reached.Add(startPos);while (frontier.Count > 0){DataNode currentNode = GetLowestgCostNode(frontier);frontier.Remove(currentNode);if (currentNode.pos == goalPos){Debug.Log("完成!!!");return new DataNode(goalPos, currentNode.parent);}List<DataNode> neighbors = GetNeighbors(currentNode.pos, reached);foreach (DataNode neighbourNode in neighbors){if (!frontier.Contains(neighbourNode)){neighbourNode.parent = currentNode;frontier.Add(neighbourNode);}reached.Add(neighbourNode.pos);}this.UpdateCost(frontier, currentNode);}return null;}//更新成本值void UpdateCost(List<DataNode> nodes, DataNode currentNode){for (int i = 0; i < nodes.Count; i++){int newCost = currentNode.gCost + CalculateDistanceCost(nodes[i].pos, currentNode.pos);if (nodes[i].gCost > newCost){nodes[i].gCost = newCost;}}}List<DataNode> GetNeighbors(Vector2Int current, List<Vector2Int> reached){List<DataNode> neighbors = new List<DataNode>();for (int i = 0; i < Utils.pointDir.Count; i++){Vector2Int neighbor = current + Utils.pointDir[i];if (this.IsCanAdd(neighbor, reached)){neighbors.Add(new DataNode(neighbor, null));}}return neighbors;}bool IsCanAdd(Vector2Int current, List<Vector2Int> reached){if (reached.Contains(current))return false;if (current.x >= 0 && current.y >= 0 && current.x < MapData.m_MapData.GetLength(1) && current.y < MapData.m_MapData.GetLength(0)){//如果是障碍物,则不能被Addif (MapData.m_MapData[current.y, current.x] == 1){return false;}return true;}return false;}private int CalculateDistanceCost(Vector2Int a, Vector2Int b){return Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y);}private DataNode GetLowestgCostNode(List<DataNode> pathNodeList){DataNode lowestFCostNode = pathNodeList[0];for (int i = 1; i < pathNodeList.Count; i++){if (pathNodeList[i].gCost < lowestFCostNode.gCost){lowestFCostNode = pathNodeList[i];}}return lowestFCostNode;}
}

结果:

参考链接:

Pathfinding in Unity - Part3: Dijkstra Algorithm Theory (youtube.com)

Pathfinding in Unity - Part4: Dijkstra Algorithm Implementation (youtube.com)

How Dijkstra's Algorithm Works (youtube.com)

戴克斯特拉算法 - 维基百科,自由的百科全书 (wikipedia.org)

http://www.tj-hxxt.cn/news/8448.html

相关文章:

  • 做网站 长免费b2b推广网站
  • 长春一般做一个网站需要多少钱厦门人才网app
  • 中央农村工作会议2022广告优化师适合女生吗
  • 苏州网站建设主页广告投放平台都有哪些
  • 网站建设与网页设计2020 惠州seo服务
  • 京东联盟怎么做CMS网站网络营销管理名词解释
  • 织梦做分销网站东莞疫情最新情况
  • 如何创建一个网站卖东西上海网站营销seo方案
  • 南阳做网站的公百度怎么收录网站
  • 深圳易捷网站建设软文范文大全
  • 吉林市教做网站北京网站优化实战
  • 大丰建站电商关键词查询工具
  • 徐州网站公司色盲眼镜
  • 手机网站要素百度网盘登录
  • 天津做网站的企业2022年最新最有效的营销模式
  • 如何java做网站北京seo技术交流
  • 网站建设中的数据库规划seo收费标准
  • 做商城网站买多大的空间seo查询排名软件
  • 梅州建站规划推广平台排行榜有哪些
  • 怎么将html代码放到wordpress武汉本地seo
  • 网站新手引导怎么做百度推广怎么优化
  • 平面设计师必看的网站东莞市民最新疫情
  • php如何做动态网站建设杭州seo教程
  • 泰安 网站建设公司营销型网站策划
  • 企业网站建设实训建议百度指数搜索指数的数据来源
  • 网站建设之后需要维护吗iis7站长工具
  • 小说网站开发现在做推广的新渠道有哪些
  • 湖南网站建站系统平台网络营销和网络推广
  • 橙云网站建设谷歌官方网站登录入口
  • 4000万中小企业网站建设 不足10% 美国 80%百度推广方案