Jump to content

Ziy

Members
  • Posts

    57
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by Ziy

  1. Post where the lines you update the allTimes reference. You are assigning it null somewhere
  2. I think you need to import this package import org.osbot.rs07.api.map.Area; Good luck!
  3. If you want to do this for an iron man you need to monitor hit splats and make sure the damage you have done equals the health of the monster
  4. maybe unrelated to the issue but the case won't break on the else of the if, so then it will fall through to the next case handling block, unless of course you want this
  5. Hey man, the reason there was a discussion on reversing a path was that you can use a path to get somewhere and then simply reverse it to return
  6. If you do put it on a separate thread make sure you keep in mind the potential for race conditions
  7. Haha how crude of me, here's a decent looking guide http://www.teachmejoomla.net/code/php/remote-ip-detection-with-php.html
  8. For anyone who want's to host their own php for it <? echo $_SERVER["REMOTE_ADDR"]; ?>
  9. What is the log output when you try? Can we see your onPaint method?
  10. You both have valid approaches to the problem but why not try to achieve the pros of both implementations in one? Performance is key, right? I would go for the lookup table approach similar Botrepreneur, why? It is way faster as all values a precomputed, here are some test results (100,000 function calls timed in nanoseconds) Test 1 (Botrepreneur 100,000 random 1-99 values) : 11839527 Test 2 (NotoriousPP 100,000 random 1-99 values): 467340188 Test 3 (Botrepreneur 100,000 calls just for value 99): 224877 Test 2 (NotoriousPP 100,000 calls just for value 99): 918205715 But it might be a good idea to keep extensibility by precomputing the values in the lookup table using NotoriousPP's method rather than hardcoding the values Therefore we will have both extensibility and performance (using both your arguments)!
  11. It's because you return after eating an item, if you want to return true if at least one item was eaten then hold it in a boolean variable until the loop has finished then return the result
  12. Do you dynamically load the mini-map image in the region preview?
  13. Ziy

    World hopping class

    You're welcome mate! :-)
  14. Ziy

    World hopping class

    This won't work.. Test Program Output Here's the problem.. private void resetList() { if (future.isEmpty() && !past.isEmpty()) { future = past; past.clear(); } } You are making future reference the same object as past and then clearing it so let's change that first private void resetList() { if (future.isEmpty() && !past.isEmpty()) { List<Integer> temp = future; future = past; past = temp; past.clear(); } } Here you add world values to the future list which is fine.. public WorldHopping(boolean p2pworlds, final boolean f2pworlds, final boolean pvpworlds) { if (p2pworlds) { future.addAll(P2P_WORLDS); } if (f2pworlds) { future.addAll(F2P_WORLDS); } if (pvpworlds) { future.addAll(PVP_WORLDS); } } But.. public void toRandomWorldNumber(){ int i = new Random().nextInt(future.size()); int w = future.get(i); System.out.println(w); future.remove(i); past.add(i); resetList(); } In each hopping method you add the index of the world in future to past and then remove the value from the future? Why would you do that? The index is useless now right? I think you meant to add the world value to the past list, like so public void toRandomWorldNumber(){ int i = new Random().nextInt(future.size()); int w = future.get(i); System.out.println(w); future.remove(i); past.add(w); resetList(); } Now we store the past world values rather than their obsolete indexes in the future list Updated program: import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; /** * @author Botrepreneur */ public class WorldHopping { private final List<Integer> P2P_WORLDS = Arrays.asList(301, 302, 303, 304, 305, 306, 309, 310, 311, 312, 313, 314, 317, 318, 319, 320, 321, 322, 326, 327, 328, 329, 330, 333, 334, 335, 336, 338, 341, 342, 343, 344, 345, 346, 349, 350, 351, 352, 353, 354, 357, 358, 359, 360, 361, 362, 365, 366, 367, 368, 369, 370, 373, 374, 375, 376, 377, 378); private final List<Integer> F2P_WORLDS = Arrays.asList(308, 316); private final List<Integer> PVP_WORLDS = Arrays.asList(325, 337); private List<Integer> future = new ArrayList<>(); private List<Integer> past = new ArrayList<>(); public WorldHopping(boolean p2pworlds, final boolean f2pworlds, final boolean pvpworlds) { if (p2pworlds) { future.addAll(P2P_WORLDS); } if (f2pworlds) { future.addAll(F2P_WORLDS); } if (pvpworlds) { future.addAll(PVP_WORLDS); } } public void toRandomWorldNumber(){ int i = new Random().nextInt(future.size()); int w = future.get(i); System.out.println(w); future.remove(i); past.add(w); resetList(); } public void toLowestWorldNumber(){ int w = Collections.min(future); int i = future.indexOf(w); System.out.println(w); future.remove(i); past.add(w); resetList(); } public void toHighestWorldNumber(){ int w = Collections.max(future); int i = future.indexOf(w); System.out.println(w); future.remove(i); past.add(w); resetList(); } private void resetList() { if (future.isEmpty() && !past.isEmpty()) { List<Integer> temp = future; future = past; past = temp; past.clear(); } } public static void main(String args[]) { WorldHopping hopper = new WorldHopping(true, true, true); for(int i = 0; i < 1000; i++) { hopper.toRandomWorldNumber(); } } } Output (it ran to 1000 iterations but these are the first few) Note: You will have to put the world hopping method back from the API
  15. String.format("%d:%02d:%02d", hour, minute, second);
  16. Hey guys, Was just browsing /r/2007scape and Mod Mat K posted the following heat maps Botting Activity in April Botting Activity in May Source: Dev blog: Bots and F2P (Reddit) It says 40K accounts were banned in April, which is crazy!
  17. Ziy

    Hashmaps

    I think my understanding of "useless" is different from yours I really can't be bothered discussing this further. It is all subjective after all. I prefer to spend a little bit of time and thought and produce reusable resources with minimal overheads
  18. Ziy

    Hashmaps

    Your approach will work, but.. Why not have worst case O(1) lookup each time if you can? You are iterating over the entire set of worlds each time which is unnecessary and can prove to be inefficient if you polling for available worlds continually This will repeat the same sequence of worlds every time You haven't mentioned the time constraint
  19. Ziy

    Hashmaps

    Hey I wrote a class to help you with the problem The pool introduces a random element without having to randomly iterate through the list each time (prioritising worlds we haven't visited for longer). import java.util.LinkedList; import java.util.Random; /** * * @author Ziy */ public class WorldManager { private int[] worlds = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Example worlds private final int POOLSIZE = 5; // Size of pool (must be <= number of worlds) private final int ACCEPTABLE_TIME = 10; // in seconds private final LinkedList<Integer> queue = new LinkedList<>(); private final int[] pool = new int[POOLSIZE]; private final Random random = new Random(); private final long startTime; public WorldManager() { // Start by shuffling the worlds shuffleArray(worlds); // Add all the worlds to the queue for (int world : worlds) { queue.add(world); } // Move the first n (where n is the pool size) into the pool for (int i = 0; i < pool.length; i++) { pool[i] = queue.remove(); } // Repurpose the world array so we can now use it to house the times // We will index it using the world number worlds = new int[100]; // Set the start time startTime = System.currentTimeMillis(); } public int getNext() // returns world or -1 if no world satisfies { int startingRandom = random.nextInt(pool.length); // Pick a random world from the pool and iterate through the rest // to look for a valid world for (int i = 0; i < pool.length; i++) { int startingIndex = (startingRandom + i) % pool.length; int nextWorld = pool[startingIndex]; if (getTime() - worlds[nextWorld] >= ACCEPTABLE_TIME - 1 || worlds[nextWorld] == 0) { // Update world time worlds[nextWorld] = getTime() + 1; // Add world back to the queue queue.add(nextWorld); // Add the head of the queue to the pool pool[startingIndex] = queue.remove(); return 300 + nextWorld; // 300 added for OS } } // No world satisfies the time required return -1; } private int getTime() { return (int) ((System.currentTimeMillis() - startTime) / 1000); } private void shuffleArray(int[] array) { for (int i = array.length - 1; i > 0; i--) { int index = random.nextInt(i + 1); // Simple swap int a = array[index]; array[index] = array[i]; array[i] = a; } } // Test main - remove if unwanted public static void main(String[] args) { long startTime = System.currentTimeMillis(); WorldManager wm = new WorldManager(); while (System.currentTimeMillis() < startTime + 30000) // crudely run for 30 secs { int world = wm.getNext(); long time = (System.currentTimeMillis() - startTime) / 1000; if (world != -1) { System.out.println("World: " + world + " Time: " + time + "s"); } } } } Here is what it looks like when we run the main run: World: 307 Time: 0s World: 301 Time: 0s World: 305 Time: 0s World: 310 Time: 0s World: 308 Time: 0s World: 304 Time: 0s World: 309 Time: 0s World: 302 Time: 0s World: 306 Time: 0s World: 303 Time: 0s World: 308 Time: 10s World: 301 Time: 10s World: 304 Time: 10s World: 305 Time: 10s World: 306 Time: 10s World: 303 Time: 10s World: 307 Time: 10s World: 310 Time: 10s World: 302 Time: 10s World: 309 Time: 10s World: 304 Time: 20s World: 305 Time: 20s World: 307 Time: 20s World: 308 Time: 20s World: 306 Time: 20s World: 303 Time: 20s World: 310 Time: 20s World: 309 Time: 20s World: 302 Time: 20s World: 301 Time: 20s BUILD SUCCESSFUL (total time: 30 seconds) Quickly drawn diagram to explain the process
  20. Ziy

    Hashmaps

    Cool :-) keep us updated
  21. Ziy

    Hashmaps

    Hashmap is a slight overkill if you are using world numbers as a key (why not an array using the world number as index?) you could also look into cyclic buffer or just a queue and just randomly pick from the 5 at the front as long as it satisfy your conditions
  22. Hey Laz, please add this to the javadocs so it comes up in the API It would make it more helpful (I didn't realise the returned value did this), I assumed it was an exit status (d'oh)
×
×
  • Create New...