<?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>Master Baboon &#187; Artificial Life</title>
	<atom:link href="http://www.masterbaboon.com/category/artificial-life/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.masterbaboon.com</link>
	<description>The sea of the simulation</description>
	<lastBuildDate>Wed, 16 Jun 2010 22:50:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simulated evolution</title>
		<link>http://www.masterbaboon.com/2009/02/simulated-evolution/</link>
		<comments>http://www.masterbaboon.com/2009/02/simulated-evolution/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 21:25:28 +0000</pubDate>
		<dc:creator>pietro</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Artificial Life]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=35</guid>
		<description><![CDATA[Here&#8217;s another classic from the 80&#8217;s: an artificial life simulation, where bugs move on a virtual Petri dish, hunting for bacteria. If they manage to survive until adulthood, and accumulate enough energy from bacteria, the bugs reproduce and generate two copies of themselves. In the reproduction process, the genetic code undergoes small mutations, so that [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another classic from the 80&#8217;s: an artificial life simulation, where bugs move on a virtual Petri dish, hunting for bacteria. If they manage to survive until adulthood, and accumulate enough energy from bacteria, the bugs reproduce and generate two copies of themselves. In the reproduction process, the genetic code undergoes small mutations, so that the baby-bugs are not exact copies of their mother.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_simulated_evolution_767041724"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/flashes/simulated_evolution.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flashes/simulated_evolution.swf"
			name="fm_simulated_evolution_767041724"
			width="550"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The genetic code of bugs determines the way they move around. It consists of six numbers that give the probability that the bug will move  in one of six directions (forward, soft/hard right, backwards, soft/hard left) at any point in time. For example, a bug with code [5, 0, 5, 0, 0, 0] would move forward 50% of the time (relative to his current direction), and for the rest of the time it would take a hard turn right (120 degrees on its right) and move. Mutations change one of the numbers in the code by +/- 2.</p>
<p>Individual with a genetic code unfit to deal with competition for food eventually die away, and by the law of natural selection the population of bugs adapts to efficiently navigate their environment to collect bacteria. The optimal strategy will depend on the environment: if the bacteria are randomly scattered around, the optimal behavior is to &#8220;slide&#8221; forward for some time before taking a turn. If instead bacteria are concentrated on a small patch, a surer way for a bug to survive is to rotate on itself, to make sure not to get too far.</p>
<p>This idea was described by<a href="http://en.wikipedia.org/wiki/Alexander_Dewdney" target="_blank"> A.K. Dewdney</a> in in the article &#8220;Simulated evolution: wherein bugs learn to hunt bacteria&#8221; in 1989  in <em>Scientific American</em> (May, pp. 138-141). The flash application above is my version of Dewdney&#8217;s simulation, implemented in ActionScript 3 (<a href="flashes/simulated_evolution.zip">click here to download the code</a>). It is based on the SpatialDatabase class <a href="http://www.masterbaboon.com/2009/02/spatial-database-for-collision-detection/" target="_self">described in the previous post</a>, so you might want to have a look at the code if you&#8217;re curious about how it can be used in practice.</p>
<p>As you might have guessed, the yellow circles are bacteria, while the green ones are bugs. Bugs start to fade when their energy is low; if they don&#8217;t find food fast enough, they eventually disappear into nothing. The button &#8220;Garden of Eden&#8221; activates a small region with high bacterial growth, you can switch it on to see how fast the bugs adapt to the new environment. It usually takes around 20 generations for them to show a highly specialized behavior.</p>
<p>Have fun!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5929969675637192";
google_ad_slot = "7572213318";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2009/02/simulated-evolution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>2D Cellular Automata</title>
		<link>http://www.masterbaboon.com/2009/02/2d-cellular-automata/</link>
		<comments>http://www.masterbaboon.com/2009/02/2d-cellular-automata/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 03:30:46 +0000</pubDate>
		<dc:creator>pietro</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Artificial Life]]></category>
		<category><![CDATA[Cellular Automaton]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=7</guid>
		<description><![CDATA[I decided to get my feet wet with Flash + ActionScript programming with a classic of the 80&#8217;s: 2-dimensional Cellular Automata!
A 2D CA is a grid of cells, each of which can be in either an &#8220;alive&#8221; or &#8220;dead&#8221; state. The state of each cell evolves in time, according to simple update rules based on [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to get my feet wet with Flash + ActionScript programming with a classic of the 80&#8217;s: 2-dimensional Cellular Automata!</p>
<p>A 2D CA is a grid of cells, each of which can be in either an &#8220;alive&#8221; or &#8220;dead&#8221; state. The state of each cell evolves in time, according to simple update rules based on the number of alive neighbors (each cell has 9 neighbors). Briefly:</p>
<ul>
<li>The update rule defines the overall behavior of the CA, and is given by two lists of numbers, S for &#8220;Survival&#8221; and B for &#8220;Birth&#8221;</li>
<li>If the cell is alive and the number of active neighbors is not on the S list, the cell dies</li>
<li>If the cell is dead and the number of active neighbors is on the B list, the cell becomes alive</li>
</ul>
<p>The standard notation for the rules is S/B. For example, 23/3 (S=[2,3], B=[3]) corresponds to the celebrated <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank">Game of Life</a> by Conway, that produces ever-changing patterns of activity. The reason CAs are so famous is because they are a perfect example of how simple, local rules can produce complex, global behavior.</p>
<p>In the Flash application below, you can experiment with different rules by (un)checking the checkbox on the right side. <a href="http://en.wikipedia.org/wiki/Life-like_cellular_automata" target="_blank">This wikipedia page</a> has a list of rules known to produce interesting behavior.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ca2d_645587256"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/flashes/ca2d.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flashes/ca2d.swf"
			name="fm_ca2d_645587256"
			width="550"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Short instructions: click on the grid elements to switch them between dead and alive states. On the right side, you can add numbers to the Survival and Birth list, clear the CA to a blank state, or set the cells to a random state.</p>
<h4>Actionscript notes</h4>
<p>You can download the AS3 and the Flash library <a title="AS3 core for 2D CAs" href="/flashes/ca2d.zip">here</a>. This is my first ActionScript project, so everything was new to me. The hardest part for me was to figure out how to link the interface I designed in the Flash IDE with the AS3 classes. I think I found a decent solution in the end, but let me know if you have suggestion to improve the code.</p>
<p>The BinaryCA class is an independent class to manage 2D CAs. To store the CA cells I based the core on the Array2 class from polygonal labs&#8217; <a href="http://lab.polygonal.de/ds/" target="_blank">AS3DS data structures library</a>.</p>
<p>Cellular Automata&#8230;  so retro!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5929969675637192";
google_ad_slot = "7572213318";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2009/02/2d-cellular-automata/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
