Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 跳转点搜索结果不正确_C#_Algorithm_Path Finding - Fatal编程技术网

C# 跳转点搜索结果不正确

C# 跳转点搜索结果不正确,c#,algorithm,path-finding,C#,Algorithm,Path Finding,在我完成了如何进行a*寻路之后,我想学习更多关于跳转点搜索的知识。 我研究了一下如何通过阅读 关于它 所以在读了几遍之后,我自己尝试了一下,所以我做了一个,但效果很差。 所以问题是他能找到一条路,但不是用最好的方式来理解我的意思 所以我的第一个想法是,我做了一些错误的最低成本,所以尝试改变第一,但这不是答案。然后我研究了Sucessor函数,如果我做错了什么,尝试更改脚本的顺序,但结果保持不变。 之后,我研究了跳转代码。但老实说,我也不知道我做错了什么 然后我试着在这里找到答案,但是,大多数

在我完成了如何进行a*寻路之后,我想学习更多关于跳转点搜索的知识。 我研究了一下如何通过阅读 关于它

所以在读了几遍之后,我自己尝试了一下,所以我做了一个,但效果很差。 所以问题是他能找到一条路,但不是用最好的方式来理解我的意思

所以我的第一个想法是,我做了一些错误的最低成本,所以尝试改变第一,但这不是答案。然后我研究了Sucessor函数,如果我做错了什么,尝试更改脚本的顺序,但结果保持不变。 之后,我研究了跳转代码。但老实说,我也不知道我做错了什么

然后我试着在这里找到答案,但是,大多数答案都是相同的结果

也许我忘记了这个算法需要的东西

成功者功能

    List<Node> IDSucessor(Node currentNode,Node start,Node goal)
{
    List<Node> sucessors = new List<Node>();
    List<Node> neighbors = new List<Node>();
    neighbors = Neigbors(currentNode);
    foreach (Node n in neighbors)
    {
        Node node = n;
        node = Jump(currentNode, n.x - currentNode.x, n.y - currentNode.y, start, goal);
        if (node != null)
        {
            if (!closedList.Contains(node))
            {
                int newMovementCost = (int)currentNode.GCost + GetDistance(currentNode, n);
                if (newMovementCost < node.GCost || !openList.Contains(node))
                {
                    node.GCost = newMovementCost;
                    node.HCost = GetDistance(n, goal);
                    node.FCost = n.GCost + n.HCost;
                    node.parent = currentNode;
                    if (!openList.Contains(node))
                    {
                        sucessors.Add(node);
                    }
                }
            }
        }
    }
    return sucessors;
}
 bool IsForcedHor(Node currentNode,int dirX)
{
    Node up = RetunNodeDir(currentNode, 0,  1);
    Node down = RetunNodeDir(currentNode, 0,  - 1);
    if(up!=null)
    {
        if(up.Col)
        {
            //check next to him.
            Node upNext = RetunNodeDir(currentNode, dirX,  1);
            if(upNext!=null)
            {
                if(!upNext.Col)
                {
                    return true;
                }
            }
        }
    }
    if(down!=null)
    {
        if(down.Col)
        {
            Node downNext = RetunNodeDir(currentNode, dirX, - 1);
            if (downNext != null)
            {
                if (!downNext.Col)
                {
                    return true;
                }
            }
        }
    }
    return false;
}
强制节点水平。垂直方向代码相同,但协调方向不同。diangle也使用相同的代码,但它需要在函数中添加额外的内存

    List<Node> IDSucessor(Node currentNode,Node start,Node goal)
{
    List<Node> sucessors = new List<Node>();
    List<Node> neighbors = new List<Node>();
    neighbors = Neigbors(currentNode);
    foreach (Node n in neighbors)
    {
        Node node = n;
        node = Jump(currentNode, n.x - currentNode.x, n.y - currentNode.y, start, goal);
        if (node != null)
        {
            if (!closedList.Contains(node))
            {
                int newMovementCost = (int)currentNode.GCost + GetDistance(currentNode, n);
                if (newMovementCost < node.GCost || !openList.Contains(node))
                {
                    node.GCost = newMovementCost;
                    node.HCost = GetDistance(n, goal);
                    node.FCost = n.GCost + n.HCost;
                    node.parent = currentNode;
                    if (!openList.Contains(node))
                    {
                        sucessors.Add(node);
                    }
                }
            }
        }
    }
    return sucessors;
}
 bool IsForcedHor(Node currentNode,int dirX)
{
    Node up = RetunNodeDir(currentNode, 0,  1);
    Node down = RetunNodeDir(currentNode, 0,  - 1);
    if(up!=null)
    {
        if(up.Col)
        {
            //check next to him.
            Node upNext = RetunNodeDir(currentNode, dirX,  1);
            if(upNext!=null)
            {
                if(!upNext.Col)
                {
                    return true;
                }
            }
        }
    }
    if(down!=null)
    {
        if(down.Col)
        {
            Node downNext = RetunNodeDir(currentNode, dirX, - 1);
            if (downNext != null)
            {
                if (!downNext.Col)
                {
                    return true;
                }
            }
        }
    }
    return false;
}
我希望我给了你足够的信息

亲切问候,, 编码