Jump to content

Bobrocket

Members
  • Posts

    1664
  • Joined

  • Last visited

  • Days Won

    4
  • Feedback

    100%

Everything posted by Bobrocket

  1. Great read. I actually cover this a little bit in my OmniPocket thread except I call it "bias deviation" I'll post some code here in a bit, hang in there EDIT: untested, however should work: import java.awt.Point; import java.awt.Rectangle; import java.util.Random; public class BetterMouse { public static Point getBiasedPoint(Point src, Point dst) { Rectangle dstRect = new Rectangle((int) dst.getX() - 2, (int) dst.getY() - 2, 5, 5); if (dstRect.contains(src)) return src; int dstStartX = (int) dstRect.getX(); int dstStartY = (int) dstRect.getY(); int dstEndX = dstStartX + (int) dstRect.getWidth(); int dstEndY = dstStartY + (int) dstRect.getHeight(); int srcX = (int) src.getX(); int srcY = (int) src.getY(); boolean north = (srcY <= dstStartY); boolean west = (srcX <= dstStartX); int biasedX = (north ? positiveSkewedRandom(1, 3) : negativeSkewedRandom(1, 3)); int biasedY = (west ? positiveSkewedRandom(1, 3) : negativeSkewedRandom(1, 3)); return new Point(dstStartX + biasedX, dstStartY + biasedY); } public static int positiveSkewedRandom(int min, int max) { return skewedRandom((double) min, (double) max, 2.55, -1.68); } public static int negativeSkewedRandom(int min, int max) { return skewedRandom((double) min, (double) max, 2.55, 1.68); } //http://stackoverflow.com/a/13548135 public static int skewedRandom(double min, double max, double skew, double bias) { Random r = new Random(System.currentTimeMillis()); double range = max - min; double mid = min + range / 2.0; double unitGaussian = r.nextGaussian(); double biasFactor = Math.exp(bias); double retval = mid + (range * (biasFactor / (biasFactor + Math.exp(-unitGaussian / skew)) - 0.5)); return (int) retval; } } Skewed random functions from here, enjoy
  2. Bobrocket

    Damages

    Sounds like your motherboard is fucked Sorry mate.
  3. Bobrocket

    Damages

    Check your motherboard troubleshooting manual. I'm sure that means something.
  4. Bobrocket

    Damages

    Nothing displayed on your monitor? No BIOS boot up screen?
  5. Bobrocket

    Damages

    This. OP, turn your PC on (with all the components inside), let it run and listen for any beeping. The beeps typically last 1 second with a delay of 1 second and then will pause for 3-5 seconds. Count them and then diagnose manually with the motherboard beep tests. I'm gonna guess that some of the RAM modules have become corrupted (although when that happened to me I didn't get a beep code, it displayed on my monitor that it was corrupt), or there is some damage to the circuitry. You said it all powers up fine, does that include CPU fans/case fans?
  6. ^ Put it on Google Hangouts, make it a real hangout by using a rope.
  7. Try something like this: GroundItem g = sA.getGroundItems().getAll().stream().filter(groundItem -> (groundItem.exists() && groundItem.getName().equalsIgnoreCase(c.loot))).min(new Comparator<GroundItem>() { @Override public int compare(GroundItem one, GroundItem two) { return Integer.compare(sA.getMap().distance(one), sA.getMap().distance(two)); } }).orElse(null); if (g == null) return; if (!g.isVisible()) sA.getCamera().toEntity(g); if (sA.getInventory().isFull() && sA.getInventory().contains(c.food)) sA.getInventory().getItem(c.food).interact("Eat"); g.interact("Take"); If that doesn't work, log each line to see where the error is
  8. I had it laid out like that so people can see each individual step, I'll add that in a bit though
  9. Shouldn't matter in the example you provided though right? Or does the problem lie in the fact that I create a new Stream<Player>?
  10. Here I will be covering streams. Streams are great ways to essentially sort through lists. Why should we use streams? Since you can do just about anything with them in a single line of code. There are cases where streams probably aren't the most useful, take this: NPC guard = getNpcs().closest("Guard"); This is our bog standard way of grabbing the closest "Guard" npc. What it would actually be doing behind the scenes would be using a stream like so: public NPC closest(String name) { return getNpcs().getAll().stream().filter(npc -> (npc.exists() && npc.getName().equalsIgnoreCase(name))).min(new Comparator<NPC>() { @Override public int compare(NPC one, NPC two) { return Integer.compare(getMap().distance(one), getMap().distance(two)); } }).orElse(null); } Looks complicated, right? Here's what it would look like if it wasn't all one line: public NPC closest(String name) { Stream<NPC> unfilteredStream = getNpcs().getAll().stream(); Stream<NPC> filteredStream = unfilteredStream.filter(npc -> (npc.exists() && npc.getName().equalsIgnoreCase(name))); Optional<NPC> npc = filteredStream.min(new Comparator<NPC>() { @Override public int compare(NPC one, NPC two) { return Integer.compare(getMap().distance(one), getMap().distance(two)); } }); return npc.orElse(null); } Here's a breakdown of all the functions: (more on comparators in a bit) filter() -> This function will filter out our list for the specified properties that we're looking for in an NPC. In our case, we're looking for an NPC that exists and has a name of our variable "name". Every NPC that is in our region that doesn't suit our needs is discarded. min() -> This is a bit of a complicated function, but what it will do is find the NPC which returns the smallest compare() value. In this scenario, it will return the NPC which is closest to us. orElse() -> This is the same as an if (x) y; else z; statement, however basically what we are saying is if we could not find a suitable NPC, we can return the value inside orElse() (in this case, null). Now, this probably still looks like a bunch of wizardry to you. No worries, streams are scary at first, but after you know how to write them they're great! How to write a stream By now, you're probably itching to write a stream. In this example, we're going to find all the players within a 6 tile radius. To start off, we're going to have a function called getPlayersWithinSix(): public List<Player> getPlayersWithinSix() { return null; //We'll change this soon } Now we're going to begin the filter! To start off, we want to grab all the players, and put it in a Stream<Player>. This is what we will be filtering! public List<Player> getPlayersWithinSix() { Stream<Player> ourStream = getPlayers().getAll().stream(); return null; //We'll change this soon } Now that we have our stream, we can finally begin filtering! In this example, we only want to filter to see if the player is within 6 tiles of our own player. We're going to store the filter in another stream like so: public List<Player> getPlayersWithinSix() { Stream<Player> ourStream = getPlayers().getAll().stream(); Stream<Player> ourFilteredStream = ourStream.filter(player -> (player.exists() && getMap().distance(player) <= 6)); return null; //We'll change this soon } In our filter, we're checking these conditions: Does the player exist? Is the distance of the player within 6 tiles? Finally, we want to turn our Stream into a list so we can use it. We do this like so: public List<Player> getPlayersWithinSix() { Stream<Player> ourStream = getPlayers().getAll().stream(); Stream<Player> ourFilteredStream = ourStream.filter(player -> (player.exists() && getMap().distance(player) <= 6)); return ourFilteredStream.collect(Collectors.toList()); } See how we changed our return to ourFilteredStream.collect();? What that will do is put all of these players we found into a list, and return it. Now, this doesn't look like our streams from before, so to put it all in one line it would look like this: public List<Player> getPlayersWithinSix() { return getPlayers().getAll().stream().filter(player -> (player.exists() && getMap().distance(player) <= 6)).collect(Collectors.toList()); } Comparators, what do they do? A comparator is basically a way we compare two objects. Since the Comparator type is abstract (much like our Filter<T> class), we have to make our own compare() method. An example can be seen in our NPC closest function: new Comparator<NPC>() { @Override public int compare(NPC one, NPC two) { return Integer.compare(getMap().distance(one), getMap().distance(two)); } } What this Comparator does, in essence, is compare the distances of both NPCs (relative to the player). Since getMap().distance() returns an integer, we use Integer.compare to compare both of the distances. You'll most likely be using a Comparator to check for distance. More stream examples Here I'll be writing a few more stream examples to show why they're so useful. Find the furthest away NPC that has the name "Man": getNpcs().getAll().stream().filter(npc -> (npc.exists() && npc.getName().equalsIgnoreCase("man"))).max(new Comparator<NPC>() { @Override public int compare(NPC one, NPC two) { return Integer.compare(getMap().distance(one), getMap().distance(two)); } }).orElse(null); Get all the NPCs in a 10 tile radius that you can attack: getNpcs().getAll().stream().filter(npc -> (npc.exists() && npc.hasAction("Attack") && getMap().distance(npc) <= 10)).collect(Collectors.toList()); Get all the fishing spots where you can cage for lobsters: getNpcs().getAll().stream().filter(npc -> (npc.exists() && npc.hasAction("Cage") && npc.hasAction("Harpoon"))).collect(Collectors.toList()); If I missed anything, let me know
  11. What I did was purchase one of these super cheap refurbished office PCs off of eBay. I added some RAM, a new CPU, and a graphics card (total cost estimating £200 now or around $320 I think?), can run Skyrim perfectly fine on high settings, same with all the games I own. With the left over money, you could probably invest in a larger HDD (I'd say go with an SSHD if you want faster speeds), and save the rest of your money for other things
  12. Your bottleneck will be the CPU. If you look for a company called defensiveservers, they offer windows VPS cheaper. Their plan of the same price for Windows has 3 vCPU cores vs OVH's 2 vCPU cores, albeit with less RAM.
  13. Congrats on the pussy + free sub bro! My day was pretty good, got my replacement pc parts so its no longer broken and I can work again, I still have homework to do before my classes start on the 7th and I have to get a bag and all too
  14. Just a thought, wouldn't it be better to have the separate class so that way you don't recreate the filter everytime its needed?
  15. It's the same, just changing the letter for the y intercept
  16. make a graph from -10 to +10 on both axes, work out all the y values from x=-10 to x=10 (they will be in the formula y=mx+c) and plot them where x=0 is the x intercept, where y=0 is the y intercept. the gradient will be the m value in the formula y=mx+c (how much up/down for each x increment)
  17. Wow bro did you RIP that from the game cache????
  18. Jams loves my hams When he sees them he like "Damn!" But he mad cuz they my hams Ain't no one fuck with my hams You looking at me and you think I'm coming Come on then and meet me at Woking I rhyme so hard you'll be choking To even try and spit my bars, you ain't no king! *drops mic*
  19. To fix your implementation, replace .closest("Yak") with .closest(<filter>)
  20. Obvious answer, you brute force the mainframe! Duh, who doesn't know that?
  21. What's the advantage for a custom filter over just an anonymous filter?
  22. What scripts are you using? Maybe they take some time to load?
  23. I was working on one, could always revive it and see how it works. Would be a long project however :p
  24. Your onLoop() will be executing anywhere from 5-10 times per second (depending on your return value of course, should typically have it at around 215ms), so you can imagine it would be clicking 5-10 times per second since it will just continue the loop after clicking continue. A way to do this would be to see if there is a widget with the text "Please wait...", as this is the substitute when you click continue (right?), and if there is, you wait. Another way is to sleep until the widget changes/disappears.
×
×
  • Create New...