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); } } } }
public void addEdge(CircleNode child, int action) { CircleEdge newEdge = new CircleEdge(this, child, action); newEdge.setBusy(); this._edges.Add(newEdge); child.setParent(this); }
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(); }
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); }
public void removeEdge(CircleNode child) { foreach (CircleEdge i in this._edges) { if (i.getChild().Equals(child)) { this._edges.Remove(i); return; } } }
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); }
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; }
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); } }
public void rollBack(CircleNode n) { CircleNode a = n; while (a.isBusy()) { CircleNode parent = a.getParent(); this.deleteNode(a); a = parent; } return; }
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); } }
abstract public CircleNode apply(CircleNode Xinit, InfoDomain _domain, Graph graph);
public void setParent(CircleNode p) { this._parent = p; }
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); }
abstract public Boolean validate(CircleNode newnode, CircleNode oldnode, InfoDomain domain, Graph graph);
public override CircleNode apply(CircleNode Xinit, InfoDomain _domain, Graph graph) { return(null); }