Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

372 Excellent

About Wrecker

  • Rank
    Advanced Member

Recent Profile Visitors

701 profile views
  1. what's your favorite implementation that you have come up with to solve a problem? my favorite to date is on a project that I pretty much gave up on when I realized how much work was ahead of me when I wanted to rewrite it into a proper implementation. I was just writing it for an end result and when I realized how fucked I was going to be if I ever released it and expected to be able to update/modify it without breaking a stupid amount of dependencies, I pretty much left it where it was. it was supposed to be a MC Spigot RPG plugin where you created a wolf pack, fought to steal resources and shit from other packs, leveled up your characters, had other npc wolves that were characters and a part of packs that claimed their own territories and stuff like that who you could wage war against/try to coerce into joining your own pack alongside other players, but it worked into a giant mess that would work initially, but would be susceptible to a shit-ton of broken dependencies for some simple additions/changes, and I was embarrassed so I left it where it was. One thing I was proud of, though, was using A* search to figure out paths to travel, the idea was to be able to send AI wolves from your pack to go out and scout other packs and report their findings when they returned... The next step was to build a few separate databases of blocks and hold them in a queue, so individual threads could access them and figure out where they were going without fucking over the main thread... Maybe even build some better heuristics, but fuck I was happy when everything worked as it was the first time... Node: class Node implements Comparable<Node> { private Node parentNode = null; ArrayList<Node> neighbours = new ArrayList<>(); private boolean isClosed = false; private int f; private int g = Integer.MAX_VALUE; private int h; private int x; private int y; private int z; private RouteFinder finder; Node(int x, int y, int z, RouteFinder finder) { this.x = x; this.y = y; this.z = z; this.finder = finder; finder.nodes.add(this); setHeuristic(); } private boolean nodeExistsAt(int x, int y, int z) { for (Node node : finder.nodes) if (node.x == x && node.y == y && node.z == z) return true; return false; } private boolean isObstacle(int x, int y, int z) { World world = finder.world; return world.getBlockAt(x,y,z).getType().isSolid() || !world.getBlockAt(x,y,z).getType().isSolid() && !world.getBlockAt(x,y-1,z).getType().isSolid(); } private void setHeuristic() { h = Math.abs(x - finder.toX) + Math.abs(y - finder.toY) + Math.abs(z - finder.toZ); } void setF() { f = g + h; } int getG() { return g; } int checkG(Node node) { if (node.y > y || node.y < y) return 2; else return 1; } void setG(int g) { this.g = g; } boolean isComplete() { return x == finder.toX && y == finder.toY && z == finder.toZ; } void setParentNode(Node node) { this.parentNode = node; } Node getParentNode() { return parentNode; } int getX() { return x; } int getY() { return y; } int getZ() { return z; } void setNeighbours() { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { for (int k = -1; k < 2; k++) { int cX = x + i; int cY = y + k; int cZ = z + j; if (!nodeExistsAt(cX,cY,cZ) && !isObstacle(cX,cY,cZ)) { Node node = new Node(cX,cY,cZ,finder); neighbours.add(node); } } } } } boolean isClosed() { return isClosed; } void setClosed() { isClosed = true; } @Override public int compareTo(@Nonnull Node node) { return Integer.compare(f, node.f); } } RouteFinder: public class RouteFinder implements RouteObserver { private static final long TRAVEL_TIMEOUT = 10000; private static final long RETRY_TIMEOUT = 500; private static final long TELEPORT_TIMEOUT = 8000; private static final int BLOCK_ACCURACY = 2; ArrayList<Node> nodes = new ArrayList<>(); private ArrayList<Node> openSet = new ArrayList<>(); private ArrayList<Location> route = new ArrayList<>(); private boolean isEntityLoaded; private EntityInsentient entity; private RouteSubject subject; private int fromX; private int fromY; private int fromZ; int toX; int toY; int toZ; World world; public RouteFinder(EntityInsentient entity, World world) { this.entity = entity; isEntityLoaded = world.getChunkAt((int)entity.locX,(int)entity.locZ).isLoaded(); this.subject = WolfPack.getChunkLoadListener(); this.world = world; } private void setRoute() { long startTime = System.currentTimeMillis(); long endTime; long totalTime; Node node = new Node(fromX,fromY,fromZ,this); node.setG(0); openSet.add(node); while (!openSet.isEmpty()) { Collections.sort(openSet); Node current = openSet.get(0); current.setNeighbours(); openSet.remove(current); current.setClosed(); if (current.isComplete()) { //DEBUG endTime = System.currentTimeMillis(); totalTime = endTime - startTime; Debugger.debug("Execution took: " + totalTime + "ms"); //DEBUG //Route found buildRoute(current); return; } for (Node neighbour : current.neighbours) { if (neighbour.isClosed()) continue; if (!openSet.contains(neighbour)) openSet.add(neighbour); int tempG = current.getG() + neighbour.checkG(current); if (tempG >= neighbour.getG()) continue; neighbour.setParentNode(current); neighbour.setG(tempG); neighbour.setF(); } } //No route found } private void buildRoute(Node node) { Node current = node; while (current.getParentNode() != null) { route.add(new Location(world,current.getX(),current.getY(),current.getZ())); current = current.getParentNode(); } nodes.clear(); openSet.clear(); Collections.reverse(route); } public void moveEntity(Location to) { subject.addObserver(this); this.fromX = (int) entity.locX; this.fromY = (int) entity.locY; this.fromZ = (int) entity.locZ; this.toX = to.getBlockX(); this.toY = to.getBlockY(); this.toZ = to.getBlockZ(); setRoute(); if (isEntityLoaded) moveEntityLoaded(); else moveEntityUnloaded(); } private void moveEntityLoaded() { new BukkitRunnable() { public void run() { //DEBUG int debugRetryAttempt = 0; //DEBUG Iterator<Location> iterator = route.iterator(); while (iterator.hasNext()) { Location go = iterator.next(); long timeout = System.currentTimeMillis() + TRAVEL_TIMEOUT; long retryTravel = System.currentTimeMillis() + RETRY_TIMEOUT; long teleportTravel = System.currentTimeMillis() + TELEPORT_TIMEOUT; int entityX; int entityY; int entityZ; int goToX = go.getBlockX(); int goToY = go.getBlockY(); int goToZ = go.getBlockZ(); boolean arrived = false; entity.getNavigation().a(goToX, goToY, goToZ, 1D); while (!arrived) { if (!isEntityLoaded) { moveEntityUnloaded(); cancel(); } entityX = (int) entity.locX; entityY = (int) entity.locY; entityZ = (int) entity.locZ; //Check to see if the entity has arrived at its destination if (entityX >= goToX - BLOCK_ACCURACY && entityX <= goToX + BLOCK_ACCURACY && entityY >= goToY - BLOCK_ACCURACY && entityY <= goToY + BLOCK_ACCURACY && entityZ >= goToZ - BLOCK_ACCURACY && entityZ <= goToZ + BLOCK_ACCURACY) { arrived = true; iterator.remove(); } //Probably won't occur with the teleport aspect added in, but just for safety's sake if (System.currentTimeMillis() >= timeout) { //DEBUG Debugger.debug("Cancelling route."); //DEBUG cancel(); return; } //Retry the next step of the route, they get distracted a lot if (System.currentTimeMillis() >= retryTravel) { entity.getNavigation().a(goToX, goToY, goToZ, 1D); retryTravel = System.currentTimeMillis() + RETRY_TIMEOUT; debugRetryAttempt++; } //Teleport the entity if it is stuck if (System.currentTimeMillis() >= teleportTravel) { //DEBUG Debugger.debug("Teleporting..."); //DEBUG entity.setPosition(go.getX(),go.getY(),go.getZ()); teleportTravel = System.currentTimeMillis() + TELEPORT_TIMEOUT; } try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } } //DEBUG Debugger.debug("Route COMPLETE! Retries: " + debugRetryAttempt); //DEBUG cancel(); //Route complete } }.runTaskAsynchronously(WolfPack.getPlugin()); subject.removeObserver(this); } private void moveEntityUnloaded() { //Speed Formula //y = 43.178x-0.02141 double blocksPerMillisecond = (43.178 * entity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue() - 0.02141)/1000; new BukkitRunnable() { public void run() { Iterator<Location> iterator = route.iterator(); double blockTravelled = 10/blocksPerMillisecond; int counter = 0; Location go = iterator.next(); //Emulate the entity travelling the route through the unloaded chunk while (iterator.hasNext()) { while (counter <= blockTravelled) { entity.setPosition(go.getX(),go.getY(),go.getZ()); if (isEntityLoaded) { moveEntityLoaded(); cancel(); } counter = counter + 10; iterator.remove(); iterator.next(); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } } cancel(); } }.runTaskAsynchronously(WolfPack.getPlugin()); subject.removeObserver(this); } @Override public void update(boolean loaded) { this.isEntityLoaded = loaded; } @Override public EntityInsentient getEntity() { return entity; } } Tried to implement the Observer pattern to check if an Entity happened to be unloaded from the server so it could continue its route: public interface RouteObserver { void update(boolean loaded); EntityInsentient getEntity(); } public interface RouteSubject { void addObserver(RouteObserver observer); void removeObserver(RouteObserver observer); void notifyObservers(ArrayList<EntityInsentient> entities, boolean loaded); } public class ChunkLoadListener implements Listener, RouteSubject { private ArrayList<RouteObserver> observers = new ArrayList<>(); @EventHandler public void onChunkUnload(ChunkUnloadEvent event) { notifyObservers(buildEntityList(event.getChunk()),false); } @EventHandler public void onChunkLoad(ChunkLoadEvent event) { notifyObservers(buildEntityList(event.getChunk()),true); } @Override public void addObserver(RouteObserver observer) { observers.add(observer); } @Override public void removeObserver(RouteObserver observer) { observers.remove(observer); } private ArrayList<EntityInsentient> buildEntityList(Chunk chunk) { ArrayList<EntityInsentient> entities = new ArrayList<>(); for (Entity entity : chunk.getEntities()) { if (((CraftEntity) entity).getHandle() instanceof EntityInsentient) { entities.add((EntityInsentient) ((CraftEntity) entity).getHandle()); } } return entities; } @Override public void notifyObservers(ArrayList<EntityInsentient> entities, boolean loaded) { for (RouteObserver observer : observers) { for (EntityInsentient entity : entities) { if (observer.getEntity() == entity) observer.update(loaded); } } } } That was a while ago, and I have no idea what observers is doing in ChunkLoadListener after reading it in this post, but I do remember it being a problem with it waiting for it to say that there's an Entity that should be emulated to move instead of actually moved... Fuck me, it might not be moving at all after unload maybe with nothing looking to see where it's at? Been a while since I've dealt with Spigot or looked at this code lol. Erm, fuck it, what have you written that does exactly what you want it to or at least close enough that you're happy with where you're at in you goals?
  2. What's the fuck up with my neighbors and friends

    11 years? yeah, fuck that guy. i feel the same way in work camps, because it's just a rolling thing with them that you and your neighbour share the same bathroom with paper-thin walls, if i've had the same room for a pile of time and some new neighbour rolls in and starts pulling a pile of bullshit, it's fucking game on. if I'm the new guy in a room, then it's like okay, it is what it is. i can't fucking stand people that can't get off the phone, it literally drives me fucking insane. when some prick-ass motherfucker wakes me up in the middle of the night fucking yammering on to whoever the fuck, i cannot at all keep calm, it's like 0 to fucking redline in half a second. there's always gotta be a moment to kind of take things in and make sure i'm not just misunderstanding the situation, and then when i realize it's super late at night/early in the morning, that they're just bsing with thier spouse/whoever, and my fucking alarm is going to go off wayyy sooner than i would ever want it to because i am hundreds of kilometres away from home with a fucking job to wake up for, FUCK YOU! holy fuck, fuck you. nothing like working 12hrs when it's minus fucking 40 pissed off all day because your awesome fucking neighbour couldn't shut the fuck up and let you have more than 4hrs of sleep. especially when you fucking yell "it's FUCKING TWO IN THE FUCKING MORNING, SHUT THE FUCK UP" and they just go quiet for a bit, then continue on like you just forgot about them, then it's door-time. i fucking hate conflict, i fucking hate knowing who my fucking neighbour is in the first place, but fuck me i cannot handle that shit. i try to be as reasonable as possible, namely because i hate the fact that i have to fucking talk to these dickheads in the first place, and it's so fucking hard to do when you've just spent the last x amount of time quietly losing your fucking shit for being woke up from a dead sleep because some asshole is just a general fucking asshole living up to its name. it's shitty enough being stuck in fucking camp, fuck people that talk on the fucking phone in their room. seriously, fuck everything about them. there's fucking rec-rooms, smoke shacks, main hallways, soo many places for them to not be fucking lowlife fucking assholes driving all of their fucking neighbours up the fucking walls, but that's what they choose to do, all the fucking time. it's not just one guy. there's so fucking many of them, guaranteed you spend enough time in one room on your regular rotation, you will end up with one of these fucking DEGENERATE FUCKS as a neighbour, fuck me. i don't even know how i got on this topic, this is like my biggest beef ever, though. fuck.
  3. Just stuff

    I hope you know I wasn't fucking around, thanks for that.
  4. Just stuff

    Stupid fucking depression gives you a lot of time to think about, cope with, or handle shit on your own, and I fucking hate it. The bottom line for me, I wish I was never born. I wish there was a point before life where somebody would mention the fact that you have to be alive, do your own thing to cope, and watch other people die around you until you're left into whatever fucking bullshit predicament you're left in before you pass yourself. I'd rather just not be anything at that point. Who the fuck wants to look forward to being in the same scope as their (at least, my own) grandparents, stuck in a world of Alzheimers or Dementia until you can't fucking breathe anymore. How fucking fun does that sound? Fuck me, I can usually feel better by thinking about today and tomorrow, but the fucking thought about an inevitable future that none of us fucking picked, it's fucking there. We will most likely be around when our own parents die, there is a chance that we'll be around when our fucking siblings die, our loved ones, fucking anybody. There's a chance that we will experience a horrible and painful death for no good reason in the prime of our life. We all hope for good times and success, and how many of us actually experience it? One thing is for certain, nobody can just live their life without some kind of bullshit lingering over their shoulder, there's always something there, doesn't matter who you are. Fucking feeling depressed for me a few years ago was like fuck me I want to just drive my truck into a support for a concrete overpass right off of the governor, had a pretty good plan, but now it's totally different. It's like fuck I hope this isn't going to be as shitty as it feels like it's going to be, and it usually isn't... Same fucking feelings are there, just years of being used to it... Still fucked up about the just being fucking born thing, I bet there are countless others that would love to have the life that I have, why the fuck is it me instead of them? Why in the fuck is it that there's always a feeling of some kind of fucking bullshit lingering over my shoulder when I'd be happier just not fucking existing? Let somebody else have the shit I have, I am lucky in terms of too many things, and I still feel like shit too many times. I don't know, fuck depression.
  5. Fuck this stupid fucking Statistics fucking class

    i had more fun fucking around with my calculator in math class than learning math... i miss those days.
  6. hit paste

    yea when i saw that, it was kind of brutal to post lol, but it is supposed to be ctrl+v, eugh.
  7. hit paste

    @Override public boolean collides(Collidable collidable) { if (Utils.distance(position.x, position.y, collidable.getClosestPoint(position)[0], collidable.getClosestPoint(position)[1]) <= r) { paint.setColor(Color.RED); /* Log.d("wlf","D: " + Utils.distance(position.x, position.y, collidable.getClosestPoint(position)[0], collidable.getClosestPoint(position)[1]));*/ if (collidable.isSolid()) Log.d("wlf","SOLID"); else Log.d("wlf","NOT SOLID"); } else paint.setColor(Color.WHITE); return Utils.distance(position.x, position.y, collidable.getClosestPoint(position)[0], collidable.getClosestPoint(position)[1]) <= r; } @Override public void invertDirection() { acceleration.mult(-1); } @Override public boolean isSolid() { return false; } @Override public boolean collisionChecked() { return collisionChecked; } @Override public void setCollisionChecked(boolean checked) { collisionChecked = checked; } @Override public float[] getClosestPoint(Vector pos) { float[] closestPoint = new float[2]; double degree = Math.atan(position.y-pos.y/position.x-pos.x); closestPoint[0] = (float) Math.sin(degree)*r; closestPoint[1] = (float) Math.cos(degree)*r; if (pos.x > position.x) closestPoint[0] += position.x; else closestPoint[0] -= closestPoint[0]; if (pos.y > position.y) closestPoint[1] += position.y; else closestPoint[1] -= closestPoint[1]; //Log.d("wlf","X: " + closestPoint[0] + " Y: " + closestPoint[1]); return closestPoint; } @Override public Vector getPosition() { return position; }
  8. So, I have a handy bottle of water I usually drink after a night of drinking to minimize the future hangover... As per the usual course, I took a giant drink of it before going to bed. It wasn't fucking all water this time. There was a definite and strong taste of vodka, and I spent I don't know how long just standing and staring at the wall thinking "This is horrible, but everything will be okay, don't puke, I'm going to empty this out, rinse it, and fill it with just normal water..." Grammarly is awesome. I fucking made it though, motherfucker that was one of the most horrible fucking things ever. I'm still trying to not think about that and write this, but holy-o-fuck, when you figure you're drinking water and it's not water, especially when the only thing you want is water, it really sucks. Good night.
  9. Why I'm misanthropic and why I hate hunters.

    https://www.investing.com/news/commodities-news/oil-hits-highest-levels-since-2015-amid-tightening-markets-saudi-purge-764156 https://www.investing.com/news/commodities-news/oil-hits-highest-levels-since-2015-amid-tightening-markets-saudi-purge-764156 https://www.investing.com/news/stock-market-news/asia-shares-slip-from-decade-highs-oil-at-twoyear-top-on-saudi-purge-764154 http://www.foxbusiness.com/markets/2017/11/05/oil-hits-highest-levels-since-2015-amid-tightening-markets-saudi-purge.html https://www.investing.com/news/commodities-news/crude-oil-gains-in-asia-as-saudi-crackdown-drives-risk-views-764152 http://www.talkmarkets.com/content/commodities/wti-crude-oil-trades-intraday-to-2017-high-as-opec-breeds-confidence?post=155174 It isn't that anybody limited production, you should see what happens when plants are directed to increase production above their designed capacity. It's hard enough for them to produce less than what they're designed for, it's next to impossible to just turn them up. It isn't on a dial. Things have a tendency to catastrophically ESD.
  10. Why I'm misanthropic and why I hate hunters.

    Of course there wasn't an increase in production, that's not even how it works... Forget it, what's with the melodramatic were-fucked junk rhetoric? You're just going to sit back and say everything is fucked without doing anything?
  11. Why I'm misanthropic and why I hate hunters.

    It should be painfully obvious that any and all losses are from the direct causation of the standoff between OPEC and western counterparts circa 2014. Those losses cannot sensibly be regarded as something pertinent to the question at hand which is in regard to the improvement of environmental standards from major oil producers in Canada that have shown considerable improvement over time. Also, if you're arguing against oil in general, why is that graph showing population through time? Correlation and causation. The exchange rate of the several oil commodities has nothing to do with this, and even OPEC members have suffered losses over the time elapsed, which you've stated that is already a known fact that is monitored during every trading session every day. It might be a better idea for you to look into why oil is trading at the rate it is before assuming... uhh... Actually, what are you assuming here? What point are you trying to make with those statistics? I hope you're doing more than just writing stuff on here and calling everything insignificant because every voice matters in changing something, and I'm trying to say that it really does force changes to happen. Keeping your mouth shut and just bitching about things to people that already feel the same sentiment does nothing, but maybe signing the odd petition or encouraging other people that you know to become just a little bit more vocal, and bitching to a broader audience yourself are all steps forward. I'm not happy with watching any of these motherfuckers just keep plugging on like nobody's ever going to stop them, but bit by bit, they're forced to change over public interest. We've made a significant amount of progress since the industrial revolution, and we are polymorphic in terms of our interests; nothing's fucking impossible.
  12. Why I'm misanthropic and why I hate hunters.

    No, I do work in the oil and gas industry, but that doesn't mean I advocate their work by any means. There is such thing as progress, though. You should move north of the border in your search, considering I wasn't referring at all to the junk shale industry, fracing or the like. Look up outfits like CNRL, Suncor, MEG, Cenovus, Devon or Syncrude. And yes, it is entirely about image, but that doesn't mean that nothing changes as a result. If it weren't for the Westray Disaster, Bill C-45 wouldn't be a thing where I live and work, and you better believe that they plug safety HARD in the industry now. You should see what happens on every site through the province on April 28th to commemorate the National Day of Mourning for fallen workers. All the cranes on site blast their horns for several seconds, all work stops, and everybody sitewide takes a moment of silence. Same goes to show with environmental issues, the current place I work in and several others I've been at have big-time severe spill reporting and handling policies where if more than a liter of so much as water or propylene glycol (used for hydrostatic testing in the winter months) hits the ground, they want to know about it and file an incident report over it. They'll shut down an entire project if a protected bird happens to create a nest in an active work area as per legislation. Things happen with pressure in the same shape and way that asbestos is no longer the most common ingredient in insulation or that nuclear sources aren't installed without shielding, appropriate measurement, and training. Things happen when people get pissed off.
  13. Huh.

    Fuck me that shit drives me up the wall. I was headed out to the coast on vacation, and I left a town where there was an immediate passing lane outside of town. I passed the person I intended to, then I saw somebody right up on my bumper, moved over to let them by, and some fucking asshole in a white Chevy passed me and swerved at me before he went on. At first I was like WTF, the guy's a piece of shit, but I figured he might have just been distracted or something. Everything was decent before the next passing lane popped up where I was back into cruise control and about to pass the fucking douche, but he hammered on it right before I was beside him and ripped the fuck into my lane. I was trying not to lose it, because I had my mother with me for that trip, but I floored it, and got in front of the guy from the inside lane. So, trying to have a nice vacation with my mom and this fucking piece of shit heads through everybody just to cut me right the fuck off and shoot a giant middle finger out the window. I was losing my fucking mind, the piece of shit fucking tried to run me off the road and I don't even know what for... He turned off the road a bit better than an hour later, but fuck me I wanted to drive the motherfucker so bad, the fucking cunt tried to put me into the ditch and I don't even know why. Eugh.
  14. Why I'm misanthropic and why I hate hunters.

    Bad media makes a world of a difference. When an outfit in Alberta shipped a heavy hauler down to a museum in Washington as a token of the equipment utilized in the oilsands industry, several activists caught wind of it, scrutinized the industry and provided as much bad publicity as they possibly could. It was enough attention to encourage a world of a difference in methods of oil exploration and values that were adopted by big names across the board. All of the sudden there were plans introduced by everybody to hand back tapped out stakes to nature, create muchly improved strategies and policies to handle spill response, introduce an entirely new method of oil extraction (SAGD), implement deadlines to return seismic cutlines, and forking out a fucking boatload of money in experimental technologies designed to make their processes more efficient and less wasteful. Everybody is gunning to be the next supposed green industry leader in pushing bitumen through a pipeline because there's serious market value in it now. They took a big hit when the world saw them tearing shit apart and firing up junk old boilers to push fairly shit oil downstream. That's not at all saying that any of them are perfect; there's still a lot of work to be done, but the fucking junk attitude that it just needs to be done and that's the way it is, is fucking stupid. Nobody in any oil, gas, or mining industry is turning a deficit short of the organizations servicing them alongside their expendable employees, they are still and will continue to create substantial revenue for the foreseeable future. They're the most ruthless motherfuckers you'll ever meet, and as soon as they have to do something, they'll fuck anybody right over without question to make sure they still stay on payroll. Public pressure can sway a lot of things, put somebodies job on the line and they'll answer.
  15. Why I'm misanthropic and why I hate hunters.

    I am an environmentalist, and it fucking drives me to watch legislation just slip by the general public pretty well unnoticed as bill riders. There's a lot of shit going on now, and it's waaaaay worse with Trump.