<?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>GLOW Interactive &#124; BLOG &#187; Evolution</title>
	<atom:link href="http://blog.glowinteractive.com/tag/evolution/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.glowinteractive.com</link>
	<description>codify, media, gaming, industry ramblings, finance</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:05:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Teaching Worms to Crawl Using Genetic Algorithms</title>
		<link>http://blog.glowinteractive.com/2010/02/teaching-worms-to-crawl-using-genetic-algorithms/</link>
		<comments>http://blog.glowinteractive.com/2010/02/teaching-worms-to-crawl-using-genetic-algorithms/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 13:27:28 +0000</pubDate>
		<dc:creator>Jan Kalis</dc:creator>
				<category><![CDATA[Codify]]></category>
		<category><![CDATA[Crawling-Creatures]]></category>
		<category><![CDATA[Emergent-Behavior]]></category>
		<category><![CDATA[Evolution]]></category>
		<category><![CDATA[Genetic-Algorithms]]></category>
		<category><![CDATA[Neural-Networks]]></category>

		<guid isPermaLink="false">http://blog.glowinteractive.com/?p=688</guid>
		<description><![CDATA[This is a follow-up to the first article about training creatures to walk using neural networks and genetic algorithms. The next creature I decided to train is a worm. Here's the result (generation ~200).]]></description>
			<content:encoded><![CDATA[<p>This is a follow-up to <a href="http://blog.glowinteractive.com/index.php/2010/02/on-using-genetic-algorithm-to-train-neural-network-driven-creatues-to-walk-in-flash/">the first article</a> about training creatures to walk using neural networks and genetic algorithms. The next creature I decided to train is a worm. Here&#8217;s the result (generation ~200).</p>
<p><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/worms.swf" target="_blank"><img class="alignnone size-full wp-image-773" title="codify_genetic_algorithms_worms" src="http://blog.glowinteractive.com/wp-content/uploads/2010/02/codify_genetic_algorithms_worms.jpg" alt="Genetic Algorithms - Worms" width="670" height="320" /></a></p>
<p><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/creatures.zip">Get the source code</a> (contains the walking creatures, too).</p>
<p>PS: Again, if you happen to evolve an interesting locomotion, send me your code/swf and I&#8217;ll post it here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glowinteractive.com/2010/02/teaching-worms-to-crawl-using-genetic-algorithms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>On Using Genetic Algorithms to Train Neural Network Driven Creatures to Walk in Flash</title>
		<link>http://blog.glowinteractive.com/2010/02/on-using-genetic-algorithm-to-train-neural-network-driven-creatues-to-walk-in-flash/</link>
		<comments>http://blog.glowinteractive.com/2010/02/on-using-genetic-algorithm-to-train-neural-network-driven-creatues-to-walk-in-flash/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 04:32:26 +0000</pubDate>
		<dc:creator>Jan Kalis</dc:creator>
				<category><![CDATA[Codify]]></category>
		<category><![CDATA[Emergent-Behavior]]></category>
		<category><![CDATA[Evolution]]></category>
		<category><![CDATA[Genetic-Algorithms]]></category>
		<category><![CDATA[Neural-Networks]]></category>
		<category><![CDATA[Walking-Creatures]]></category>

		<guid isPermaLink="false">http://blog.glowinteractive.com/?p=595</guid>
		<description><![CDATA[I remember seeing Karl Sims' video Evolved Virtual Creatures a long time ago. I was completely stunned but unfortunately forgot about it for many years. I was reminded of it again last year when reading about training neural networks using genetic algorithms and decided to evolve my own creatures.]]></description>
			<content:encoded><![CDATA[<p>I remember seeing <a href="Evolved Virtual Creatures?phpMyAdmin=ON7xtWcaZ2dG5aY8FuKOMbfOZk5">Karl Sims&#8217; video Evolved Virtual Creatures</a> a long time ago. I was completely stunned but unfortunately forgot about it for many years. I was reminded of it again last year when reading about training <a href="http://en.wikipedia.org/wiki/Neural_network">neural networks</a> using <a href="http://en.wikipedia.org/wiki/Genetic_algorithm">genetic algorithms</a> (Tom Mitchell&#8217;s <a href="http://www.cs.cmu.edu/~tom/mlbook.html">Machine Learning</a> is highly recommended) and decided to evolve my own creatures.</p>
<p><strong>Preparation</strong></p>
<p><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/ants.swf">Here is the first demo.</a></p>
<p><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/ants.swf" target="_blank"><img class="alignnone size-full wp-image-770" title="codify_genetic_algorithms_ants" src="http://blog.glowinteractive.com/wp-content/uploads/2010/02/codify_genetic_algorithms_ants.jpg" alt="Genetic Algorithms - Ants" width="670" height="320" /></a></p>
<p>The task is to teach an ant to get to the end of the L-shaped corridor as fast as possible. All an ant is allowed to do (every frame) is rotate freely and turn on its forward thrust (acceleration). Ant&#8217;s behavior is encoded in its DNA consisting of several genes. Every gene prescribes what an ant does in the frame that corresponds to the index of the gene in the DNA. Specifically, each gene is a 3-bit number encoding the ant&#8217;s possible behavior:</p>
<pre class="brush: as3; title: ;">
var gene:int = dna[simulationStep];
var acceleration:Boolean = gene &amp; 1;
var turnPositive:Boolean = gene &amp; 2;
var turnNegative:Boolean = gene &amp; 4;
</pre>
<p>The <a href="http://en.wikipedia.org/wiki/Genetic_operator">genetic operators</a> used are not tuned for this particular application. What you see on the screen is one population of 100 individuals. It takes time but if you let them learn you&#8217;ll see that in the end they achieve the goal in the most optimal way.</p>
<p><strong>Evolution</strong></p>
<p>Encouraged by the result (also, it only took about 2 hours to code) I wanted more. Without further ado I present the <strong><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/walking_gen0300.swf">walking creatures</a><span style="font-weight: normal;"> (after 300 generations)</span></strong>.</p>
<p><a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/walking_gen0300.swf" target="_blank"><img class="alignnone size-full wp-image-771" title="codify_genetic_algorithms_walking" src="http://blog.glowinteractive.com/wp-content/uploads/2010/02/codify_genetic_algorithms_walking.jpg" alt="Genetic Algorithms - Walking" width="670" height="320" /></a></p>
<p>The task here is to give physics-based (thank you, <a href="http://box2dflash.sourceforge.net/">Box2D</a>!) ragdoll figures brains to be able to move a certain distance. Following Ngo and Marks&#8217; paper <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.2303">Spacetime Constrains Revisited</a> I set out to make my own creatures in Flash. In short, I am using a genetic algorithm to train a neural network that controls motors in the creature&#8217;s joints. The <a href="http://en.wikipedia.org/wiki/Fitness_function">fitness function</a> is plainly how far a creature can get within a certain amount of time. The neural network used is very simple &#8211; it&#8217;s a single layer <a href="http://en.wikipedia.org/wiki/Feedforward_neural_network">feed-forward</a> neural network with the inputs being the angles at every joint, vertical velocity and horizontal distance traveled and the outputs the speed of the motor and the target angle of every joint.</p>
<p><strong>Results</strong></p>
<p>I was really happy to see results only after about 300 generations (it took a night though): a frog. Excited, I ran it again and again and interestingly, I only got frogs. I tried to change the fitness function a bit so that the creatures that touch the ground are penalized but didn&#8217;t get anything interesting. Also tried to make the torso a bit heavier and an inchworm-like creature evolved. If you like, you can try to evolve your own creatures, <a href="http://blog.glowinteractive.com/wp-content/themes/glow/flash/jan/genetic/walking_gen0000.swf">here&#8217;s the link to first generation</a> (with a little bit of creativistic randomization to start with). At the end of every generation, the best DNA is <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary808.html">traced </a> so if you happen to get some interesting locomotion, please send it to me and I&#8217;ll post it here. (Source code to follow after a brief clean-up.)</p>
<p><strong><span style="color: #ff0000;">Edit:</span></strong><strong> </strong>Get the source code in the <a href="http://blog.glowinteractive.com/index.php/2010/02/teaching-worms-to-crawl-using-genetic-algorithms/">next GA post</a>.</p>
<p><strong>What&#8217;s Next</strong></p>
<p>My plan is to try what behaviors will emerge with different shapes, physics set up, fitness functions or selection algorithms.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glowinteractive.com/2010/02/on-using-genetic-algorithm-to-train-neural-network-driven-creatues-to-walk-in-flash/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

