Implementing a wall in get successor for A*

84 views Asked by At

I have a get successor function C# which get the successor for Nodes in a grid

public ArrayList GetSuccessors()
    {
        ArrayList successors = new ArrayList ();

        for (int xd=-1;xd<=1;xd++)
        {
            for (int yd=-1;yd<=1;yd++)
            {
                if ((xd != 0 && yd == 0) || (xd == 0 && yd != 0)) // to take only up - down - right - left
                {

                    if (Map.getMap(x + xd, y + yd) != -1)
                    {
                            // generate a new node where the parent node is the existance, goal node, cost , x , y
                            Node n = new Node(this, this._goalNode, Map.getMap(x + xd, y + yd), x + xd, y + yd);

                            // to elemenat duplication 
                            if (!n.isMatch(this.parentNode) && !n.isMatch(this))
                                successors.Add(n);

                    }
                }
            }
        }
        return successors;
    }

for getMap function it's just return if the value inside the map 1 or -1 if it's 1 then I take this node if it's -1 then No it's an obstacles.

My question is how I can implement a condition so that if there is a wall between [0,0] and [0,1] in the grid don't take [0,1] as a successor for [0,0]

thank you

0

There are 0 answers