<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Long Straight Highway (redux) &#187; csci</title>
	<atom:link href="http://www.longstraighthighway.com/tag/csci/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.longstraighthighway.com</link>
	<description>amusements for gentlemen and scholars</description>
	<lastBuildDate>Wed, 18 Jan 2012 22:54:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Life as computer science</title>
		<link>http://www.longstraighthighway.com/2009/06/05/1259/</link>
		<comments>http://www.longstraighthighway.com/2009/06/05/1259/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 15:49:50 +0000</pubDate>
		<dc:creator>shanusmagnus</dc:creator>
				<category><![CDATA[cat-blog]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[superdork]]></category>
		<category><![CDATA[csci]]></category>

		<guid isPermaLink="false">http://www.longstraighthighway.com/?p=1259</guid>
		<description><![CDATA[So I was hacking around and I found the source code to myself. As it turns out I&#8217;m written in Lisp, which is good in most ways but bad because I can&#8217;t interface with other libraries and because most people can&#8217;t understand me. Still, I figured I&#8217;d share a few things I&#8217;ve learned. This function, [...]]]></description>
			<content:encoded><![CDATA[<p>So I was hacking around and I found the source code to myself.  As it turns out I&#8217;m written in Lisp, which is good in most ways but bad because I can&#8217;t interface with other libraries and because most people can&#8217;t understand me.  Still, I figured I&#8217;d share a few things I&#8217;ve learned.</p>
<p>This function, for instance, is pretty interesting.  It shows what happens when I come near an object.  (There&#8217;s other stuff in the conditional that I&#8217;ve omitted for clarity.)</p>
<pre>
<code>
((def process-near-object (thing)
     ;; Is it junk food?
     (cond
      ((and (is-junk-food thing)
	    (in-front-of thing :me))
       (eat thing))))
</code>
</pre>
<p>That explains a lot, actually &#8211; there&#8217;s no complicated nonsense, no willpower, no thinking.  Well, I mean, observationally all of those things happen, but I guess they don&#8217;t actually matter.  If junk food happens to fall into my area of control I&#8217;ll just eat it.  All the thinking and agonizing and stuff happens somewhere else, and doesn&#8217;t really matter.</p>
<p>But this one is the real eye opener.  It&#8217;s pretty long, even after I&#8217;ve edited out a bunch of stuff.  Still, it explains a hell of a lot:</p>
<pre>
<code>

(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))))))))
</code>
</pre>
<p>Basically, the idea is the same &#8211; all kinds of my behavior is actually pretty straightforward.  If I happen to find myself at the gym, I&#8217;ll workout.  If I&#8217;m in bed, I&#8217;ll go to sleep.  If I have a book in my hands, I&#8217;ll read it.  </p>
<p>But the most interesting (to me) one is the clause about being hungry.  This has really been on my mind lately since I&#8217;ve been working at the U.  For a few days I&#8217;d be eager to get over there, and the state of our house made it difficult to cook, so I wouldn&#8217;t make a lunch and told myself I&#8217;d either skip lunch or else get something healthy around campus.  Of course, it never worked, and now I see why.</p>
<p>Since most of you don&#8217;t know Lisp you might be a little confused.  The code explains what I do when I&#8217;m hungry, but it doesn&#8217;t go into what happens to me afterward.  It&#8217;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.</p>
<p>Still, impossible though the task is, I&#8217;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&#8217;ve extracted from a hex dump of myself:</p>
<p><a href="http://www.longstraighthighway.com/wp-content/uploads/2009/06/life_as_cs1.png"><img src="http://www.longstraighthighway.com/wp-content/uploads/2009/06/life_as_cs1.png" alt="life_as_cs1" title="life_as_cs1" width="424" height="485" class="alignnone size-full wp-image-1261" /></a></p>
<p>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.</p>
<p>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:<br />
<a href="http://www.longstraighthighway.com/wp-content/uploads/2009/06/with_peaches.png"><img src="http://www.longstraighthighway.com/wp-content/uploads/2009/06/with_peaches.png" alt="with_peaches" title="with_peaches" width="146" height="481" class="alignnone size-full wp-image-1263" /></a></p>
<p>This diagram is subtle, so allow me to interpret: if I&#8217;m in the state of being with Peaches, there&#8217;s only one action that can be taken: we&#8217;ll hang out.  If we hang out, there&#8217;s only one possible state that I could transition to: feeling good.  (That&#8217;s where the &#8216;deterministic&#8217; in &#8216;deterministic finite automaton&#8217; comes from.)</p>
<p>*</p>
<p>Now that you&#8217;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 &#8211; in the vast majority of your daily activities &#8211; there&#8217;s just not a lot to think about.  If I get into the state of &#8220;hungry without lunch&#8221; then there will be only one outcome, and that outcome is bad.  If I am in the state of &#8220;with Peaches&#8221; then there will also be only one outcome, and that outcome is good.</p>
<p>So instead of spending a lot of time worrying about why I&#8217;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&#8217;t need any particular will power, I don&#8217;t need to do anything heroic.  I just need to make sure to have a fucking lunch with me when I&#8217;m hungry.</p>
<p>It takes a while to make and export and upload these diagrams, but in my notebook I&#8217;ve identified a shitload of pretty simple DFA that have &#8216;feeling good&#8217; (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 &#8216;feeling bad.&#8217;</p>
<p>Which means that all my bitching and moaning just makes something very simple into something very complicated.  And I&#8217;m tired of doing that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.longstraighthighway.com/2009/06/05/1259/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Language and Religion</title>
		<link>http://www.longstraighthighway.com/2008/12/23/968/</link>
		<comments>http://www.longstraighthighway.com/2008/12/23/968/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 21:38:49 +0000</pubDate>
		<dc:creator>shanusmagnus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[csci]]></category>

		<guid isPermaLink="false">http://www.longstraighthighway.com/?p=968</guid>
		<description><![CDATA[I know this isn&#8217;t the best way to jump back into posting, but this is funny as shit to any computer scientist.  Excerpt: C++ would be Islam - It takes C and not only keeps all its laws, but adds a very complex new set of laws on top of it. It&#8217;s so versatile that it can be [...]]]></description>
			<content:encoded><![CDATA[<p>I know this isn&#8217;t the best way to jump back into posting, but <a href="http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html">this</a> is funny as shit to any computer scientist.  Excerpt:</p>
<blockquote>
<p><span>C++</span> would be <span>Islam</span> - It takes C and not only keeps all its laws, but adds a very complex new set of laws on top of it. It&#8217;s so versatile that it can be used to be the foundation of anything, from great atrocities to beautiful works of art. Its followers are convinced that it is the ultimate universal language, and may be angered by those who disagree. Also, if you insult it or its founder, you&#8217;ll probably be threatened with death by more radical followers.</p>
</blockquote>
<p>That should break the ice.  And how about this: we got a cat, who is apparently half-psychotic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.longstraighthighway.com/2008/12/23/968/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

