Wednesday, September 29, 2010

The Strategy pattern and Traits

So I promised I would talk about patterns and traits. When I wrote about the concepts of the Controller and the RuleSet, I already hinted at using the Strategy pattern. I was right, because that turned out to be exactly what I needed. And I was wrong, because the classical Strategy pattern is an ill match for Scala.

In this post I will explain how I implemented the Strategy pattern using Scala traits, and how this turned out to be an unsatisfying approach.

Wednesday, September 22, 2010

My first experience with Scala collections

In my previous post, I explained some concepts for improving my city builder simulations. By now, all code has been implemented, reimplemented, and reimplemented again. This has resulted in a codebase which, in my humble opinion, resembles real Scala. As a bonus, it also does what I wanted it to do.

I will talk about collections, traits, design patterns, and having fun with Scala. This post is dedicated to Scala collections; the traits and design patterns will be discussed in the next post.

Wednesday, September 8, 2010

Tying it together - Theory

So far, I have created a number of actors that together make up a simple, non-exciting simulation. However, controlling these actors is still done in an ad-hoc fashion.

In the next couple of posts, I will extend the simulation with supporting objects that make it easier to create and run different kinds of simulations. This post is dedicated to the theory behind these next steps.

In this post, I will introduce Actor states, the Controller, Rule sets and Settings.

Monday, September 6, 2010

Refactoring: Traits and Partial functions

In this post I was planning to add Citizens to my simulation. I did, and it turned out to be as exciting as watching termites mate.

So instead, in this post I will add Citizens to my simulation, clean up my codebase, factor out all duplicate code using Traits and refactor the act/loop/react by introducing partial functions.

Friday, September 3, 2010

Creating a simple simulation - Harvesters

In my previous post, I created a specification for my Harvesters. Now it's time to actually implement them and let them conform to that spec.

This post is mostly about messaging between actors, the different choices in handling those messages, and the impact these choices have on the concurrency of your system.