i implemented simple a* , noticed infity loop if 4 spots around character filled. current stuck how work start running nearest possible spot. guesses on it? (sorry long code) the a* private node astarsearch(int startx, int starty) { openlist.clear(); closelist.clear(); successor.clear(); node startnode = new node(null, startx, starty, 0, 0); openlist.add(startnode); while (openlist.size() != 0) { // sort list collections.sort(openlist, nodecomperator); node q = openlist.remove(0); // first object int qx = q.x; int qy = q.y; // start adding successors // left node left = createneighbor(q, qx - 1, qy); if (left != null && !closelist.contains(left)) successor.add(left); // right node right = createneighbor(q, qx + 1, qy); if (right != null && !closelist.conta...
Comments
Post a Comment