Exemple #1
0
        public void deleteNode(CircleNode n)
        {
            CircleNode parent = n.getParent();

            parent.removeEdge(n);
            this._nodes.Remove(n);
        }
        public override Boolean validate(CircleNode newnode, CircleNode oldnode, InfoDomain domain, Graph graph)
        {
            State newstate = newnode.getState();
            State oldstate = oldnode.getState();

            if (outsideOfMap(newstate))
            {
                return(false);
            }
            else
            {
                if (isVerticalMovement(oldstate, newstate) || newstate.getAction() == 2)
                {
                    if (thereIsWallBetweenV(newstate, oldstate, domain))
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    if (thereIsWallBetweenH(newstate, oldstate, domain))
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
        }
Exemple #3
0
        public void addEdge(CircleNode child, int action)
        {
            CircleEdge newEdge = new CircleEdge(this, child, action);

            newEdge.setBusy();
            this._edges.Add(newEdge);
            child.setParent(this);
        }
Exemple #4
0
        public Graph(State inicial, CircleNode n)
        {
            this._nodes        = new ArrayList();
            this._nonBusyNodes = new ArrayList();
            CircleNode initialNode = new CircleNode(inicial);

            this._nodes.Add(initialNode);
            this._nonBusyNodes.Add(initialNode);
            this._rnd = new Random();
        }
Exemple #5
0
 public bool isConnected(CircleNode n)
 {
     foreach (CircleEdge i in this._edges)
     {
         if (i.getChild().Equals(n))                     // Might need implementation of Equals in order to guarantee functionality
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
 public void removeEdge(CircleNode child)
 {
     foreach (CircleEdge i in this._edges)
     {
         if (i.getChild().Equals(child))
         {
             this._edges.Remove(i);
             return;
         }
     }
 }
Exemple #7
0
 public void addNode(CircleNode childNode, CircleNode parent, int action)
 {
     if (this.getSize() == 0)
     {
         this._nodes.Add(parent);
     }
     this._nodes.Add(childNode);
     parent.addEdge(childNode, action);
     childNode.setParent(parent);
     _nonBusyNodes.Add(childNode);
 }
Exemple #8
0
 public CircleNode(State s)
 {
     this._edges       = new ArrayList();
     this._parent      = null;
     this._state       = s;
     this._busyActions = new bool[5];
     _busyActions[0]   = false;
     _busyActions[1]   = false;
     _busyActions[2]   = false;
     _busyActions[3]   = false;
     _busyActions[4]   = true;
 }
Exemple #9
0
 public CircleNode getRandomNode(CircleNode n)
 {
     // Infinite loop if all Nodes have all their actions explored
     if (this._nonBusyNodes.Count > 0)
     {
         return((CircleNode)this._nonBusyNodes[this.getRandomNumber(this._nonBusyNodes.Count)]);
     }
     else
     {
         return(null);
     }
 }
Exemple #10
0
        public void rollBack(CircleNode n)
        {
            CircleNode a = n;

            while (a.isBusy())
            {
                CircleNode parent = a.getParent();
                this.deleteNode(a);
                a = parent;
            }
            return;
        }
Exemple #11
0
        private Path recursiveTraceBack(CircleNode goalNode, Path l)
        {
            if (goalNode.getParent() == null)
            {
                l.AddNewPoint(goalNode.getState().point);
                return(l);
            }
            else
            {
                this.recursiveTraceBack(goalNode.getParent(), l);
                l.AddNewPoint(goalNode.getState().point);
                if (goalNode.getParent().getParent() != null)
                {
                    if (goalNode.getParent().getState().getVelocityX() != goalNode.getState().getVelocityX() && goalNode.getParent().getState().getPosY() >= goalNode.getState().getPosY())
                    {
                        goalNode.getParent().getState().point.TurningPoint = true;
                    }
                }

                return(l);
            }
        }
Exemple #12
0
 abstract public CircleNode apply(CircleNode Xinit, InfoDomain _domain, Graph graph);
Exemple #13
0
 public void setParent(CircleNode p)
 {
     this._parent = p;
 }
Exemple #14
0
        public Path traceBack(CircleNode goalNode)
        {
            Path l = new Path();

            return(recursiveTraceBack(goalNode, l));
        }
 public override Boolean validate(CircleNode newnode, CircleNode oldnode, InfoDomain domain, Graph graph)
 {
     return(false);
 }
Exemple #16
0
 abstract public Boolean validate(CircleNode newnode, CircleNode oldnode, InfoDomain domain, Graph graph);
Exemple #17
0
 public override CircleNode apply(CircleNode Xinit, InfoDomain _domain, Graph graph)
 {
     return(null);
 }