News for hackers. Stuff that matters.
Re:Will you drown? by jffry on Saturday April 26, 2014 @01:49PM (#7652178)
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.)
Re:Will you drown? by shawnz on Saturday April 26, 2014 @02:02PM (#7652222)
Hilariously, this gets stuck buying "Stuff" over and over and doesn't seem to ever complete the game
Re:Will you drown? by JumpCrisscross on Saturday April 26, 2014 @02:04PM (#7652235)
It is appropriate that relying on a static heuristic to point one's path leaves you unfulfilled, bitter, and dead.
Re:Will you drown? by elinchrome on Saturday April 26, 2014 @02:07PM (#7652246)
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.
Re:Will you drown? by CyberShadow on Saturday April 26, 2014 @04:07PM (#7652594)
> 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

Re:Will you drown? by hellbreakslose on Saturday April 26, 2014 @05:06PM (#7652741)
yes that version 2 if u open up the original js ull see bazzillion ifs
Re:Will you drown? by fcatalan on Saturday April 26, 2014 @02:19PM (#7652278)
So now stop a bit. Reread what you wrote, think about what you did and the outcome. Harrowing isn't it?
Re:Will you drown? by callesgg on Saturday April 26, 2014 @04:46PM (#7652685)
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.
Re:Will you drown? by jffry on Saturday April 26, 2014 @02:03PM (#7652230)
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)
Re:Will you drown? by joshlegs on Saturday April 26, 2014 @02:52PM (#7652377)
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

Re:Will you drown? by jsmeaton on Saturday April 26, 2014 @08:48PM (#7653373)
Noticed that too - thought it was pretty significant.
Re:Will you drown? by parasight on Saturday April 26, 2014 @01:58PM (#7652210)
Drowning in problems? Automation is the solution ;)
Re:Will you drown? by wingerlang on Saturday April 26, 2014 @02:07PM (#7652243)
And now you have N+1 problem.
Re:Will you drown? by err4nt on Sunday April 27, 2014 @11:19PM (#7658066)
Amen to that
Re:Will you drown? by egeozcan on Saturday April 26, 2014 @06:44PM (#7653040)
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 =)

Re:Will you drown? by dennisgorelik on Sunday April 27, 2014 @08:09PM (#7657545)
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
Re:Will you drown? by jaeh on Sunday April 27, 2014 @06:45AM (#7654625)
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 ;)

Re:Will you drown? by caio1982 on Saturday April 26, 2014 @01:58PM (#7652209)
I think you missed the point here, but nice trick :-)
Re:Will you drown? by kbaker on Saturday April 26, 2014 @02:01PM (#7652220)
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...

Re:Will you drown? by jffry on Saturday April 26, 2014 @02:00PM (#7652218)
I got the point, curiosity just got the better of me
Re:Will you drown? by cturhan on Saturday April 26, 2014 @03:18PM (#7652443)
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);
Re:Will you drown? by elliottkember on Saturday April 26, 2014 @03:34PM (#7652491)
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.
Re:Will you drown? by joshstrange on Saturday April 26, 2014 @04:09PM (#7652599)
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.
Re:Will you drown? by elliottkember on Saturday April 26, 2014 @04:44PM (#7652681)
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?
Re:Will you drown? by tensaix2j on Sunday April 27, 2014 @11:53AM (#7655533)
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)

Re:Will you drown? by hmgibson23 on Saturday April 26, 2014 @02:20PM (#7652289)
- Integrity for using jQuery? Lol
Re:Will you drown? by LukeB_UK on Saturday April 26, 2014 @02:30PM (#7652313)
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...

Re:Will you drown? by hmgibson23 on Saturday April 26, 2014 @02:44PM (#7652351)
Didn't know that. Nice point!
Re:Will you drown? by sashasklar on Saturday April 26, 2014 @02:27PM (#7652302)
Seriously?

  window.setInterval(function(){ Array.prototype.forEach.call(document.querySelectorAll('a'),function(i) {i.dispatchEvent(event)})},1000);
Re:Will you drown? by jffry on Saturday April 26, 2014 @02:28PM (#7652306)
I was going for quick and dirty. $(foo).click() was available so why not use it?
Re:Will you drown? by hmgibson23 on Saturday April 26, 2014 @03:04PM (#7652408)
It was a joke...
Re:Will you drown? by sashasklar on Saturday April 26, 2014 @05:05PM (#7652738)
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?
Re:Will you drown? by hmgibson23 on Saturday April 26, 2014 @03:04PM (#7652405)
Seriously it was a joke