Skip to content

Life as computer science

So I was hacking around and I found the source code to myself. As it turns out I’m written in Lisp, which is good in most ways but bad because I can’t interface with other libraries and because most people can’t understand me. Still, I figured I’d share a few things I’ve learned.

This function, for instance, is pretty interesting. It shows what happens when I come near an object. (There’s other stuff in the conditional that I’ve omitted for clarity.)


((def process-near-object (thing)
     ;; Is it junk food?
     (cond
      ((and (is-junk-food thing)
	    (in-front-of thing :me))
       (eat thing))))

That explains a lot, actually – there’s no complicated nonsense, no willpower, no thinking. Well, I mean, observationally all of those things happen, but I guess they don’t actually matter. If junk food happens to fall into my area of control I’ll just eat it. All the thinking and agonizing and stuff happens somewhere else, and doesn’t really matter.

But this one is the real eye opener. It’s pretty long, even after I’ve edited out a bunch of stuff. Still, it explains a hell of a lot:



(def behave
     (let
	 ((my-location (get-current-location :me))
	  (my-state (get-current-state :me)))
       (cond

	;; Am I at the gym?
	((is-at :gym my-location)
	 (workout))

	;; Is there a book in my hands?
	((is-book? (get-item-in-hands :me))
	 (read (get-item-in-hands)))

	;; Am I in bed, ready to sleep?
	((and (is-at? :bed my-location)
	      (in-sleep-posture (get-current-configuration)))
	 (sleep))

	;; What happens when I get hungry?
	((is-hungry? my-state)

	 ;; If I brought my lunch, eat it.
	 (if (brought-lunch? :me)
	     (eat (get-lunch :me))

	   ;; If I didn't bring a lunch, find junk food and eat it.
	   (progn
	     (let ((junk-food (find :junk-food)))
	       (eat junk-food))))))))

Basically, the idea is the same – all kinds of my behavior is actually pretty straightforward. If I happen to find myself at the gym, I’ll workout. If I’m in bed, I’ll go to sleep. If I have a book in my hands, I’ll read it.

But the most interesting (to me) one is the clause about being hungry. This has really been on my mind lately since I’ve been working at the U. For a few days I’d be eager to get over there, and the state of our house made it difficult to cook, so I wouldn’t make a lunch and told myself I’d either skip lunch or else get something healthy around campus. Of course, it never worked, and now I see why.

Since most of you don’t know Lisp you might be a little confused. The code explains what I do when I’m hungry, but it doesn’t go into what happens to me afterward. It’s probably something super-complicated, right? I mean, who could possibly predict my mood and my physical condition in the wake of being hungry? It might be anything from the entire human repertoire, after all.

Still, impossible though the task is, I’ve toiled for hours, bringing all my signficant expertise as both an artist and a scientist to bear in attempting to lay it out for you in this deterministic finite automaton, which I’ve extracted from a hex dump of myself:

life_as_cs1

As you might expect, this diagram is imperfect. The state space is nearly infinite, after all, and for this reason a DFA is not a particularly good model for representing human behavior to a human. Still, if you relax a little this diagram pretty much says it all.

What about non-food, though? Is there any insight to be found in more complicated domains? Since I know how demanding you guys are I did another few hours of work and finally came up with another DFA:
with_peaches

This diagram is subtle, so allow me to interpret: if I’m in the state of being with Peaches, there’s only one action that can be taken: we’ll hang out. If we hang out, there’s only one possible state that I could transition to: feeling good. (That’s where the ‘deterministic’ in ‘deterministic finite automaton’ comes from.)

*

Now that you’ve got a whirlwind tour of computer science, what should you take away? The big idea is that if I am any guide, people are just not that complicated. Really, in the common case – in the vast majority of your daily activities – there’s just not a lot to think about. If I get into the state of “hungry without lunch” then there will be only one outcome, and that outcome is bad. If I am in the state of “with Peaches” then there will also be only one outcome, and that outcome is good.

So instead of spending a lot of time worrying about why I’m feeling bad, maybe the better way to conduct my life would be to exploit these simple causal relationships described very clearly in code. I don’t need any particular will power, I don’t need to do anything heroic. I just need to make sure to have a fucking lunch with me when I’m hungry.

It takes a while to make and export and upload these diagrams, but in my notebook I’ve identified a shitload of pretty simple DFA that have ‘feeling good’ (or something like it) as a resultant state out of another state with only one possible transition. Likewise, I have no shortage of equivalent single transitions out of a state into ‘feeling bad.’

Which means that all my bitching and moaning just makes something very simple into something very complicated. And I’m tired of doing that.