<?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>Raelifin.com &#187; Code</title>
	<atom:link href="http://raelifin.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://raelifin.com</link>
	<description>Deus ex Machina</description>
	<lastBuildDate>Tue, 31 Jan 2012 22:03:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>K-Means Clustering in J</title>
		<link>http://raelifin.com/code/k-means-clustering-in-j/</link>
		<comments>http://raelifin.com/code/k-means-clustering-in-j/#comments</comments>
		<pubDate>Thu, 26 May 2011 17:06:34 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[J]]></category>
		<category><![CDATA[k-means]]></category>
		<category><![CDATA[perception]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=1106</guid>
		<description><![CDATA[Perception is essentially the problem of extracting high-level patterns from large amounts of raw-data (from sensors). Correctly recognizing the pattern/shape &#8220;dog&#8221; in a bitmap is one example of a tricky perceptual task. Note that the symbol &#8220;dog/not dog&#8221; is much less information than the raw image data. This compression is vital for being able to [...]]]></description>
			<content:encoded><![CDATA[<p>Perception is essentially the problem of extracting high-level patterns from large amounts of raw-data (from sensors). Correctly recognizing the pattern/shape &#8220;dog&#8221; in a bitmap is one example of a tricky perceptual task. Note that the symbol &#8220;dog/not dog&#8221; is much less information than the raw image data. This compression is vital for being able to do quick computations further on in the mental process (&#8220;if tiger: run&#8221; is a good example of a conditional that depends on very abstract patterns for both tigers and running).</p>
<p>If we imagine that each sensor is a dimension, then we can say that distinguishing between images of dogs and not-dogs is a matter of partitioning a multidimensional input-space into two areas. Perception in animals is (almost?) never guided by top-down labels, though; animals learn *common* patterns/shapes, and then use these patterns in higher-cognition.</p>
<p><span id="more-1106"></span></p>
<p>Finding common patterns in an input space is the problem of <strong>clustering</strong>. Consider the following graph:<br />
<img src="http://raelifin.com/files/pics/AnimalClusters.png" alt="Animals by Mass and Number of Eyes" /><br />
We can create 4 clusters which (due to outside knowledge) we can loosely associate with labels we&#8217;ve learned previously.</p>
<p>There are many algorithms that will do this sort of clustering task, but perhaps the simplest is <a href="http://en.wikipedia.org/wiki/K-means_clustering">K-Means</a>. Yesterday I built a K-Means clusterer in <a href="http://www.jsoftware.com/">J</a>. It picks initial cluster-centers using <a href="http://en.wikipedia.org/wiki/K-means%2B%2B">K-Means++</a>, and can scale to any number of dimensions. Here is is, chopping a bunch of random points spread over a circle into seven clusters (diamonds indicate the centroids a.k.a. &#8220;means&#8221;):<br />
<img src="http://raelifin.com/files/pics/CircleClusters.png"/></p>
<p><a href="https://github.com/Raelifin/K-Means-Clustering-in-J/blob/master/k-meansClustering.ijs">Here is the code on GitHub.</a> Everything is public domain. No need to provide credit.</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/k-means-clustering-in-j/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nyx</title>
		<link>http://raelifin.com/code/nyx/</link>
		<comments>http://raelifin.com/code/nyx/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 17:16:57 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[cardgame]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Nyx]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=987</guid>
		<description><![CDATA[I don&#8217;t usually post projects that are only mostly done, but I wanted to get this off my plate. It&#8217;s a simple cardgame built entirely in javascript called Nyx (after the Greek goddess). Each turn consists of both players secretly choosing an action. Actions consist of either drawing two cards, or playing a card. There [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t usually post projects that are only mostly done, but I wanted to get this off my plate. It&#8217;s a simple cardgame built entirely in javascript called Nyx (after the Greek goddess). Each turn consists of both players secretly choosing an action. Actions consist of either drawing two cards, or playing a card.</p>
<p><a href="http://raelifin.com/files/Nyx_1/screenshot.png"><img src="http://raelifin.com/files/Nyx_1/screenshot.png" style="width: 540px"/></a></p>
<p>There are a few bugs, and it&#8217;s not at all &#8220;balanced&#8221;, but it&#8217;s mostly playable, and pretty intuitive (IMO). It&#8217;s written in HTML5, so unless you&#8217;re using Google Chrome, I can&#8217;t guarantee it&#8217;ll render properly.</p>
<p>Play it here: <a href="http://raelifin.com/files/Nyx_1/">http://raelifin.com/files/Nyx_1/</a><br />
Download it here: <a href="http://raelifin.com/files/Nyx_1/Nyx.tar.gz">http://raelifin.com/files/Nyx_1/Nyx.tar.gz</a></p>
<p>I may work on it in the future, if I get the urge. Right now I&#8217;m focused on my non-game studies, though, and I was afraid that this would just get thrown on the pile of unpublished code I have lying around.</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/nyx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to the Prisidium</title>
		<link>http://raelifin.com/code/welcome-to-the-prisidium/</link>
		<comments>http://raelifin.com/code/welcome-to-the-prisidium/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 15:28:14 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[interfaces]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Mass Effect]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=933</guid>
		<description><![CDATA[Looks like you can&#8217;t see the iframe content. Perhaps you&#8217;re not on the blog? P.S. This post is so tall because the code is in an iframe. The code could easily integrate as a library, and I could then make this a normal post, but I want it to be encapsulated for now.]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://raelifin.com/files/VIIT.html" width="540" height="540">
<p>Looks like you can&#8217;t see the iframe content. Perhaps you&#8217;re not on <a href="http://raelifin.com/thoughts/welcome-to-the-prisidium/">the blog</a>?</p>
<p></iframe></p>
<p>P.S. This post is so tall because the code is in an iframe. The code could easily integrate as a library, and I could then make this a normal post, but I want it to be encapsulated for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/welcome-to-the-prisidium/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple Rationality</title>
		<link>http://raelifin.com/code/simple-rationality/</link>
		<comments>http://raelifin.com/code/simple-rationality/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 11:03:35 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Cognition]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[heuristics]]></category>
		<category><![CDATA[rationality]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=804</guid>
		<description><![CDATA[I don&#8217;t know why it&#8217;s taken me so long to post this. Several weeks ago I was playing a turn-based fighting game that I love, and I got to thinking &#8220;what would an AI that plays this game well look like?&#8221; And as I thought about it, it became clear to me that the challenge [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know why it&#8217;s taken me so long to post this. Several weeks ago I was playing <a href="http://www.kongregate.com/games/Kongregate/kongai">a turn-based fighting game that I love</a>, and I got to thinking &#8220;what would an AI that plays this game well look like?&#8221; And as I thought about it, it became clear to me that the challenge of playing a complex game is the same as reaching goals in any sufficiently understood environment.</p>
<p>Let me elaborate on that last point, because I think it&#8217;s important. Most of what artificial intelligence, as a field, focuses on (and rightly so) is building a model of an environment. This learning involves taking raw sensory data and turning (or rather, integrating) it into a set of concepts and relationships. But with the simple case of a game, we don&#8217;t really need to learn what the rules are, or learn how to take actions; we can focus entirely on how to play well.</p>
<p><span id="more-804"></span></p>
<p>Playing well involves maximizing a value, which depends on the game. In poker, this value is &#8220;money owned&#8221;, while in chess it&#8217;s &#8220;enemy kings captured*&#8221;. (In chess, the game never progresses to the point where any kings are captured, but as far as goals are concerned, checkmating the king is identical to capturing it.) Another way of putting this is to point out that each game has a distinct <strong>goal</strong>. Playing well involves maximizing the degree to which this goal is met, which I will call &#8220;<strong>utility</strong>&#8220;.</p>
<p style="color: #777">* &#8211; It&#8217;s technically a little bit more complicated than that, because it&#8217;s possible to stalemate, and that&#8217;s not as bad as an outright loss.</p>
<p>So, when presented with several possible &#8220;moves&#8221; in a game, we want to pick the move that has the highest utility. I call this searching and choosing &#8220;being rational&#8221;. To make a game-playing AI then, I needed to build a Rational Agent.</p>
<p>To be a bit more formal about the agent&#8217;s task, it must output a move when given:
<ul>
<li>A &#8220;state&#8221; where it currently is.</li>
<li>A &#8220;rulebook&#8221; (a.k.a. model) for how the game works, including what moves can be made at the given state.</li>
<li>A utility function that, given a state, returns the degree to which it meets a goal.</li>
</ul>
<p>The utility function is conceptually separate for me from the rulebook, as it specifies exactly what this agent &#8220;cares about&#8221;, where the rules are objective and unchanging regardless of who you are. (Example: the rulebook for chess doesn&#8217;t tell you which player you are.) Another reason that I think of them as conceptually distinct is because as I&#8217;m defining the utility function, it is <em>agnostic to consequences</em>. This is a fancy way of saying that the utility function doesn&#8217;t pay attention to what might happen next; it&#8217;s firmly grounded in the &#8220;present&#8221; (i.e. whatever state it&#8217;s given). Because of this agnosticism, it doesn&#8217;t actually rely on any information about game dynamics (rules).</p>
<p>The job of considering consequences is exactly what the Rational Agent is built to do. It takes each action in turn and finds the utility of its immediate consequences, then adds the utility of the next state, and the utility of next&#8230; etc. In other words, it is the limit of the infinite sum of the utility function from t=0 to infinity.</p>
<p>Or at least, it would be if it were a PERFECTLY rational agent. The unfortunate reality (from a math perspective) is that most systems are chaotic enough that it is damn near impossible (and sometimes just plain impossible) to take such an integral. As an example, consider a game (like chess or whatever) where the rule is that your opponent will play exactly as you would in the other position. If you try and compute the consequences of an action, you have to consider the moves of the opponent, which will involve considering your moves, to an infinite regression.</p>
<p>I <a href="http://raelifin.com/thoughts/recursive-escapades/">wrote a post</a> on this problem several weeks ago. It had some fancy math that lets some infinite regressions be solved, but I couldn&#8217;t figure out any fancy tricks that worked for all situations. I intuitively don&#8217;t think it makes much sense trying to compute the limits, either. If I&#8217;m resigned to building an agent that is not perfectly rational, but is only somewhat rational, than I can simply say that at some point the agent stops recursively &#8220;imagining&#8221; the future, and works on the approximate sum.</p>
<p>The problem with this, however, is that many games are not won until very late (a.k.a. after many moves). Consider a game I invented to test my agent:</p>
<blockquote><h2 style="margin-bottom: 2px; padding-bottom: 0px;">Counting</h2>
<h3 style="padding-top: 0px;">or perhaps &#8220;Lineland Treasurehunt&#8221;</h3>
<p>You are at a position, and your goal is to get to another position. Possible moves are &#8220;walk forward&#8221; and &#8220;walk backwards&#8221;. Oh, and the spot you start at is called &#8220;0&#8243; and the goal spot is called &#8220;100&#8243;. Each time you walk forward your position increases by one, and each time you walk backward, it decreases by one.</p></blockquote>
<p>The problem is that, as defined, there&#8217;s no base utility in being at &#8220;99&#8243; over &#8220;0&#8243;. The only utility in being at &#8220;99&#8243; is in the consequence of being able to go to &#8220;100&#8243; on the next turn. If each step is a move, then the agent needs to model 100 moves in the future to have any clue what to do. Now, imagine how many moves one would need to look-ahead in order to see a victory in chess. For a perfectly rational agent it&#8217;s a mathematical possibility, but for something that can be written in code it&#8217;s just impractically beyond the maximum recursion depth.</p>
<p>The only way an agent with a maximum look-ahead of 5 moves can beat the Counting game is to get the hint &#8220;high numbers are better than low ones&#8221;. According to the rules, this is not intrinsically true, but it&#8217;s an approximation of truth that allows the agent to perform under normal circumstances. It is a <em>heuristic</em>, and it is of vital importance.</p>
<p>To be more precise, a heuristic is a component of the utility function that has been added because it is a good approximation of future utility (i.e. the goal). Some heuristics in chess are &#8220;control the center of the board&#8221;, &#8220;capture (non-king) pieces&#8221;, and &#8220;threaten many squares&#8221;. Clearly you don&#8217;t want to focus on doing any of these if you have the opportunity to checkmate, but because checkmating takes time, it&#8217;s cognitively easier to aim for any of these more apparent mini-goals.</p>
<p>The learning of heuristics seems like the most important aspect of practical rationality, and it&#8217;s something I&#8217;m looking forward to thinking about more. It seems plausible to me that the emotion of happiness in humans may be a heuristic-encoding signal. When we&#8217;re happy or sad, we say &#8220;What&#8217;d I just do? Remember presence/absence of that as a heuristic!&#8221;. Just speculating&#8230;</p>
<p>Here&#8217;s my rational agent in Haskell: <a href="http://raelifin.com/files/code/rationality.tar.gz">http://raelifin.com/files/code/rationality.tar.gz</a></p>
<p>(I also wrote a version in Java with many more example games, but I&#8217;m working on tuning that, and it&#8217;s not really suitable for posting at the moment. The Haskell is also much cleaner/prettier.)</p>
<p>N.B. This is almost certainly old ground. Reinforcement learning or alpha-beta pruning almost certainly would be good things for me to study. My ignorance on the subject is not meant to imply that there&#8217;s not already a lot out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/simple-rationality/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Butchering Haskell</title>
		<link>http://raelifin.com/code/butchering-haskell/</link>
		<comments>http://raelifin.com/code/butchering-haskell/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 20:41:26 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[RCRPG]]></category>
		<category><![CDATA[text-based]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=710</guid>
		<description><![CDATA[I picked up Haskell just under two weeks ago, and in my free time I&#8217;ve been implementing RCRPG in it, much like I did with Python. You can see my code at http://rosettacode.org/wiki/RCRPG/Haskell. It&#8217;s really not very pretty though. My mind is clearly still stuck on a procedural, object-oriented approach.]]></description>
			<content:encoded><![CDATA[<p>I picked up Haskell just under two weeks ago, and in my free time I&#8217;ve been implementing <a href="http://rosettacode.org/wiki/RCRPG">RCRPG</a> in it, much like I did with Python. You can see my code at <a href="http://rosettacode.org/wiki/RCRPG/Haskell">http://rosettacode.org/wiki/RCRPG/Haskell</a>. It&#8217;s really not very pretty though. My mind is clearly still stuck on a procedural, object-oriented approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/butchering-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autocell 2</title>
		<link>http://raelifin.com/code/autocell-2/</link>
		<comments>http://raelifin.com/code/autocell-2/#comments</comments>
		<pubDate>Sat, 29 May 2010 16:42:22 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Autocell]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=378</guid>
		<description><![CDATA[I&#8217;ve updated Autocell to version 2. In addition to cleaning up the code, adding better error handling, and (I hope) improving the interface slightly, I&#8217;ve made the following changes to the rules: You can now set cells to be drawn as images. Defining the image a cell should use is as simple as making a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://raelifin.com/files/autocell/autocell2/">I&#8217;ve updated Autocell to version 2</a>. In addition to cleaning up the code, adding better error handling, and (I hope) improving the interface slightly, I&#8217;ve made the following changes to the rules:</p>
<ul>
<li>You can now set cells to be drawn as images. Defining the image a cell should use is as simple as making a rule of &#8220;draw &lt;CELLTYPE&gt; &lt;URL&gt;&#8221; (See Langton&#8217;s Ant for example.)</li>
<li>The directions northeast, northwest, etc. have been added, as have fareast, farnorth, etc. The &#8220;far____&#8221; directions refer to cells two steps away.</li>
<li>The special noun &#8220;neighbors&#8221; now includes the NULL cells at the border.</li>
<li>New verbs &#8220;cellAt&#8221; and &#8220;neighborsOf&#8221; have been added. They both take a 2-by-1 array ([x,y]) of the cell in question as their right-parameter. The &#8220;cellAt&#8221; verb returns the type of the cell in question, while &#8220;neighborsOf&#8221; returns the set of neighbors.</li>
<li>A new two-parameter verb &#8220;+&#8221; has been added. Right now it only operates on the 2-by-1 coordinate arrays discussed above. (Example: [1,-10] + [23,7] = [24,-3])</li>
<li>In the same vein, a new special noun called &#8220;thisPos&#8221; has been added. It is the coordinates of the cell being evaluated.</li>
</ul>
<p>That&#8217;s all!</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/autocell-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Learning Python</title>
		<link>http://raelifin.com/code/learning-python/</link>
		<comments>http://raelifin.com/code/learning-python/#comments</comments>
		<pubDate>Wed, 26 May 2010 18:10:36 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[RCRPG]]></category>
		<category><![CDATA[text-based]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=375</guid>
		<description><![CDATA[It&#8217;s not that interesting, but I made a little one-player text-based RPG in python (3.1.2) this morning/last night. I&#8217;m happy with it, just because it&#8217;s the largest thing I&#8217;ve ever done in python. The whole thing is based off of this blog post. You can get the source code here: http://raelifin.com/files/code/rcrpg.py It&#8217;s all public domain, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not that interesting, but I made a little one-player text-based RPG in python (3.1.2) this morning/last night. I&#8217;m happy with it, just because it&#8217;s the largest thing I&#8217;ve ever done in python. The whole thing is <a href="http://web.archive.org/web/20080212201605/http://shortcircuit.us/muddy-kinda-like-a-mud-but-single-player/">based off of this blog post</a>. You can get the source code here: <a href="http://raelifin.com/files/code/rcrpg.py">http://raelifin.com/files/code/rcrpg.py</a><br />
It&#8217;s all public domain, but I like credit (yada, yada).</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/learning-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mini-Project: Autocell</title>
		<link>http://raelifin.com/code/mini-project-autocell/</link>
		<comments>http://raelifin.com/code/mini-project-autocell/#comments</comments>
		<pubDate>Thu, 20 May 2010 06:12:27 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Autocell]]></category>
		<category><![CDATA[cellular automata]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rapid-prototype]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=356</guid>
		<description><![CDATA[My latest quick project was to write a basic scripting language for building cellular automata. The framework is built on javascript, and I made a nice little interface to go with it. As long as you&#8217;re using a browser that isn&#8217;t terrible, you can check it out here. All the code on that page except [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin: 0 0 10px 10px; float: right;" src="http://raelifin.com/files/screenshots/autocell_screenshot.png"/>My latest quick project was to write a basic scripting language for building <a href="http://en.wikipedia.org/wiki/Cellular_automata">cellular automata</a>. The framework is built on javascript, and I made a nice little interface to go with it. As long as you&#8217;re using a browser that isn&#8217;t terrible, you can <a href="http://raelifin.com/files/autocell1.html">check it out here</a>. All the code on that page except the utility functions is public domain, but please give credit where credit is due. If you end up examining the source, I apologize for the mess; I was trying to fit everything in one file, and not use jQuery or other libraries.</p>
<p><span id="more-356"></span></p>
<p>For those interested in writing your own automata, here is a quick guide to the syntax:<br />
An automaton is composed of rules. Each rule is designated by a new line. Double slash (//) or pound (#) designate a commented line.<br />
Each rule looks something like <strong>BLACK->WHITE: 1 = 2</strong><br />
BLACK is the type of cell that the rule applies to, WHITE is the type of cell that it will become. After the colon is a statement that must resolve to a single value, or &#8220;noun&#8221;.<br />
Nouns can be strings, numbers, true/false, JSON arrays, &#8220;neighbors&#8221;, or any of the cardinal directions (lower-case). The noun &#8220;neighbors&#8221; is a special noun which is a JSON array with values equal to the types of the surrounding tiles (in eight directions). The special nouns &#8220;west&#8221;, &#8220;north&#8221;, &#8220;south&#8221; and &#8220;east&#8221; are equal to the type in that direction, or &#8220;NULL&#8221; if at the edge.<br />
Nouns can be acted upon by the following &#8220;verbs&#8221;:
<ul>
<li><strong>=</strong>, <strong>></strong>, <strong><</strong> &#8212; Basic comparison operators. They behave like their counterparts in javascript (except for =, which is comparison, not assignment). &#8212; example: &#8220;1 > 2 = false&#8221; (returns true)</li>
<li><strong>or</strong>, <strong>and</strong> &#8212; Low-priority logic operators. These behave like || and &#038;&#038; in most languages. Low-priority means they are evaluated after other verbs. &#8212; example: &#8220;true and false or true&#8221; (returns true)</li>
<li><strong>not</strong> &#8212; Inverts the boolean value to the right. If the value to the right is non-boolean, it is cast to a boolean just like ! in javascript. &#8212; example: &#8220;not true&#8221; (returns false)</li>
<li><strong>contains</strong>, <strong>isIn</strong> &#8212; Check if a value is contained in an array. The two verbs are identical except in the order of their parameters (&#8220;value isIn array&#8221;, or &#8220;array contains value&#8221;). &#8212; example: &#8220;[1,2,3] contains 0&#8243; (returns false)</li>
<li><strong>count</strong> &#8212; Changes the noun on the right from an array to an integer. &#8212; example: &#8220;count [0,1,2]&#8221; (returns 3)</li>
<li><strong>ofType</strong> &#8212; Filters an array on the left to only contain the value on the right. &#8212; example: &#8220;[0,0,0,1,2,3] ofType 0&#8243; (returns [0,0,0])</li>
<li><strong>echo</strong> &#8212; Makes a popup containing the value on the right. Does not change the data. This verb isn&#8217;t very useful, and can flood your browser with popups if you aren&#8217;t careful.</li>
</ul>
<p>Verbs are evaluated from left-to-right, but you can use parentheses to change the order of operations. More examples can be found by loading the prebuilt automata.</p>
<p>I know the interface is a bit hard to use, but if you make anything (even if it&#8217;s pretty trivial) please leave a comment! You can export boards as well, so feel free to share interesting formations in <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway&#8217;s Game of Life</a>, <a href="http://en.wikipedia.org/wiki/Wireworld">Wireworld</a>, or others.</p>
<p>On a related note, this talk by Wolfram is not to be missed:<br />
<object width="446" height="326"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talks/dynamic/StephenWolfram_2010-medium.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/StephenWolfram-2010.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=843&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=stephen_wolfram_computing_a_theory_of_everything;year=2010;theme=tales_of_invention;theme=bold_predictions_stern_warnings;theme=what_s_next_in_tech;theme=new_on_ted_com;theme=a_taste_of_ted2010;theme=unconventional_explanations;theme=art_unusual;theme=inspired_by_nature;event=TED2010;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="446" height="326" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talks/dynamic/StephenWolfram_2010-medium.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/StephenWolfram-2010.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=843&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=stephen_wolfram_computing_a_theory_of_everything;year=2010;theme=tales_of_invention;theme=bold_predictions_stern_warnings;theme=what_s_next_in_tech;theme=new_on_ted_com;theme=a_taste_of_ted2010;theme=unconventional_explanations;theme=art_unusual;theme=inspired_by_nature;event=TED2010;"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/mini-project-autocell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mini-Project: Think Like a &#8220;Good Old AI&#8221; Researcher</title>
		<link>http://raelifin.com/thoughts/mini-project-think-like-gofai-researcher/</link>
		<comments>http://raelifin.com/thoughts/mini-project-think-like-gofai-researcher/#comments</comments>
		<pubDate>Wed, 12 May 2010 05:17:49 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[associative database]]></category>
		<category><![CDATA[GOFAI]]></category>
		<category><![CDATA[knowledge]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ontology]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[world-building]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=313</guid>
		<description><![CDATA[Those who&#8217;ve known me for many years will know that I love to create fictional worlds. They represent the epitome of complicated systems, with all of the messiness and detail of the real world combined with the flexibility required to satisfy my creative desires. Because of the immensity of world-building, at a certain point it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://phaedoras.raelifin.com/?q=describe+S%C3%A1r%C3%ADb%C3%A1"><img style="border: thick solid black; float: right; margin: 0 0 10px 10px; width: 250px;" src="http://raelifin.com/files/screenshots/family-tree.png" alt="Example Family Tree" /></a>Those who&#8217;ve known me for many years will know that I love to <a href="http://thecbg.org/news.php">create fictional worlds</a>. They represent the epitome of complicated systems, with all of the messiness and detail of the real world combined with the flexibility required to satisfy my creative desires. Because of the immensity of world-building, at a certain point it is absolutely necessary for the creator to maintain a solid body of notes on the various people, places, things, etc. in the setting. Worlds are nonlinear by nature, so it is very common to use a wiki to write things down, and it was in re-reading my own wiki-notes that I got an idea for another way to do things.</p>
<p><span id="more-313"></span></p>
<p>Specifically, I began to notice how few links my notes contained, and the difficulty I might have in changing small details (like names) across many pages. Wouldn&#8217;t it be nice, I thought, if I were able to tell my computer about my world, and have the computer organize and maintain my notes in a way that let me quickly and easily extract and change the underlying facts. Essentially, I was thinking about automating the world-building process by reducing a world into a data and making code to manipulate and present that data.</p>
<p>Because I had heard good things about <a href="http://en.wikipedia.org/wiki/Associative_model_of_data">associative databases</a>, I built one to handle the facts of the world and began entering items like<br />
<code style="margin-left: 20px;">Kogámos is_child_of Sáríbá</code><br />
(Yes, I know that&#8217;s a lot of accents). Associative databases (with exceptions, I&#8217;m sure) represent data <a href="http://en.wikipedia.org/wiki/Ontology">ontologically</a> (that is, as a collection of factual claims about entities), and in this way resemble the data structures of <a href="http://en.wikipedia.org/wiki/GOFAI">Good Old-Fashioned AI</a>*. Now, before I started this project I was very skeptical about logic-based <a href="http://en.wikipedia.org/wiki/Strong_AI">AGI</a>, but I knew that in some domains, (such as <a href="http://en.wikipedia.org/wiki/Expert_System">Expert Systems</a>) logic based <em>narrow</em> AI had become successful, so I set about exploring whether this was one such domain.</p>
<p style="color: #444">* &#8211; Really, this structure is common to all logic-based AI, even fuzzy-logic, modern approaches like <a href="http://sites.google.com/site/narswang/home">NARS</a>. Much of the criticism that follows can be applied to any sort of artificial reasoning system.</p>
<p>Before I go on, however, I&#8217;d like to share a documentary about the semantic web. It&#8217;s related, and I&#8217;ll be talking about it, but it&#8217;s 15 minutes and you could probably skip it if you&#8217;re familiar with the concept.</p>
<p style="text-align: center"><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11529540&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11529540&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object></p>
<p>With the possible exception of being able to make meta-facts (that is, facts about facts), the eventual structure of the semantic web closely resembles that of an associative database. In fact, I&#8217;m sure that facebook has a piece of data saying<br />
<code style="margin-left: 20px;">Max_Harms is_child_of Tracy_Harms</code><br />
or something to that effect, right now. And like my project, the semantic web seeks to represent data about an entire world, not just a highly-restricted domain.</p>
<p>My project has some big advantages, though. The biggest is probably that all the information given might as well be coming from God. If the world-creator says that rivers run uphill, that&#8217;s just the way it works. Thus there is no need to model confidence in facts entered. Secondly, the system doesn&#8217;t actually have to act; it simply has to store and present the data in an intelligent way.</p>
<p>One of the early things I noticed in my exploration is just how fun it is to see the computer answer questions. Logic-based AI is very attractive because it takes hardly any work before you can ask it things like &#8220;Who is the child of Sáríbá?&#8221; and it will give you the right answer. I ended up spending lots of time asking questions that I already knew the answer to,  just because it was fun whenever the computer was right.</p>
<blockquote><p>One of the biggest hurdles in the transition from a Reductionist to a Holistic stance is that the Reductionist stance works so well for simple problems, and thus is very seductive to beginners.<span style="float: right">- <a href="http://monicasmind.com/">Monica Anderson</a></span></p></blockquote>
<p>The problem here is that answering simple questions based on simple rules from entered facts doesn&#8217;t mean squat. It&#8217;s about as useful as writing the information in a text file and using <a href="http://en.wikipedia.org/wiki/Regular_expression">regex</a>.</p>
<p>It gets worse than that, though. As mentioned before, worlds are messy and complicated. If the problem was as simple as generating a family tree, or making Venn diagrams, we&#8217;d be okay. But how do you represent something as nuanced as &#8220;Sally likes to spend time downtown, except on the weekend, when she finds it too crowded&#8221;? Such things are simple for us to remember because they tie into our experiences. To illustrate what I mean, imagine the similar phrase &#8220;Queue is angry about rowing in Vah, except when floating, when torque is standard.&#8221; This statement has no connection with our common experience, and because we do not understand it, we cannot store it easily. This is the same problem as that confronting the semantic web. We can pour in data until we die, and the system still wouldn&#8217;t &#8220;get it&#8221;.</p>
<blockquote><p>If a programmer attempts to describe the world to a Logic based AI, for instance by creating ontologies, he’ll never finish the task. The world is too rich. The Cyc project – the largest and most famous AI project ever undertaken – has been trying to describe the world using predicate calculus for decades; it is the poster project for Reductionist approaches to AI. But Cyc will never approach anything worthy of the term “Intelligence”. It has been told many things and can recite many definitions but Understands nothing. This is the difference between “Instructionist” top down education and “Constructionist” bottom up learning – a distinction poorly understood even in human education.<span style="float: right">- <a href="http://monicasmind.com/?p=188">Monica Anderson</a></span></p></blockquote>
<p>Even in a task as basic as storing and retrieving information we still need the computer to understand what it&#8217;s doing beyond tasks of relative simplicity. This is because knowing about the world falls into a large class of problems that are fundamentally impossible without General Intelligence**. Other problems in this category include using natural language, navigating complex environments, and behaving in socially acceptable ways. As hard as we may try, until Strong AI is solved, a chatbot will always be a <a href="http://www.cleverbot.com/">mimicking machine</a>, a database will always fail in complex domains, and humans will be forced adapt to robots (instead of robots adapting to humans).</p>
<p style="color: #444">** &#8211; It may be possible for a vast enough intelligence to make a system so complex that it&#8217;d be able to handle one of these domains. I don&#8217;t think even large numbers of humans would be smart enough to make one, though.</p>
<p>Even with my increased dislike of logical systems, I&#8217;m quite happy with what I was able to make in the few days I spent building my database. You can <a href="http://phaedoras.raelifin.com/">check out the results</a> yourself, or even <a href="http://phaedoras.raelifin.com/input.html">add and delete facts</a>. The database will be restored to a backup state twice a day (not sure what timezone my server is in), so don&#8217;t worry about making a mess.</p>
<p>Search commands:
<ul>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=describe+Ix">describe X</a>&#8221; = get all facts relating to X</li>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=list+Ix+is+%3F">list X is ?</a>&#8221; = get all items that X is</li>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=list+Ix+is_child_of+%3F">list X is_child_of ?</a>&#8221; = get the parents of X</li>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=list+%3F+is|has+om%C3%A1ku">list ? is|has X</a>&#8221; = get everything that is or has X</li>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=list+%3F+imports+*+%3F+is+geographical_area">list ? imports * ? is geographical_area</a>&#8221; = gets geographical areas that import anything</li>
<li>&#8220;<a href="http://phaedoras.raelifin.com/?q=infer">infer</a>&#8221; = list suggestions for facts, based on correlations</li>
</ul>
<p><a href="http://raelifin.com/files/code/WorldDatabase.zip">Source code is here</a>. Everything I wrote (files in the root directory) is public domain. Attribution is appreciated.</p>
<p>(P.S. I&#8217;m a big supporter of the semantic web, and doubly so for open data. The criticisms expressed in this post are against the idea that it is possible to intelligently know lots about the world using ontological representations. Links are data, and that data is important, even if that data isn&#8217;t knowledge in itself.)</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/thoughts/mini-project-think-like-gofai-researcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First GoiD Task</title>
		<link>http://raelifin.com/code/first-goid-task/</link>
		<comments>http://raelifin.com/code/first-goid-task/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 20:40:52 +0000</pubDate>
		<dc:creator>Raelifin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[GoiD]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://raelifin.com/?p=304</guid>
		<description><![CDATA[In case anyone&#8217;s wondering what I&#8217;m up to, my first task on the Game of Intelligent Design was published today. If you&#8217;re familiar with javascript and like the the idea of programming virtual robots, go play!]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin: 10px;" src="http://raelifin.com/files/screenshots/GoiDMaze.png" alt="GoiD Maze Screenshot" />In case anyone&#8217;s wondering what I&#8217;m up to, my first task on the <a href="http://gameofid.com/">Game of Intelligent Design</a> was published today. If you&#8217;re familiar with javascript and like the the idea of programming virtual robots, <a href="http://gameofid.com/play/maze">go play</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://raelifin.com/code/first-goid-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

