Jump to content

FrostBug

Scripter III
  • Posts

    3967
  • Joined

  • Last visited

  • Days Won

    5
  • Feedback

    100%

Everything posted by FrostBug

  1. :L nice This is a neat tool to play around with. it really shows the difference in efficiency http://qiao.github.io/PathFinding.js/visual/ What you had initially somewhat resembled a Depth First Search (DFS). Those are usually good for tree spanning. Unfortunatly that tool can't demonstrate DFS good luck with it
  2. Sounds good :E, since OSBot kinda does need this Id recommend using java's PriorityQueue, it will automatically sort whatever you push into it by comparing. Which means that if you have your WalkingNode implement the Comparable interface, and have it compare their accumulated distances from the starting point, when popping a node from the queue, it will always be the node with the least distance from the starting point. Add a heuristic ontop of that (accumulated distance from start node + estimated distance to goal), and you're golden. Doing so it will always pop the node with the best potential for reaching the goal in the best possible way
  3. A* implemented with an accurate heuristic (eg. A heuristic that is incapable of overestimations, which is easy in this case) is incapable of returning a path that is not the shortest possible. Also, 111 nodes in 34ms is relatively slow looking at your implementation, I can see that this really isnt a real Dijkstra algorithm, It wont search in the pattern illustrated by your gif. It works, but it will search very inefficiently. Dijkstra is implemented using a PriorityQueue or something of the like, with the ability to sort its content by comparing their potential (Accumulated distance from starting point). Using a deque simply does not accomplish this. It polls random nodes rather than the ones with the shortest distance, which may ultimately return suboptimal paths Overall its a decent piece of code, but has room for some improvements
  4. If the cost of a graph edge is measured in distance, why would you use Dijkstra and not A*? A* Would reach the destination much faster, since it would search a lot less nodes. Using Euclid or a modified Manhattan heuristic would provide good results
  5. Math operations are usually very expensive (Especially the Pow() operation) I'd recommend just indexing a single-dimensional array @Liverare, not sure why you would want to do a 2d array EDIT: This is the one I use public static final int[] XP_TABLE = {0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431};
  6. Looks useful; but.. Why would you make a singleton without a defined constructor :E? The purpose of singleton is to prevent multiple instances, hence a private constructor.. and the only reason u would do this is in cases where the class holds some sort of reference that should not be created multiple instances of; like a connection. But you create a new one every time anyway? also, is this on purpose? final String AVERAGE = "average",LOW= "recent_high", HIGH="recent_low"; HIGH = low and LOW = high?
  7. FrostBug

    Webwalker

    Ah, that's quite a bit faster than I had expected o_O Gj on that ;), Guess a heuristic won't be necessary after all
  8. FrostBug

    Webwalker

    What kind of complexity are you referring to? Even if the map is weighted for stuff like doors, a heuristic will immensely improve the runtime, as long as you dont let it overestimate the heuristic distances. How is the graph built? If its a node-edge based graph where each node has like.. 1-3 neighbours and long/medium distance edges, then I see no issue with a heuristic.. Dijkstra is not much better than Breadth first search, with a runtime of O(n2) compared to A*'s potentially linear runtime. If the graph is how I imagine it, I would recommend Euclid heuristic Performing a large-scale pathfinding between 2 faraway points would be ridiculously time consuming without one
  9. FrostBug

    Webwalker

    Why Dijkstra? Using a heuristic based algorithm would likely be a lot faster. (A* might outperform Dijkstra quite a bit with an accurate heuristic)
  10. Thanks for this Alot of people might want to remove the f2p worlds, though
  11. Ah.. Should have checked the Snippets section yesterday when I needed this; Anyway, I've made a similar implementation; I suppose people can choose what fits their needs import java.util.ArrayList; import java.util.List; import org.osbot.script.mouse.RectangleDestination; import org.osbot.script.rs2.Client; import org.osbot.script.rs2.ui.Option; /** * * @author FrostBug */ public class Menu { private List<Option> options; private List<String> strOptions; private int x, y, width; private Client client; private static final int OPTION_HEIGHT = 15; private static final int TOP_PADDING = 19; private Menu(Client client) { this.strOptions = new ArrayList<>(); this.options = client.getMenu(); this.x = client.getMenuX(); this.y = client.getMenuY(); this.width = client.getMenuWidth(); this.client = client; for (Option o : options) { strOptions.add(o.action); } } public static Menu getActiveMenu(Client client) { if (client.isMenuOpen()) { return new Menu(client); } else { return null; } } public boolean hasOption(String action) { return strOptions.contains(action); } private RectangleDestination getDestinationRect(int index) { return new RectangleDestination(x + 4, y + TOP_PADDING + (index * OPTION_HEIGHT), width - 8, OPTION_HEIGHT); } public boolean moveMouseToOption(String action, boolean click) throws InterruptedException { int index = strOptions.indexOf(action); boolean success; if (index > -1 && client.isMenuOpen()) { RectangleDestination rect = getDestinationRect(index); success = client.moveMouse(rect, false); if (click && success) { client.clickMouse(false); } } return success; } public boolean isMouseOnOption(String action) { RectangleDestination rect = getDestinationRect(strOptions.indexOf(action)); return client.isMenuOpen() && rect.destinationReached(client.getMousePosition()); } }
×
×
  • Create New...