本文整理汇总了C#中PriorityQueue.contains方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.contains方法的具体用法?C# PriorityQueue.contains怎么用?C# PriorityQueue.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AStarSearch
/// <summary>
/// Performs A* search to find optimal path between two tiles.
/// </summary>
/// <returns>
/// The star search.
/// </returns>
/// <param name='start'>
/// Start.
/// </param>
/// <param name='finish'>
/// Finish.
/// </param>
protected List<HexTile> AStarSearch(SearchNode start, SearchNode finish)
{
// Openlist
PriorityQueue openList = new PriorityQueue();
// Closed List
List<SearchNode> closedList = new List<SearchNode>();
// Add initial node
openList.enqueue(start);
List<HexTile> path = new List<HexTile>();
// Go till there is nothing on openlist
while(openList.Count>0){
//Debug.Log(openList);
//openList.printQueue();
SearchNode head = openList.dequeue();
//Debug.Log(head.Tile.Location);
if(head.Tile == finish.Tile){
path = generatePath(head);
break;
}
else if(head.Tile.CanMove){
List<HexTile> neighbors = getNeighbors(head.Tile);
foreach(HexTile t in neighbors){
SearchNode s = generateSearchNode(t, finish.Tile, head.Cost + 1, head);
if(openList.contains(s)){
SearchNode oldNode = openList.get(s);
updateNode(s, oldNode);
}
else if(containsNode(closedList, s) == null){
openList.enqueue(s);
}
}
}
closedList.Add(head);
}
//_fact.returnNodes(openList);
//_fact.returnNodes(closedList);
return path;
}