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

            parent.removeEdge(n);
            this._nodes.Remove(n);
        }
예제 #2
0
        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);
                    }
                }
            }
        }
예제 #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);
        }
예제 #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();
        }
예제 #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);
 }
예제 #6
0
 public void removeEdge(CircleNode child)
 {
     foreach (CircleEdge i in this._edges)
     {
         if (i.getChild().Equals(child))
         {
             this._edges.Remove(i);
             return;
         }
     }
 }
예제 #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);
 }
예제 #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;
 }
예제 #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);
     }
 }
예제 #10
0
        public void rollBack(CircleNode n)
        {
            CircleNode a = n;

            while (a.isBusy())
            {
                CircleNode parent = a.getParent();
                this.deleteNode(a);
                a = parent;
            }
            return;
        }
예제 #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);
            }
        }
예제 #12
0
 abstract public CircleNode apply(CircleNode Xinit, InfoDomain _domain, Graph graph);
예제 #13
0
 public void setParent(CircleNode p)
 {
     this._parent = p;
 }
예제 #14
0
        public Path traceBack(CircleNode goalNode)
        {
            Path l = new Path();

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