<?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>Brainfold &#187; cooperative multitasking</title>
	<atom:link href="http://www.brainfold.org/blog/tag/cooperative-multitasking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brainfold.org/blog</link>
	<description>On Python, game development and everything</description>
	<lastBuildDate>Sat, 15 May 2010 21:58:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MVC, my friend</title>
		<link>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/</link>
		<comments>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 02:29:57 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[cooperative multitasking]]></category>
		<category><![CDATA[entity system]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[scene management]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/</guid>
		<description><![CDATA[As I was finishing high level design of scene management, I realized it was starting to resemble the Model-view-controller pattern. The (hopefully) more or less final design is sort of a hybrid of the alternatives I already presented: Entities contain arbitrary data in attributes. These compose the Model. Entities can contain any amount of features; [...]]]></description>
			<content:encoded><![CDATA[<p>As I was finishing high level design of scene management, I realized it was starting to resemble the <a href="http://en.wikipedia.org/wiki/Model-view-controller">Model-view-controller</a> pattern. The (hopefully) more or less final design is sort of a hybrid of the alternatives I already presented:</p>
<ul>
<li><em>Entities</em> contain arbitrary data in <em>attributes</em>. These compose the <strong>Model</strong>.</li>
<li>Entities can contain any amount of <em>features</em>; these are the <strong>controllers</strong>.</li>
<li><em>Subsystems</em> (for lack of a better name) link entity attributes to lower-level systems - such as the renderer, audio mixer and physics simulation - and thus represent <strong>views </strong>into the scene.</li>
</ul>
<p>Features are normal tasks in the engine, based on cooperative multitasking. They can read from and write to attributes and create, trigger and listen to <em>signals</em> (an implementation of the observer pattern), which is how they communicate with each other. Subsystems also listen to signals to get notified of attribute changes. Attributes can be shared between features; for example <em>transform</em> is a common attribute probably used by almost all features and subsystems. Sharing of attributes is based purely on their names, there's no actual cooperation between features and subsystems except for signals and of course documentation.</p>
<p>I think a rough example is in order again:</p>
<ol>
<li>A ship gets hit, triggering the <em>hit signal.</em></li>
<li>The <em>damage controller feature</em> is listening to this signal and gets notified.</li>
<li>Damage controller decreases ship health accordingly and notices it's below zero:  it adds a <em>destruction sequence feature</em> to the ship entity and stops listening to hit events.</li>
<li>Destruction sequence adds an <em>audio source attribute</em> to the ship entity (if it doesn't already exist), spawns particle effects for a while and finally marks the ship entity for removal.</li>
<li>The <em>audio subsystem</em> notices the new audio source and adds it to the low level audio mixer.</li>
</ol>
<p>What do you think? Input is still welcome, I haven't actually started implementing this yet. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  And I still have at least a couple of open questions:</p>
<ol>
<li>How should signals be triggered externally, for example by features in other entities? Should they just trigger the signals directly, or should there be an "external API" consisting of callable attributes?</li>
<li>Should features occupy named slots like attributes, or should they just reside in a generic list? I'm currently leaning towards the latter approach and reserving names just for attributes, since feature don't have to directly know about each other.</li>
</ol>
<p>I still have to design the rendering pipeline; I already have a general idea of what I want, but details are kind of blurry. But that's the topic of another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2007/12/15/mvc-my-friend/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tasks, tools and tribulations</title>
		<link>http://www.brainfold.org/blog/2007/11/21/tasks-tools-and-tribulations/</link>
		<comments>http://www.brainfold.org/blog/2007/11/21/tasks-tools-and-tribulations/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 23:40:12 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[COLLADA]]></category>
		<category><![CDATA[cooperative multitasking]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[parsing]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/2007/11/21/tasks-tools-and-tribulations/</guid>
		<description><![CDATA[Inspired by Entity Crisis, I'm finally taking the plunge and converting my task scheduler to use generator-powered cooperative multitasking instead of normal functions. It should make both the task scheduler implementation and future task writing much more elegant. I'm also thinking of extending it later with threadable, networked and Stackless-based tasks. More on this as [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://entitycrisis.blogspot.com/">Entity Crisis</a>, I'm finally taking the plunge and converting my task scheduler to use generator-powered cooperative multitasking instead of normal functions. It should make both the task scheduler implementation and future task writing much more elegant. I'm also thinking of extending it later with threadable, networked and <a href="http://www.stackless.com/">Stackless</a>-based tasks. More on this as I get it done.</p>
<p>Good-ish news on the parser front: Dave Kuhlman released a new version of <a href="http://www.rexx.com/~dkuhlman/generateDS.html">generateDS</a>, which now succesfully parses the Collada schema, but the generated parser still fails to parse more complex Collada files, specifically transformation elements such as translate. I hope it's "just" a bug and not a missing feature. If it is, I just might contribute the missing features myself if needed and it's not too complex. In any case, this is promising.</p>
<p>I also started writing the C header parser using <a href="http://pyparsing.wikispaces.com/">Pyparsing</a>. It's easy enough to work with, though I wish its documentation was more decent and its interface cleaner and more Pythonic. Anyway, from the humble start it looks like it won't be too difficult a project for the small subset of C grammar I need it to understand. I already got it to recognize some preprocessor directives, now I just need it to do something with them, and then it's on to actual C grammar.</p>
<p>And I'm still waiting for  <a href="http://trac.edgewall.org/">Trac</a> 0.11  to be released, and hoping it will be easier to install than 0.10, which I never could get to work on shared webhosting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2007/11/21/tasks-tools-and-tribulations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
