Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Play automatically:

  setInterval(function(){ $("a").click() }, 100)
(Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)


Hilariously, this gets stuck buying "Stuff" over and over and doesn't seem to ever complete the game


It is appropriate that relying on a static heuristic to point one's path leaves you unfulfilled, bitter, and dead.


I wasn't aware that clicking different things in different orders affected the outcome. I have just been clicking solve every time it comes up and not reading the captions.


> I wasn't aware that clicking different things in different orders affected the outcome.

I don't think it does.

Here's the relevant part of the (dart2js'd but slightly cleaned-up) code:

https://gist.github.com/CyberShadow/11329584

Edit: I made a full graph of the entire game: https://news.ycombinator.com/item?id=7652770


yes that version 2 if u open up the original js ull see bazzillion ifs


So now stop a bit. Reread what you wrote, think about what you did and the outcome. Harrowing isn't it?


I interpret that as Stuff gets in the way of life. Interesting, i wounder if he designed it that way or it just kind of happened.


For me it ended in my death, with no hope left. It might be a slight timing problem (e.g. play around with the interval and see what happens)


I died with hope!!

Also, I noticed that something compounded to solve if you had more of them, notably stress. When you only had 1, it was instantaneous to solve. If you had more than one, the percent counter took time


Noticed that too - thought it was pretty significant.


Drowning in problems? Automation is the solution ;)


And now you have N+1 problem.


Amen to that


The first thing I did after figuring out how the game works was typing this:

setInterval(function({[].slice.call(document.querySelectorAll("a")).forEach(function(a){a.click()})},100)

It feels great to know there are some more people who think of automating first, a better life second =)


this version of the script gets you through the game: https://github.com/jaeh/willyoudrown/blob/master/willyoudrow...

i am also thinking about writing some ifs into it that allow you to focus on "friends", "happy buddha", "people person", "wisdom", "early death" and maybe some other criteria, but that needs user interface and more time, which i dont have today ;)


This code:

  setInterval(function(){ $("a").click() }, 1000)
leads to a very long life.

Since "You need to learn." is at the bottom of task list, with 1s delay it never gets attention, so you don't learn, so you don't age.

Here's what I've got:

  You have:
  Hope
  Body
  Life
  Love
  309 Memory
  Integrity
  Job
  180 Experience
  53 Friend
  4 Respect
  216 Stuff
  102 Broken Heart
  6 Stress
  Knowledge
  Lover

  You are troubled. [Can't afford] -Integrity -Lost Ambition


I think you missed the point here, but nice trick :-)


I don't know, if you use this hack to get through life, you end up dying after a bitter, troubled life, having never created anything - you are always hitting 'buy more stuff' instead.

Hmm...


I got the point, curiosity just got the better of me


nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be

  fireEvent = function(element){
   var event; // The custom event that will be created

    if (document.createEvent) {
    event = document.createEvent("HTMLEvents");
    event.initEvent("click", true, true);
    } else {
    event = document.createEventObject();
    event.eventType = "click";
    }

    event.eventName = "name-of-custom-event";

    if (document.createEvent) {
    element.dispatchEvent(event);
    } else {
    element.fireEvent("on" + event.eventType, event);
    }
  }

  setInterval(function(){
     Array.prototype.forEach.call(document.querySelectorAll('a'),function(d){
      fireEvent(d);
     })
  }, 1000);


Quick to call someone stupid, aren't we? Did you even try his code? Go try it. Just because a site doesn't have jQuery, doesn't mean $ isn't assigned to anything.


Pretty sure cturhan did try jffry's code and that's why he wrote this code. The $ var on the page only returns the first instance that it matches so his code doesn't work.

A less efficient but shorter way is:

    var interval = setInterval(function(){
    	var links = document.querySelectorAll('#problems a');
    	for(var z =0; z< links.length; z++) {
    		$('#'+links[z].id).click();
    	}
    }, 1000);

Also he never called him stupid he simply informed him that it didn't work.


You're right, sorry - it was the supercilious tone I objected to. In fact $() returns the first element and clicks it. Because it's in a setInterval, it continues to click the first <a> it finds every 100ms. Did you try it?


Actually the oneliner does work. (Although it throws error when a is not found.)

A quick fix would be setInterval(function(){ $("a") && $("a").click() }, 100)


- Integrity for using jQuery? Lol


Actually, the chrome dev tools allow you to use $(selector) even if the site doesn't have jQuery enabled. [0]

[0] https://developers.google.com/chrome-developer-tools/docs/co...


Didn't know that. Nice point!


Seriously?

  window.setInterval(function(){ Array.prototype.forEach.call(document.querySelectorAll('a'),function(i) {i.dispatchEvent(event)})},1000);


I was going for quick and dirty. $(foo).click() was available so why not use it?


It was a joke...


Kinda. I use jQuery when it makes sense, and when I'm working on someone else's dime and time. Use vanilla JS for stuff like this, because why lose an opportunity to learn?


Seriously it was a joke




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: