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

顺德高端网站设计seo是什么东西

顺德高端网站设计,seo是什么东西,企业建站系统免费,宁波网站推广戴克斯特拉算法(英语: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.hkea.cn/news/2060/

相关文章:

  • layui 网站建设模板百度网址链接是多少
  • 娄底网站建设的话术网站建设是什么
  • 有没有免费的crm系统武汉百度搜索优化
  • 怎样做的英文网站技术教程优化搜索引擎整站
  • 03340 网站建设与管理百度seo白皮书
  • oa网站建设价格百度互联网营销
  • 软件开发最强的公司湖南 seo
  • 手机访问不了自己做的网站吗网络营销推广服务商
  • 专注合肥网站建设整合营销传播的方法包括
  • 项目外包公司可以去吗揭阳seo推广公司
  • 徐州网站设计师产品市场推广计划书
  • 如何修改asp网站广告投放都有哪些平台
  • 网站开发公司介绍产品网络推广方式
  • 公安部网站备案 流程微信小程序
  • 优化方案2021版语文答案江门seo网站推广
  • 如何建立一个网站要多少钱独立站seo搜索优化
  • 石家庄红酒公司 网站建设搜索引擎营销经典案例
  • 网站开发市场价网站seo李守洪排名大师
  • 做整装的网站拼多多关键词优化是怎么弄的
  • 做导航网站把别人的网址链接过来要经过允许吗安卓手机优化神器
  • 泰安哪家做网站好海外推广渠道都有哪些
  • 网站的做代理商b站视频推广网站400
  • 做网站需要什么系统渠道策略的四种方式
  • 网站倒计时百度一下你就知道
  • 品牌网站建设精湛磐石网络线上培训
  • 做外贸英文网站seo需要掌握什么技能
  • 做二手房又做网站的网络优化工程师是做什么的
  • 北京的网页建设公司seo优化效果怎么样
  • 做网站要用到什么软件如何在百度上做推广
  • wordpress 企业版网络推广seo怎么弄