<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2415973855415004202</id><updated>2024-09-14T02:01:33.370-07:00</updated><category term="scala"/><category term="simulation"/><category term="maven"/><category term="unit tests"/><category term="collections"/><category term="meta"/><category term="mistakes"/><category term="refactoring"/><category term="traits"/><title type='text'>Learning Scala</title><subtitle type='html'>Learning the Scala Programming Language by creating a city simulation in Scala and Java</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://scalasim.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-1820114001083933441</id><published>2010-09-29T06:00:00.001-07:00</published><updated>2010-09-29T06:00:05.781-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mistakes"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="traits"/><title type='text'>The Strategy pattern and Traits</title><summary type="text">
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</summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/strategy-pattern-and-traits.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/1820114001083933441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/1820114001083933441'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/strategy-pattern-and-traits.html' title='The Strategy pattern and Traits'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-4194984829487604165</id><published>2010-09-22T01:14:00.001-07:00</published><updated>2010-09-22T01:16:08.298-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="collections"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><title type='text'>My first experience with Scala collections</title><summary type="text">
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</summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/my-first-experience-with-scala.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/4194984829487604165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/4194984829487604165'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/my-first-experience-with-scala.html' title='My first experience with Scala collections'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-3743019369338851211</id><published>2010-09-08T10:46:00.001-07:00</published><updated>2010-09-08T10:46:51.245-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><title type='text'>Tying it together - Theory</title><summary type="text">
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 </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/tying-it-together-theory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/3743019369338851211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/3743019369338851211'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/tying-it-together-theory.html' title='Tying it together - Theory'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-5627068445434439954</id><published>2010-09-06T10:10:00.001-07:00</published><updated>2010-09-06T10:13:36.614-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="refactoring"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><title type='text'>Refactoring: Traits and Partial functions</title><summary type="text">
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. 
Citizens, first attempt
The pattern for extending my program should </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/refactoring-traits-and-partial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/5627068445434439954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/5627068445434439954'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/refactoring-traits-and-partial.html' title='Refactoring: Traits and Partial functions'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-7840325249866453850</id><published>2010-09-03T08:19:00.001-07:00</published><updated>2010-09-03T08:26:21.875-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><title type='text'>Creating a simple simulation - Harvesters</title><summary type="text">
In my previous post, I created a specification for my Harvesters. Now it&#39;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. 
First approach
It&#39;s always better to start simple, so let&#39;s have a look at the </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/creating-simple-simulation-harvesters.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/7840325249866453850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/7840325249866453850'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/creating-simple-simulation-harvesters.html' title='Creating a simple simulation - Harvesters'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-2150296611116831138</id><published>2010-09-01T13:28:00.001-07:00</published><updated>2010-09-02T01:07:12.494-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="unit tests"/><title type='text'>Creating a simple simulation - The HarvesterSpec</title><summary type="text">
In my previous post, I introduced the Producer actor. Now it&#39;s time to introduce the Harvester. 

In this post I will define the specifications of the Harvester and show how to test the concurrency of the eventual implementation. 

In order to do this, I will also dive into some of the cooler features of Scala, especially foreach, map, list-comprehensions and futures.
Game concepts
Harvesters </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/09/creating-simple-simulation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/2150296611116831138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/2150296611116831138'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/09/creating-simple-simulation.html' title='Creating a simple simulation - The HarvesterSpec'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-8537090920334435602</id><published>2010-09-01T11:16:00.000-07:00</published><updated>2010-09-01T11:23:55.202-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="unit tests"/><title type='text'>Adding Scala unit tests</title><summary type="text">In my previous post, I showed how the Producer worked by adding some example code to my Simulation object. This might be very suitable for small projects, but in the long run I always prefer to have unit tests. In this post I will show how I added Scala unit tests to my project.Choosing a frameworkAfter playing around with some different frameworks, I have decided to go for Scala Specs. The </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/08/adding-scala-unit-tests.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/8537090920334435602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/8537090920334435602'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/08/adding-scala-unit-tests.html' title='Adding Scala unit tests'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-213345829799210021</id><published>2010-09-01T10:00:00.000-07:00</published><updated>2010-09-01T11:23:43.621-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><title type='text'>Creating a simple simulation - Producers</title><summary type="text">Now that the project has been set up, it&#39;s time to start creating the first steps in our simulation.Every city simulation game I&#39;ve played begins the same: getting workers to obtain raw materials. So let&#39;s  create a text-only simulation that does just that.This post is about Scala syntax, Scala Actors, Scala messages, and examples of pattern matching.Simulation ConceptsEach simulation starts out </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/08/creating-simple-simulation-producers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/213345829799210021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/213345829799210021'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/08/creating-simple-simulation-producers.html' title='Creating a simple simulation - Producers'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-5379168920996157866</id><published>2010-09-01T09:00:00.000-07:00</published><updated>2010-09-01T11:23:29.261-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><title type='text'>Creating a Java/Scala Maven project</title><summary type="text">In this post, I will explain how I set up my first program, allowing me to create and run an extremely simple Scala program in my favorite IDE using Maven﻿.StructureI started out with creating the following directory structure:scalasim
+-- src
|   +-- main
|   |   +-- java
|   |   +-- resources
|   |   \-- scala
|   |       \-- Simulation.scala
|   \-- test
|       +-- java
|       +-- resources
</summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/08/first-steps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/5379168920996157866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/5379168920996157866'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/08/first-steps.html' title='Creating a Java/Scala Maven project'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2415973855415004202.post-8849129804236464379</id><published>2010-09-01T00:48:00.000-07:00</published><updated>2010-09-01T02:01:09.232-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="meta"/><title type='text'>Welcome</title><summary type="text">I&#39;m currently in the process of learning Scala, and decided to use this blog to share my learning curve with the rest of the world.GoalI am going to create a large-scale simulation as experienced in the games ﻿Ceasar, Settlers or CivCity. I do not pretend this will result in a full-blown game, but it will contain many of the aspects found in those games.For those not knowing those games, the </summary><link rel='replies' type='text/html' href='http://scalasim.blogspot.com/2010/08/welcome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/8849129804236464379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2415973855415004202/posts/default/8849129804236464379'/><link rel='alternate' type='text/html' href='http://scalasim.blogspot.com/2010/08/welcome.html' title='Welcome'/><author><name>Solo DM</name><uri>http://www.blogger.com/profile/07587479286366183485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNozk4cHzqKE0ebI6jdgcKnldxhySBWm3goL14OWH6eR9jn9zdP0ARXYYpbBI_6eSIqKXsznmXUxmdlxspBQNt2P8GM4YbNGiqQ_PFWzWp89vsfp31NN5YiPplT3uwQd0/s220/solodom.JPG'/></author><thr:total>0</thr:total></entry></feed>