public Path run() { Graph graph = new Graph(_xinit, new RectangleNode()); //Boolean busy = false; RectangleNode node = null; RectangleNode newnode = null; bestSoFar = graph.getRandomNode(node); for (int iter = 0; iter < _maxiter; iter++) { //if (busy) // node = newnode; //else node = graph.getRandomNode(node); if (node == null) { return(minimizePath(graph.traceBack(bestSoFar))); } newnode = _tactics.apply(node, _domain, graph); //or only node? if (newnode == null) { continue; } //busy = newnode.isBusy(); if (_validator.validate(newnode, node, _domain, graph)) { graph.addNode(newnode, node, newnode.getState().getAction()); if (newnode.getState().numberOfCollectibles() < bestSoFar.getState().numberOfCollectibles()) { bestSoFar = newnode; } // GOAL ACHIEVED if (newnode.getState().numberOfCollectibles() == 0) { return(minimizePath(graph.traceBack(newnode))); } } //else //{ // //busy = node.isBusy(); // //if (busy) // // graph.rollBack(node); // //busy = false; // if (node.isBusy()) // graph.rollBack(node); //} } return(minimizePath(graph.traceBack(bestSoFar))); }