<?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>Jacob Repp &#187; meetup</title>
	<atom:link href="http://jrepp.com/category/meetup/feed/" rel="self" type="application/rss+xml" />
	<link>http://jrepp.com</link>
	<description>Game programming, music and life</description>
	<lastBuildDate>Fri, 16 Dec 2011 06:03:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Austin Ruby Meetup 1-17-2008</title>
		<link>http://jrepp.com/2008/01/17/austin-ruby-meetup-1-17-2008/</link>
		<comments>http://jrepp.com/2008/01/17/austin-ruby-meetup-1-17-2008/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 06:14:52 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[meetup]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jrepp.com/2008/01/17/austin-ruby-meetup-1-17-2008/</guid>
		<description><![CDATA[We had a good time at the meetup tonight. Steven and I busted out the laptops and shared some code and ideas. He had a nice rails app for learning Latin that supported a tagging architecture. I know next to &#8230; <a href="http://jrepp.com/2008/01/17/austin-ruby-meetup-1-17-2008/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We had a good time at <a href="http://ruby.meetup.com/97/">the meetup tonight</a>. Steven and I busted out the laptops and shared some code and ideas. He had a nice rails app for learning Latin that supported a tagging architecture. I know next to nothing about rails so it was interesting to see the interactive console and scaffolding at work. We talked a bit about lisp compilation, writing, philosophy and open source vs. closed source. I demonstrated how you can specialize a method in SBCL using <strong>THE</strong> type declarations and the difference it makes in the generated machine code via <strong>DISASSEMBLE</strong>. As usual it was entertaining and enriching. If you&#8217;re in the Austin area and want to talk Ruby, Lisp, Python, C or whatever you should consider joining us.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2008/01/17/austin-ruby-meetup-1-17-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing a Finite State Machine with a Ruby Domain Specific Language</title>
		<link>http://jrepp.com/2007/08/14/implementing-a-finite-state-machine-with-a-ruby-domain-specific-language/</link>
		<comments>http://jrepp.com/2007/08/14/implementing-a-finite-state-machine-with-a-ruby-domain-specific-language/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 09:12:21 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[austin]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jrepp.com/2007/08/14/implementing-a-finite-state-machine-with-a-ruby-domain-specific-language/</guid>
		<description><![CDATA[DSL-FSM.. that kinda sounds like some wierd internet sub-culture. It stands for domain specific language &#8211; finite state machine. I proposed both topics as presentation material for the austin-ruby group that I meet with once a month. Steven Harms the &#8230; <a href="http://jrepp.com/2007/08/14/implementing-a-finite-state-machine-with-a-ruby-domain-specific-language/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>DSL-FSM.. that kinda sounds like some wierd internet sub-culture.  It stands for domain specific language &#8211; finite state machine. I proposed both topics as presentation material for the austin-ruby group that I meet with once a month. <a href="http://stevengharms.com">Steven Harms</a> the organizer recommended both/either so I combined it into one piece of code as it actually works pretty well that way.</p>

<p>The DSL that I&#8217;m using is pretty small right now, which lends itself to easier understanding and explanation.</p>

<p><a href="http://jrepp.com/code/rbfsm.tgz"> Ruby code tarball can be downloaded here. </a></p>

<p>A FSM is defined in a ruby script file without any class definition using the following rules:
<ol>
    <li>All attributes are specified in a method named &#8216;setup&#8217;. Setup takes an argument hash which may contain arguments that can be used to setup a FSM entity.</li>
    <li>All states are specified by defining top level methods with the name &#8216;while<em>&lt;statename&gt;&#8217;. These methods are called in a tick update while that state is active.</li>
    <li>All transitions are initiated by saying start :statename</li>
</ol>
For example the creature FSM is has a method:
<blockquote><strong>def while</em>idle</strong>
<blockquote><strong>target_nearest</strong></p>

<p><strong>start :chasing if @target</strong></blockquote>
<strong>end</strong></blockquote>
All FSM entity templates  can be loaded in the world using world.load(&#8216;template-name&#8217;). The world is currently driven by a simple script named &#8216;simulate.rb&#8217; which allows you to single step the world simulation and watch all the state machines make their choices. There are some debugging tools available. You can list all active entities and dump the world grid.</p>

<p>World#load uses the Object#instance_eval method to evaluate the contents of the FSM definition in terms of a FSM base instance. The FSM class defines some methods that can be called within the FSM definition to control state transitions and to access common methods.</p>

<p>Practically speak this is a very simple way to enable easy extension of a system. It provides an easier path to refactor the individual state machines and lowers the barrier to entry for writing state machine code. Additionally, it would be nice to include certain types of behavior from modules so that state machine authors could have easy access to some of the methods currently defined in creature FSM. This would include methods like target_nearest.Â  You could also mix in native C modules to get access to things like a path finding grid.</p>

<p>Ideas for playing with the code:
<ol>
    <li>Make creatures pick up the &#8216;ammo&#8217; entities</li>
    <li>Make creatures compete for the &#8216;fark&#8217; entities</li>
    <li>Add a new term to the FSM for state transitions. The method names should be named &#8216;when<em>changing</em>from<em>&lt;statename&gt;, when</em>changing<em>to</em>&lt;statename&gt;, when<em>changing</em>from<em>&lt;statename&gt;</em>to_&lt;statename&gt;&#8217; and should be executed when those state change patterns are matched.</li>
    <li>Allow entities to die</li>
</ol>
Some Notes:</p>

<p>A great article about some of the different types of DSL creation and the mindset from one of the coders at 37signals:</p>

<p><a href="http://weblog.jamisbuck.org/2006/4/20/writing-domain-specific-languages"> http://weblog.jamisbuck.org/2006/4/20/writing-domain-specific-languages</a></p>

<p>Careful of using missing_method, it bit me in the arse a number of times:</p>

<p><a href="http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html"> http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html</a></p>

<p>It&#8217;s really hard to track down bugs related to method<em>missing, any code you write inside an object implementing this needs to be carefully checked. It can also lead to blowing your stack when an error in method</em>missing recalls method_missing.. and on and on.</p>

<p>This little gem is nice to keep in your back pocket when trying to raise a descriptive exception:</p>

<p><a href="http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy"> http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2007/08/14/implementing-a-finite-state-machine-with-a-ruby-domain-specific-language/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

