<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Panzergame</title>
	<atom:link href="http://panzergame.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://panzergame.wordpress.com</link>
	<description>The ultimate strategy game</description>
	<lastBuildDate>Wed, 18 Aug 2010 19:02:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='panzergame.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Panzergame</title>
		<link>http://panzergame.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://panzergame.wordpress.com/osd.xml" title="Panzergame" />
	<atom:link rel='hub' href='http://panzergame.wordpress.com/?pushpress=hub'/>
		<item>
		<title>First Experiments with OpenGL</title>
		<link>http://panzergame.wordpress.com/2009/07/31/first-experiments-with-opengl/</link>
		<comments>http://panzergame.wordpress.com/2009/07/31/first-experiments-with-opengl/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 19:00:55 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[graphics]]></category>
		<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=611</guid>
		<description><![CDATA[I got tired of how slow some drawing operations were recently and started to learn OpenGL. I&#8217;m rewriting large parts of the game now&#8211;about half of the C++ code will be replaced with Scheme, and the other half will be broken out and made a separate part.The game logic itself is fine and does not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=611&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I got tired of how slow some drawing operations were recently and started to learn OpenGL. I&#8217;m rewriting large parts of the game now&#8211;about half of the C++ code will be replaced with Scheme, and the other half will be broken out and made a separate part.The game logic itself is fine and does not need to be rewritten. I&#8217;m keeping the SVG parser, but making it a separate utility that exports the data into my own format.</p>
<p>The rewrite will solve lots of problems and reduce dependencies on other software: I&#8217;m getting rid of Gtk and won&#8217;t require Libxml at enduser&#8217;s machines anymore. SDL is a new dependency, though.</p>
<p><img src="http://panzergame.files.wordpress.com/2009/07/cairo_vs_opengl.png?w=380" alt="cairo_vs_opengl" title="cairo_vs_opengl"   class="alignright size-full wp-image-612" /></p>
<p>The output quality doesn&#8217;t come close to what I got with Cairo, at least not with the naive approach I tried. Maybe I did something wrong. I know it <em>can</em> be solved because Qt, Amanith and various other libraries can render pretty SVG graphics using OpenGL. Maybe they use fragment shaders or some other technique that&#8217;s too advanced for someone who started with OpenGL just a few days ago. I&#8217;ll get there eventually, but right now I plan to use Cairo to render textures that I can map to rectangles with OpenGL. That should give me both quality and speed, at the cost of texture memory.</p>
<p>The partial rewrite means I won&#8217;t have a prototype to show at the end of the summer as I had hoped, but once it&#8217;s done I should have a much better foundation and be able to work faster than before. Working with the new code base is already more <em>fun</em>, which may be enough to increase my output after the rewrite, since it could mean I end up putting more hours into the project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/611/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=611&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/07/31/first-experiments-with-opengl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>

		<media:content url="http://panzergame.files.wordpress.com/2009/07/cairo_vs_opengl.png" medium="image">
			<media:title type="html">cairo_vs_opengl</media:title>
		</media:content>
	</item>
		<item>
		<title>Multiple Dispatch and Open Classes</title>
		<link>http://panzergame.wordpress.com/2009/07/13/multiple-dispatch-and-open-classes/</link>
		<comments>http://panzergame.wordpress.com/2009/07/13/multiple-dispatch-and-open-classes/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 20:35:09 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[clos]]></category>
		<category><![CDATA[multimethods]]></category>
		<category><![CDATA[multiple dispatch]]></category>
		<category><![CDATA[open classes]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=575</guid>
		<description><![CDATA[In my last post I wrote that Scheme lets you extend the base language in powerful ways. In this post I&#8217;ll give you a concrete example of such an extension: TinyClos. TinyClos is a minimal implementation in Scheme of Common Lisp&#8217;s object system CLOS. CLOS is different in many ways from the object systems of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=575&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://panzergame.wordpress.com/2009/07/13/scheme-is-not-one-language/">my last post</a> I wrote that Scheme lets you extend the base language in powerful ways. In this post I&#8217;ll give you a concrete example of such an extension: TinyClos.</p>
<p>TinyClos is a minimal implementation in Scheme of Common Lisp&#8217;s object system CLOS. CLOS is different in many ways from the object systems of C++ and Java that most of us are familiar with. Two big differences are multiple dispatch and open classes.</p>
<p>Before I explain what multiple dispatch is I must explain what <em>dispatch</em> refers to. When you make a function call in any language, the compiler or language runtime must figure out which function the call refers to. This is called <em>binding</em> the function to an implementation. In some languages binding always occurs at compile time, in others always at runtime, and in still others sometimes at runtime and sometimes at compile time.</p>
<p>Some languages, such as C++, allow you to declare many functions with the same name as long as they have different parameter lists. Not only the name of the function but also the number of arguments and their types are used when binding. This is called <em>overloading</em> in C++ terminology. However, overloading is a compile-time mechanism, and as such only looks at the <em>static</em> types of the arguments. If you want to bind the call based on the run-time type of an object you have to make the function <em>virtual</em>.</p>
<p>However, virtual functions in C++ (and most other mainstream languages) only take the run-time type of the <em>first</em> parameter into account&#8211;the &#8220;this&#8221; pointer. This is called <em>single dispatch</em>, because it dispatches the call based on a single argument. As you can probably guess by now, multiple dispatch is when the run-time types of multiple arguments is used for binding. In other words, multiple dispatch is like overloading but with run-time types.</p>
<p>This is immensely useful in some situations, because you can decide what to do based on <em>combinations</em> of types, without having to sprinkle your code with instance-of tests or resorting to ugly work-arounds like the <a href="http://en.wikipedia.org/wiki/Visitor_pattern">visitor pattern</a>. For instance, to express that anti-aircraft units can attack air units but not tanks or other units types, I just specify a method can-fire-at? for the type combination (AirDefenseUnit, AirUnit) and another one for (AirDefenseUnit, Unit). The method with the most specific matching argument list will be selected, at run time.</p>
<p>Here&#8217;s another simple example in the syntax Bjarne Stroustrup wants for C++ (not included in the coming update of the standard):</p>
<p><code><span style="color:#0000ff;">bool</span> canShareHex(<strong>virtual</strong> <span style="color:#0000ff;">Unit</span> u1, <strong>virtual</strong> <span style="color:#0000ff;">Unit</span> u2) {<br />
&nbsp;&nbsp;return <span style="color:#666699;">true</span>;<br />
}<br />
<span style="color:#0000ff;">bool</span> canShareHex(<strong>virtual</strong> <span style="color:#0000ff;">GroundUnit</span> u1, <strong>virtual</strong> <span style="color:#0000ff;">GroundUnit</span> u2) {<br />
&nbsp;&nbsp;return <span style="color:#666699;">false</span>;<br />
}<br />
<span style="color:#0000ff;">bool</span> canShareHex(<strong>virtual</strong> <span style="color:#0000ff;">AirUnit</span> u1, <strong>virtual</strong> <span style="color:#0000ff;">AirUnit</span> u2) {<br />
&nbsp;&nbsp;return <span style="color:#666699;">false</span>;<br />
}<br />
<span style="color:#0000ff;">bool</span> canShareHex(<strong>virtual</strong> <span style="color:#0000ff;">SeaUnit</span> u1, <strong>virtual</strong> <span style="color:#0000ff;">SeaUnit</span> u2) {<br />
&nbsp;&nbsp;return <span style="color:#666699;">false</span>;<br />
}</code></p>
<p>In other words, GroundUnits can share hex with all units but other GroundUnits. This example also demonstrates the other feature I wanted to write about: open class extensions. As you can see above, the methods were not part of a class but added separately. This too is very useful, because you can&#8217;t always anticipate what people may want to do with your classes, and sometimes it&#8217;s impractical to cram everything into one class.</p>
<p>For example, let&#8217;s say you are writing a compiler and define classes for different kinds of expressions, like addition and multiplication and so on, reflecting the tree structure of arithmetic expressions. Since the set of operations (optimizations) you may want to perform on the tree is open ended, you wouldn&#8217;t want to make them all methods of the tree classes. It would be much cleaner to define each optimization separately, while still dispatching on the actual run-time type(s) of the tree nodes.</p>
<p>With Scheme, I could just download TinyClos and start using these features. They can be compiled efficiently too, though I&#8217;m not sure they are in Chicken. Knowing that it can be solved should the need arise is reassuring, though.</p>
<p><strong>Further reading:</strong></p>
<ul>
<li>An efficient implementation of open multimethods for C++: <a href="http://www.research.att.com/~bs/multimethods.pdf">www.research.att.com/~bs/multimethods.pdf</a></li>
<li>Multijava, a version of Java extended with multiple dispatch: <a href="ftp://ftp.cs.iastate.edu/pub/techreports/TR04-01/TR.pdf">ftp://ftp.cs.iastate.edu/pub/techreports/TR04-01/TR.pdf</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/575/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=575&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/07/13/multiple-dispatch-and-open-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
		<item>
		<title>Scheme is not one Language</title>
		<link>http://panzergame.wordpress.com/2009/07/13/scheme-is-not-one-language/</link>
		<comments>http://panzergame.wordpress.com/2009/07/13/scheme-is-not-one-language/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 15:40:56 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=560</guid>
		<description><![CDATA[Considering all the hassle of using multiple languages in one project, was it really a good idea to use Scheme? I would say so. Scheme is not like other languages. In a way, Scheme is not really one language, but a foundation for defining other languages. The semantics of Scheme were designed to enable programmers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=560&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Considering all the hassle of using multiple languages in one project, was it really a good idea to use Scheme? I would say so.</p>
<p>Scheme is not like other languages. In a way, Scheme is not really one language, but a foundation for defining other languages. The semantics of Scheme were designed to enable programmers to devise their own control structures and the syntax was minimized to make it easy to parse, modify and layer your own syntax on top of. The language as a whole left so many other things unspecified that you <em>must</em> build your own environment on top of it unless you&#8217;re working on a small project.</p>
<p>One example of the power Scheme gives its users is unlimited <em>continuations</em>. A continuation is a point in the execution of a program which has been lifted up to the language layer, where it can be passed around or saved in variables, letting you execute it again later should you want to. That was pretty abstract so I&#8217;ll give you an example:</p>
<p>As you may know, functions in C programs push their return address on a stack before they are invoked. When a function returns, it pops the return address from the top of the stack and jumps to that address, which is where the call came from. The return address is the <em>continuation</em> of the caller (I&#8217;m simplifying here), but it doesn&#8217;t exist as a first-class entitiy in the C language, so we cannot see it or refer to it. In Scheme you can. Moreover, you can call a continuation as many times as you wish, and you can ask for the current continuation at any point, not just at call sites.</p>
<p>This is not terribly useful in day-to-day coding, but it is essential if you want to make your own language. Using continuations, you can implement exception-handling mechanisms like try-catch without resorting to low-level hackery (and things like loops with complicated exit logic and light-weight threads, too).</p>
<p>What all this comes down to is that Scheme is a very good environment for language experimentation, which has resulted in a lot of people hacking on these kinds of things. Consequently, you can go to the web page of your Scheme environment and download language extensions others have written that add or alter fundamental parts of the language; They may for instance add object-oriented constructs and run-time dispatch. Mainstream languages are much less malleable.</p>
<p>In summary, I think the ability to download language extensions and, so to speak, assemble my own language from pieces written by others has been a huge advantage. That, and the ability to make changes to the program as it&#8217;s running has been more than enough to justify the hassle.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/560/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=560&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/07/13/scheme-is-not-one-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
		<item>
		<title>Extended Scheme</title>
		<link>http://panzergame.wordpress.com/2009/07/13/extended-scheme/</link>
		<comments>http://panzergame.wordpress.com/2009/07/13/extended-scheme/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 14:41:47 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=549</guid>
		<description><![CDATA[I have now started to use the preprocessor on a small scale. All it does currently is translate dotted field expressions into the syntax TinyClos expects. I actually found out you could type  (slot@ foo x y) instead of (slot-ref (slot-ref foo &#8216;x) &#8216;y), but foo.x.y is better still, so I don&#8217;t regret writing the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=549&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have now started to use the preprocessor on a small scale. All it does currently is translate dotted field expressions into the syntax TinyClos expects. I actually found out you could type  (slot@ foo x y) instead of <span style="color:#000000;">(</span><span style="color:#000000;">slot-ref (slot-ref foo &#8216;x) &#8216;y</span>), but foo.x.y is better still, so I don&#8217;t regret writing the preprocessor. Besides, this way I can easily add more &#8220;macros&#8221; that don&#8217;t conform to Lisp&#8217;s grammar later.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/549/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=549&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/07/13/extended-scheme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
		<item>
		<title>Even Bigger Map</title>
		<link>http://panzergame.wordpress.com/2009/07/05/even-bigger-map/</link>
		<comments>http://panzergame.wordpress.com/2009/07/05/even-bigger-map/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 20:45:43 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=536</guid>
		<description><![CDATA[I increased the size of the map again. I&#8217;ve included a scaled down version (15% of the normal view size) of the map as it looks right now below. As you can see it&#8217;s far from complete, but I think this will be the final extent of this scenario. I&#8217;m not sure exactly what the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=536&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I increased the size of the map again. I&#8217;ve included a scaled down version (15% of the normal view size) of the map as it looks right now below. As you can see it&#8217;s far from complete, but I think this will be the final extent of this scenario.</p>
<p>I&#8217;m not sure exactly what the scenario will be, but something like an attack on Denmark with Sweden getting drawn in. The south of Sweden was pretty much undefended (we had prepared for the war between the Soviet Union and Finland to spread to the north of Sweden, not for war with Germany), but the Swedish navy could probably have helped the Danes a bit.</p>
<p><img class="alignnone size-full wp-image-537" title="sweden" src="http://panzergame.files.wordpress.com/2009/07/sweden.png?w=380" alt="sweden"   /></p>
<p>I haven&#8217;t done much programming this weekend, but I experimented some more with the Antlr parser generator. I can now recognize field access expressions like foo.bar.baz and transform them into (slot-ref (slot-ref foo &#8216;bar) &#8216;baz). I detest having to type all that garbage just to access some fields, so anything that can rid me of that is welcome even if it means writing a preprocessor. More about that later. I&#8217;ll need to work more on it before I have something that can be used.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/536/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=536&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/07/05/even-bigger-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>

		<media:content url="http://panzergame.files.wordpress.com/2009/07/sweden.png" medium="image">
			<media:title type="html">sweden</media:title>
		</media:content>
	</item>
		<item>
		<title>Illustrating Farmlands</title>
		<link>http://panzergame.wordpress.com/2009/06/20/illustrating-farmlands/</link>
		<comments>http://panzergame.wordpress.com/2009/06/20/illustrating-farmlands/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 16:47:21 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[graphics design]]></category>
		<category><![CDATA[illustration]]></category>
		<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=519</guid>
		<description><![CDATA[I&#8217;ve been experimenting with the look of cultivated areas today. I&#8217;m quite happy with the result so far&#8211;it&#8217;s much better than the flat yellow surface I use in most places, that&#8217;s for sure. The lines and dots in the fields are all vector data.. Maybe I should use bitmap textures for these things instead? I&#8217;m completely inexperienced [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=519&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with the look of cultivated areas today. I&#8217;m quite happy with the result so far&#8211;it&#8217;s much better than the flat yellow surface I use in most places, that&#8217;s for sure.</p>
<p>The lines and dots in the fields are all vector data.. Maybe I should use bitmap textures for these things instead? I&#8217;m completely inexperienced with vector graphics design work, so I don&#8217;t know how people usually handle this kind of stuff.</p>
<p>I also added shadows underneath the tanks, to place them more firmly onto the ground.</p>
<p><img class="alignnone size-full wp-image-523" title="screenshot-090620-2" src="http://panzergame.files.wordpress.com/2009/06/screenshot-090620-21.png?w=380" alt="screenshot-090620-2"   /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/519/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=519&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/06/20/illustrating-farmlands/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>

		<media:content url="http://panzergame.files.wordpress.com/2009/06/screenshot-090620-21.png" medium="image">
			<media:title type="html">screenshot-090620-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Submarines</title>
		<link>http://panzergame.wordpress.com/2009/06/20/submarines/</link>
		<comments>http://panzergame.wordpress.com/2009/06/20/submarines/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 15:24:01 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=510</guid>
		<description><![CDATA[I took a break from coding and worked a bit on the graphics instead. The map is much bigger now and stretches from the west coast of Denmark to the east coast of Sweden. Here&#8217;s a screenshot of a new u-boat outside the German coast:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=510&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I took a break from coding and worked a bit on the graphics instead. The map is much bigger now and stretches from the west coast of Denmark to the east coast of Sweden. Here&#8217;s a screenshot of a new <a title="u-boat" href="http://en.wikipedia.org/wiki/U-boat">u-boat</a> outside the German coast:</p>
<p><img class="alignnone size-full wp-image-511" title="090620-1" src="http://panzergame.files.wordpress.com/2009/06/090620-1.png?w=380" alt="090620-1"   /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/510/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=510&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/06/20/submarines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>

		<media:content url="http://panzergame.files.wordpress.com/2009/06/090620-1.png" medium="image">
			<media:title type="html">090620-1</media:title>
		</media:content>
	</item>
		<item>
		<title>Proactive Air Defense</title>
		<link>http://panzergame.wordpress.com/2009/06/19/proactive-air-defense/</link>
		<comments>http://panzergame.wordpress.com/2009/06/19/proactive-air-defense/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 13:22:41 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=503</guid>
		<description><![CDATA[Anti-aircraft units are now much better at defending their area, since they get to shoot first&#8211;during the enemy&#8217;s turn. Things are a bit confusing now, though, because the chain of events isn&#8217;t made manifest to the player. If you lose concentration and accidentally move a plane into the range of an hostile anti-aircraft unit you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=503&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Anti-aircraft units are now much better at defending their area, since they get to shoot first&#8211;during the enemy&#8217;s turn. Things are a bit confusing now, though, because the chain of events isn&#8217;t made manifest to the player. If you lose concentration and accidentally move a plane into the range of an hostile anti-aircraft unit you may be surprised to find your unit suddenly half as strong as it used to be. If you&#8217;re really unlucky the whole unit may disappear, with no indication of who fired at it.</p>
<p>In short, this change makes animation a requirement, and not just a feature that would be nice to have. I probably won&#8217;t take care of that right now, though.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/503/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=503&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/06/19/proactive-air-defense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatic Reactions</title>
		<link>http://panzergame.wordpress.com/2009/06/14/automatic-reactions/</link>
		<comments>http://panzergame.wordpress.com/2009/06/14/automatic-reactions/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 10:51:00 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[progress report]]></category>
		<category><![CDATA[war game]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=479</guid>
		<description><![CDATA[I haven&#8217;t completed any new functionality yet, but I&#8217;m working on a framework for managing automatic reactions. This is needed by anti-aircraft guns for instance, since they must be able to react immediately to defend their area effectively. Before an attacking plane is allowed to drop any bombs, all air defense units in range will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=479&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t completed any new functionality yet, but I&#8217;m working on a framework for managing automatic reactions. This is needed by anti-aircraft guns for instance, since they must be able to react immediately to defend their area effectively. Before an attacking plane is allowed to drop any bombs, all air defense units in range will get a chance to shoot it down.</p>
<p>To make this work I need to decouple the request for an action from actually performing the action, so that other units get a chance to intercept. When the user tries to attack an enemy unit, I now send an attack request to an arbiter object running in another (lightweight) thread. The arbiter asks enemy units nearby if they want to counter the action, and schedules the resulting actions. The schedule is then executed and the results broadcasted to everyone who can see them.</p>
<p>These changes not only enable automatic reactions; They also bring me closer to having networked play and fog of war (the inability to see all the enemy&#8217;s units).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/479/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=479&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/06/14/automatic-reactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
		<item>
		<title>The Perils of Mutable State</title>
		<link>http://panzergame.wordpress.com/2009/06/07/the-perils-of-mutable-state/</link>
		<comments>http://panzergame.wordpress.com/2009/06/07/the-perils-of-mutable-state/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 14:43:40 +0000</pubDate>
		<dc:creator>Stefan</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://panzergame.wordpress.com/?p=458</guid>
		<description><![CDATA[A few weeks ago, I spent more than a week debugging parts of a very large software system at work. I will not go into detail about the software, but I want to write down what I learned from it so that I will remember it better, and share my conclusions with you. Actually, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=458&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I spent more than a week debugging parts of a very large software system at work. I will not go into detail about the software, but I want to write down what I learned from it so that I will remember it better, and share my conclusions with you.</p>
<p>Actually, I started thinking about similar problems months earlier when I was writing new code that gradually became much more complicated than I had expected. Why did I end up in a morass of special cases and conditions?</p>
<p>Both problems involved updating the state of several different data structures that had to be kept synchronized. The basic problem was that changes to the data were spread out over many different functions and that early changes could invalidate later changes or affect the control flow in an undesired way by changing the outcome of a conditional branch.</p>
<p>When I was working on the first problem I was writing new code and had free hands when it came to design. After realizing I would have to scrap my first design to make further progress, I decided I would partition the problem into two distinct parts: One would figure out which changes needed to be made and encode them in a class called a ChangeSet; The other would apply the changes. The idea was that it would be easier to debug and understand the algorithm if you could print out the ChangeSet and check invariants before it was applied. This worked well and simplified the code enough that I was able to make progress again.</p>
<p>The other problem had another important ingredient: randomness. The iteration order of several central datastructures (such as sets) is random in our system (a side effect of our generational garbage collector&#8217;s decisions) and caused the (very large) algorithm to update the data structures in a different order from one run to another. Most of the time everything worked fine, but every now and then things failed with random symptoms.</p>
<p>It has slowly dawned on me that these two problems were essentially the same: Many changes had to be made to many different data structures, and those very changes could cause the algorithm to trip itself up.</p>
<p>My solution to the first problem (using a ChangeSet) worked well not only because it made following the changes easier, but also because it concentrated all state changes to one phase, letting the first part of the algorithm discover what needed to be done <em>in a temporarily immutable world</em>. I think there is an important and general principle here: Changes to mutable state should be confined to as few points in both space and time as possible. This goes for any language with mutable state. Object-oriented principles do not seem to cover this problem, since hiding the state inside a class does not make the state go away; It is just changed via a method instead.</p>
<p>An interesting parallel is that the solution I described above is similar to what database systems do with transactions, and databases are specialized on managing mutable state in unpredictable environments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panzergame.wordpress.com/458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panzergame.wordpress.com/458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panzergame.wordpress.com/458/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panzergame.wordpress.com&amp;blog=4362755&amp;post=458&amp;subd=panzergame&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panzergame.wordpress.com/2009/06/07/the-perils-of-mutable-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9e62b1b37582c859f2e0df9314d9c955?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stefan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
