YADWB

Yet Another Depressed Wordpress Blogger

Posts Tagged ‘C++’

My life is a loop (geek version)

Posted by yadwb on July 16, 2009

So, here’s a little proof for those skeptical about my programming skills. Took about half hour to write, it’s a C++ version, albeit less detailed, of the loop I described in My life is a loop. An iteration of the loop represents a day, while the meaning of the exit statement should be pretty self-explanatory…

void life() {
  int mood = NORMAL;
  void (*obsession)(void) = NULL;
  
  while(1) {
    int guilt = are_relatives_important(mood);  
    int studying = is_studying(mood, guilt);
    int working = is_working(mood, guilt, studying);
        
    if(!guilt || (!working && !studying && obsession == NULL)) {
      waste_time();
      obsession = waste_time;
      mood = min(mood + GOOD_DAY, NORMAL);
    }
    else {
      if(working) {
        work(mood, obsession);
        mood -= BAD_DAY;
      }
      
      if(studying) {
        study(mood, obsession);
        mood -= BAD_DAY;
      }
            
      if(is_boring(obsession)) {
        mood -= LIFE_SUCKS;
        obsession = NULL
      }
      
      if(!guilt && mood <= SUICIDE_THRESHOLD)
        exit(-1); // failed at life()
        
      obsession = find_obsession();
      
      if(obsession != NULL && free_time() > 0)
        obsession();
    }
  }
}


Posted in Coding, Depression, Obsession, Stuff | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.