Warning: Pictures of Cats Ahead!

I used to draw a lot as a kid, but at some point I stopped doing it. Maybe I didn’t have the time. Maybe I wasn’t good enough, or never felt like my technique improved. And from time to time I felt really bad about quitting.

Well, a couple of days ago I dusted off my Wacom Bamboo tablet, downloaded the latest version of ArtRage, and started sketching again. For some reason, everything turned out cats:

The first two were made using photo references. This is our oldest cat in various poses.

This one was actually drawn from memory. This is our smallest cat, and yes, her ears really are that large.

The Amazing Arkham Horror Contents Calculator

It starts out innocently enough. You purchase the Arkham Horror base set and play a few games with friends. You have loads of solid, insanity-inducing fun, but after a while it gets kinda repetitive playing with the same Investigators and Old Ones over and over again. So you start looking at expansions, picking up say, Innsmouth Horror and Bam! you’re in Happytown again! Killing monsters! Reading ancient tomes! Learning all things Man Was Not Meant To Know.

Soon you have collected all the expansions, and now your problem is that you’re running out of space. The base set alone contains over 700 moving parts. Each expansion adds more game boards, cards, tokens, markers and rule books. You start asking yourself exactly what ridiculous amount of game components you’ve accumulated on your quest to boardgame nirvana.

At least, that’s what I asked myself. And so I whipped together a web-based calculator using GWT and some free time. Now you too can use it to calculate the extent of your mania.

Note: The columns are sortable; try clicking on the column headings. You can filter the selection by (un)checking the boxes for different expansion sets and component types.


3222 components! Whew, that’s a lot!


While writing the previous two posts I found the need to display Inform7 source code in a blog-friendly way. Unfortunatly, the pygments source highlighter doesn’t support it, and I couldn’t find any plugins for it that would. The closest I came was this blog post by Max Battcher, but as he mentions, pygments is probably a bad fit for this kind of code. Inform7 source is best displayed with a non-fixed-width font and uses regular line wrapping, but depends on significant whitespace for control flow. As far as I could tell, pygments doesn’t really support that kind of output, and anyway I couldn’t figure out how to use Python’s setuptools to hook up my own plugins to begin with.

So I did what any self-respecting hacker would do: I rolled my own solution using the tools I’m used to. In my case that means elisp, which is a good fit for med since Emacs is the tool I’m using to write this blog. I’ve put the code on GitHub it case it proves useful for the very small subset of Inform7 users who are also a) Emacs fanatics, and b) desperately in need of a HTML syntax highlighter.

Working Title: Satisfaction

I’m starting to settle into my new home office. There are boxes and cables everywhere, but at least I have a desk to work from. Time to get back to actual work again.

For the past month, I have made virtually zero progress on my Interactive Fiction game. I could blame this on the stress of moving across the country while simultaneously negotiating building plans for our summer house, and then having relatives visiting the new house over easter, but I won’t. Let’s just say I need a little ignition to get going again, and I’m hoping blogging about it a bit will help.

When I first concieved the idea for the game I thought I’d be done in a day, or a weekend at most. That was back in January, and I think I might be halfway to an alpha version now. Obviously, it took a whole lot longer than I expected, mostly because I was learning Inform 7 and designing the game world at the same time as coding. One thing I did do right though, was actually writing a simple design document before I started. It had a short synopsis describing the game flow and central mechanics, and a section for each important person in the game. Nailing down names, titles, and backgrounds of the characters really helped things later on.

The games is divided into short chapters, with the viewpoint alternating between two playable characters. I want the player to feel like she’s participating in a story rather than trying to beat a game, so there are no obvious puzzles to solve. In fact, right now most of the game can be played just by moving between rooms, and waiting at the correct places. I’m considering using the subtitle A Short Story About Inevitability, but we’ll see.

Much of the plot revolves around discovering things about the player characters, either by exploring or by having conversations with NPCs. Even though the player is largely swept along for the ride, his actions do have consequences for the ending of the game. There are several different outcomes, even though they may not be obvious.

There are two things I’m doing to invite re-play of the game. First, I’m trying to pace it so that the player will never be able to get the whole picture in the first play-through. The challenge here is making the player feel intrigued rather than annoyed, and there’s a cetain risk this will backfire. Second, this will be a short game that can probably be finished within the hour.

As I mentioned earlier, I want this to feel like a proper story. This means that the player should be able to behave like she would in real life, and expect a reasonable outcome. It also means that I have to deal with certain IF staples in creative ways. For example, realism dictates that there should be certain props (like a sideboard with a tea kettle and some breakfast on a sideboard in the Dining Romm) in the game. I want the player to be able to pick up and interact with these objects, but not carry them around the house (which would spoil the overall tone of the story). Thus, I created a mechanism for handling unimportant items:

Chapter - Non-essential props

Things can be unimportant.

A room has an object called the resting place.

Carry out going when the player has an unimportant thing:
let the resting place be the resting place of the location;
let the inessentials be the list of unimportant things carried by the player;
repeat with the inessential running through the inessentials:
if the resting place is a supporter:
try silently putting the inessential on the resting place;
otherwise if the resting place is a container and the resting place is open:
try silently inserting the inessential into the resting place;
try silently dropping the inessential;
if the resting place is a supporter:
"You put the
[the inessentials]
back on
[the resting place]
otherwise if the resting place is a container:
"You put the
[the inessentials]
back in
[the resting place]
"You leave the
[the inessentials]
[the printed name of the location in lower case]

This rule ensures that an item that is declared unimportant the player will drop it before leaving the room. To make it a bit more realistic, you can name a container or supporter a resting place (for want of a better name) for each room. Unimportant objects will then be put back on the supporter or back into the container.

This is the (somewhat abridged) description of my Dining Room:

Section - Dining Room

The sideboard is a fixed in place supporter in Dining Room.
"Along one of the walls is a grand old sideboard crafted out of solid oak. Conveniently placed on it is
[a list of things on the sideboard]
The resting place of Dining Room is the sideboard.

The silver kettle is on the sideboard.

The kettle contains the tea. The description of the tea is
"Smells like Earl Grey."
The indefinite article of the tea is

Some breakfast is on the sideboard.
"It seems Watkins has prepared some cucumber sandwiches for you. Just as good, you sincerely doubt you'd be able to eat a full breakfast right now."
The breakfast is edible.

The kettle and breakfast are unimportant.

And this is how it plays:

Dining Room
Along one of the walls is a grand old sideboard crafted out of solid oak. 
Conveniently placed on it is a silver kettle, some breakfast, some china and a 
crystal decanter.

>take kettle

>take breakfast

You are carrying:
  some breakfast
  a silver kettle
    some tea
  a candle (providing light)
  some clothes (being worn)

You put the breakfast and silver kettle back on the sideboard.

[New room description snipped]

Allright, I should stop now. I just realized I spent an hour on this post instead of actually working on the darn game. See ya next time!

Going Remote

A week from now the movers will come and stuff all our belongings into a big ol’ truck. We will get in the car, wave goodbye to friends and family and drive north for two days. There, in a small town you’ve probably never heard of, lies our new home.

Naturally, this is quite a scary proposition for a city boy. I honestly don’t know if I’ll make it up there. But I was given a great opportunity, and I had to at least try. Besides, life in the city was getting a bit too convenient, if you know what I mean? It was time for a change.

Fortunately, my employer was keen to keep me on, which means that starting two weeks from now I’ll be working 100% remotely. This is a big change, and I hope it will work out for everyone involved. Our team has started using PivotalTracker and Campfire, and the overall impression is good so far. However, I will be working from my home office, and I just hope the cabin fever doesn’t get unbearable.

Another big change is that I’ll just be working 80%. Living in the northern parts of Sweden is pretty cheap, and after doing the math we decided that it wasn’t really necessary for me to work full time anymore. Instead, I’ll try to spend the extra time on fun personal projects, without having to worry about them earning me any money (although it would be nice if they did).

I’ve been longing to give game development a shot for a long time now, and this is kind of my big chance. For a guy with my background the obvious choice seems to be mobile game development with Android, and I already have some ideas to work on. I’m also really intrigued by what can be done with Common Lisp, which I believe could make for a great interactive game environment. However, my first goal is to finish my Inform 7 game, hopefully being able to enter it into IFComp 2011. Watch this space.

You know, I have a good feeling about this.

Fun With Inform7

For the past month I’ve been amusing myself with a wonderful language: Inform7. It is a very domain-specific language in that its main application is authoring text adventures (oh, sorry, ‘Interactive Fiction’), and produces the Z-code or Gluglx bytecode when compiled.

There are several reasons I really shouldn’t enjoy this language so much:

  • It uses natural language, which I initially thought was a terrible choice for language design. I’ve always treasured brevity and conciseness in code, but I may have to reconsider. True, Inform7 code is pretty verbose and sometimes a bit repetitive, but at the same time it flows like easy to read prose, kind of like Knuth’s literate programming.
  • It comes with an IDE, which you are strongly encouraged to use. Normally I’m a die-hard emacs guy who only uses Eclipse as a last resort, but in this case it works pretty well. There is integrated documentation, a system for structured code, and testing facilities especially tailored for helping you run through different branches of you interactive stories.

Coding in Inform7 is an interesting experience. The code reads a lot like regular english, but of course it isn’t really natural language. There is still a basic level of syntax you have to adhere to, even if the parser does some fairly intelligent disambiguation of terms and lets you describe you world in a lot of alterative ways.

Yes, ‘describe your world’. That pretty much sums it up; a program is mostly a description of you model game world, with rooms, objects and behaviours. This is a trivial treasure collecting game in five lines of code (including the title):

"Treasure Hunt" by Fredrik Appelberg
Treasure Hill is a room. The description is "A green and abundant hill,
with a view of the surrounding fields. It makes an excellent
starting point for your treasure hunt."
The chest is an closed openable container in Treasure Hill. It contains a
gold coin.
The player is carrying a brass lantern. The player is wearing a cloak.
Every turn when the player is carrying the coin: end the story saying "You

Describing an object is the same as creating it. Here I create a room (with a descriptive text), a chest with a gold coin inside, a lantern and a cloak held by the player. The cloak is interesting: since I state that the player is wearing it, Inform7 is able to infer that it is a piece of clothing (an object subclass that has its own set of properties) without me having to say it. Also, I’ve explicitly stated that the chest is a container (another subclass), but in this example that’s not really necessary, since the compiler can infer that from the fact that there’s a coin inside the chest. However, I’ll leave it like this since it makes the text a bit easier to read.

For me, this is a very novel way of coding, and reminds me of the Prolog hacking we did at the university: programming is mostly just stating facts about the world, and trusting the compiler to handle the rest.

Compiling and running is as simple as pushing a button. This is what a transcript of the game looks like:

Treasure Hunt
An Interactive Fiction by Fredrik Appelberg
Release 1 / Serial number 110211 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD

Treasure Hill
A green and abundant hill, with a view of the surrounding fields. It makes an excellent 
starting point for your treasure hunt.

You can see a chest (closed) here.

You are carrying:
  a brass lantern
  a cloak (being worn)

>x chest
You see nothing special about the chest.

>open it
You open the chest, revealing a gold coin.

>take the coin

    *** You won! ***

In that game you scored 0 out of a possible 0, in 4 turns.

Would you like to RESTART, RESTORE a saved game, QUIT or UNDO the last command?

But that’s just my simple play-through. If you like, you can try the game yourself, without leaving your browser. That’s right: Inform7 also generates a simple website for your game, complete with a z-code interpreter written in javascript.

Creating Interactive Fiction With Inform 7

If you don’t hear from me for a while, it’s probably because I’m busy hacking my first serious game. It’s taken me longer than anticipated, but that doesn’t bother me. Writing with Inform7 is such joy that I can’t help myself.

By the way, I thought I’d take the time to plug Aaron Reed’s excellent Creating Interactive Fiction With Inform 7. It’s one of the most inspiring programming books I’ve ever read. And I’ve been through a few.

Introducing Woodchipper

Well, my last post may have been a bit of a rant, but it did spur my creativity. The more I thought about automatically replacing logging statements with System.out.println(), the more the idea appealed to me. A couple of days later I had a day off with beautiful weather and nothing to do, and I spent it out on the balcony, hacking frantically. In the end I had a rough proof of concept that I’ve now refined to the point that I’m not embarrased to show it to people.

Ladies and gentlemen, I give you WoodChipper. It is a command line utility that will automatically remove all Log4j and Commons Logging statements from a given .jar file or a classpath directory. This happens through bytecode manipulation, so the dependencies are removed completely. There is no classpath trickery like with Slf4j (which supplies its own replacement jars for the underlying logging system), no fiddling with your library path, no more need to write exclusion filters in maven. You can run it on your own code, but it’s really designed to work on 3rd party .jar files where you can’t influence the choice of logging framework.

Depending on your opinion on the state of Java logging frameworks, this is either wonderful or a terrible idea. Anyway, let me know what you think.


You need to have git and maven installed. Now get a bash prompt and download and install WoodChipper:

> git clone http://github.com/fred-o/woodchipper
> cd woodchipper
> mvn package

[lots and lots of maven output]

This builds woodchipper and woodchipper-test-jar. The latter is a small project with trivial classes you can use for testing. Let’s start by trying to run one of the classes directly:

> java -cp woodchipper-test-jar/target/woodchipper-test-jar-1.0-SNAPSHOT.jar woodchipper.TestClass

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Priority
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

Ok, so we get NoClassDefFoundError. That’s actually expected, as I didn’t include any log4j .jar file on the classpath. Anyway, let’s run woodchipper on the sucker:

> java -jar woodchipper/target/woodchipper.jar -i \

Removing Log4J references from woodchipper/TestClass.class
Removing Commons Logging references from woodchipper/TestClass4.class

Looks like it’s working. Let’s try running it again:

> java -cp woodchipper-test-jar/target/woodchipper-test-jar-1.0-SNAPSHOT.jar woodchipper.TestClass

first message!
second message!
third message!
fourth message!
fifth message (with exception!)
    at woodchipper.TestClass.main(TestClass.java:29)

Yay! No log4j dependency anymore! (Note that the exception at the end isn’t acutally an error with WoodChipper, just a logged exception).


Java logging is fundamentally broken. This is hard fact, not a point of view. Logging is broken, and has been for years.

How is it broken, you ask? Let me count the ways:

  • I’ve had application servers die on me because a logging framework was complaining over something. This shouldn’t happen. Ever.
  • One of our old production servers is running JBoss4 and has been running for five years now. About two years ago Log4J started giving strange error messages that has something to do with class loading. I have no idea if we even changed anything, it just stopped working.
  • We switched to Glassfish after that. Now, glassfish is a terrific app server, but it insists on using the JDK logging facilities. Since we use Log4J internally that means everything gets mangled through System.out, then logged with a severity of INFO regardless of the original severity. Glassfish also uses a really ugly multi-line logging format as default. I’d really like to change that if I could only figure out how.
  • Also, we have three Glassfish servers. Two of them write their logs like they’re supposed to. On the third machine (identical setup as far as I can tell) it stops logging right after boot. No indication of what’s going on, just silence.
  • Speaking of JDK logging, what’s up with the logging levels? I dig SEVERE, WARNING, INFO; they’re all right. Maybe even CONFIG. But FINE, FINER and FINEST? That’s just stupid.
  • And don’t get me started about Commons Logging. The problems with this sorry piece of software is well documented.
  • I have never gotten Log4j to work with Jetty, and not for lack of trying.
  • I wanted to deploy Nexus (an otherwise excellent product) to a Glassfish server. Shouldn’t be a problem, right? Just a standard WAR in a standard Servlet container, right? Nope, couldn’t be done because of serious bugs in the logging code. I now have to run Nexus in its own container on a different port. This is frankly ridiculous. Why should the implementors choice of logging framework dictate what web cointainer I can run?

In short, I have spent way to much time just getting simple logging working through the years, and now I’ve had just about enough. Think of the man-hours lost, what we could be doing instead of fiddling with log4j.properties and commons-logging.properties! Why do we put up with this?

The basic principles of logging are sound, but it’s too late. There are simply too many logging frameworks out there, each one making the situation a little bit worse. Commons Logging was bad enough. Log4J fractured the market, and Sun cemented the situation by introducing the badly designed JDK logging package.

Logging meta-frameworks isn’t really helping the situation. The ship has sailed. We don’t need more frameworks, we need less of them. The ideal situation would be exactly one logging framework (that doesn’t suck), that would be the obvious choice for most projects. As it stands now all open source projects use a different one, each incompatible with each others but offering ‘helpful’ and ‘seamless’ integration that never seems quite to work.

Last time I checked the dependencies for our main webapp at work included multiple versions of Log4J, Commons Logging, Slf4J, and problably Logback and a few others I’ve missed as well. Have fun working out the classloader issues there!

An interim solution: WoodChipper

I dreamt this up at work the other day, and this is all purely hypothetical, but I do believe someone should make something like this.

Anyway, WoodChipper (or whatever it will be called, I choose the name since it is a machine that disintegrates logs) is a java utility that goes through all the jar files on your class path and uses sophisticated byte code manipulation to replace all references to Commons Logging, Log4J, JDK logging, etc. with System.out.println(). Ideally this could be done at runtime, or as a maven plugin.

I know some people would argue it’d better to make it all Slf4J instead, but then you’re kind of missing the point. I’ve had enough of logging. I don’t want to spend another minute configuring a logging framework, and I don’t see why I should have to. I’m declaring logging bancruptcy.

Writing to stdout isn’t bad. At least the results can be piped, greped and redirected using standard Unix tools.

Is it time for a NoLOG license?

Today I started thinking that maybe what we need is a new sort of Open Source license, kind of like an inverted GPL. It would state that you’re free to use my code pretty much anyway you like, just as long as the finished product does not depend on a logging framework. Any transgressions would be punishable by catapult.

Extreme measures, perhaps. But if that’s what it takes to get people to stop using Commons Logging, it may well be worth it in the end.

Inspiration-Driven Development

I want to talk a little about inspiration.

The act of programming is of a very creative nature. Abstract concepts like data structures and algorithms get crystalized to code, seemingly created ex nihilo. Where first there was nothing, there is now a file of source code.

Writing code can be an exhausting occupation, and sometimes frustrating. It can wear you out emotionally and physically. But when you’re in the zone, just going with it and letting code flow from your fingers, there’s nothing quite like it. I once tried to describe the allure of coding as “Kind of a cross between knitting and crossword-solving”, by which I mean a highly intellectual activity that’s also half handicraft. My girlfriend, both a crossword enthusiast and a needlework afficionado, understood completely.

Unfortunatly, I find myself spending far less time doing actual development work than I’d like to, and I think this is a common complaint among programmers.

Real Life

The company I work for employs about 60 people, but only five of us work for the IT department. So, we’re a small team that are expected to do everything from refilling printer cartridges to maintaining and architecting the J2EE behemoth that is our web site. My business card says ‘Systems Developer’, but in reality a large part of my job seems to be to figure out what my job is. I do sysadmin stuff, Java coding, CSS troubleshooting, customer support, system integration, even business development on occasion. There’s a lot of non-programming stuff going on, I get a lot of email, and I tend to spend a substatial amount of time on the web, keeping up with current events.

This used to bug me a lot. I resented the constant interruptions, the emails, the meetings. “Why pay me to work here when you won’t let me do my job?” I used to mutter. I loathed myself for wasting company time surfing the web. The stress was getting to me. But lately I’ve come to realize one important thing:

Even the non-coding activities are a part of my job as a developer.

Listening to suggestions, responding to criticism and above all, managing expectations, is crucial. Reading tech blogs is a part of my job, and so is taking a break to slack off or go for a walk if I need to. Because my job isn’t to just sit in front of a computer and produce code. It is to ensure that the systems we deliver are as good as they’re ever going to be.

I know some of my (non-IT) co-workers would be suprised by this. “Surfing the web a part of the job? Really, that’s just a poor excuse for slacking off. That’s like stealing from the Company!”

Just kidding, I have wonderful co-workers. But here’s the thing:

The best coding happens in the brain, long before you actually sit down to write.

I’ll be so bold as to claim that the time you’re spending at the keyboard is your least creative period. There’s too much distractions, too many things happening. You get too invested in what you’re building to think deep and hard about the underlying problem. That’s when you need to take a break, step away from the computer and go do something else.

Pro Tip

Here’s a tip: my favourite way of solving particularly hairy coding problems is to go sit down somewhere with my moleskine and my favourite pen (Pilot G2 0.7mm, since you ask). I try to write down the problem as clear as I possibly can, then go about describing ways of tackling it. Usually I start with some obvious solution, then write down the reason that it won’t work. Then I come up with something else, then something else. And then suddenly the solution presents itself, like magic.

This method has worked, without fail, every time I’ve used it. But you can’t cheat. You need to get away from the computer, and you need to write things down. By hand. I don’t know why, but I suspect the act of writing activates a part of your brain you wouldn’t otherwise be using.


I’ve found that when the stars are aligned correctly I’m at my coding peak between 3pm and 7pm. There seems to be very little I can do about that; earlier in the day my thoughts are too scattered for me to be of any use, and later in the evening I get too hungry to focus on anything but dinner. The sad part about this is that when I’m not working from home I have to leave the office at 5pm in order to catch my train. That leaves about 2 hours of productive time a day.

I’ve come to accept that, and started structuring my day to accomodate this fact instead of fighting it. Before lunch I respond to mail, make notes, read blogs, get the facebooking out of the way, try to check out any bug report we’ve received, return calls to customers who are having problems, etc. Basically, I’m trying to remove all the obstacles that will impede my progress when the gears in my brain finally click and I can get to work.

Some days that doesn’t happen. The magic is gone, and it feels like I can’t get anything done. That’s okay too. There’s always going to be days like that, and it usually happens when I’m stressed out or tired. Those days I do stuff that requires as little mental effort as possible. Simple code refactoring, perhaps. Following up on email. Going through old stuff on the todo list that’s been nagging me. That is, ensuring that when inspiration returns, I will be ready for it.

The Anti-iPad

I bought a new computer last week. A laptop. A very, very tiny laptop, in fact. It’s called a Ben NanoNote, and it makes standard netbooks look cumbersome and unwieldy.

I mean, just look at the thing

My nanonote, dwarfed by the iMac.

Not for everyone, though

This is not a consumer-oriented device, at least not yet. For example, the first thing you should do when you get yours is to reflash the firmware with the latest version. This is a scary operation requiring you to remove the battery, short-circuit a few pins with tinfoil, attach it to a Linux machine and run an update script (which took about 20-30 minutes to finish). This is a hard sell if you’re targeting the regular Apple customers.

With the newest firmware you get a graphical menu system that’s kind-of nice (but ultimatly not very useful) and an mp3 player that I can’t get to play my songs. Don’t know if that’s my fault or not but again, a hard sell for most people.


  • At 110 euro (plus 25 for shipping), it’s relatively inexpensive.
  • It’s running OpenWRT, a linux distribution primarily targeted at embedded devices. You can run vim, zile (bare-bones emacs), python, ruby, lua, whatever you manage to fit into the 32MB of RAM. Surprisingly, mine had a web server activated by default when I got it. I have no idea what I’d do with a web server on this little machine, but it’s still pretty cool.
  • Not only is it running free software, the hardware specs are free as well. In fact, you are encouraged to copy, modify and share the hardware design and build your own devices.
  • It’s small, really small. Smaller than my Nintendo DS, just about the size of my wallet. In fact, just by looking at pictures it’s hard to fathom just how tiny it is. You really need to hold it in your hand.
  • And yet it has a 54-key keyboard. Granted, it’s too small to accommodate touch typing (and I have pretty petite hands) but still, it’s a keyboard with real keys.
  • Oh yeah, and it plays quake.

In short, it’s open (truly open), multi-tasking, small and affordable. It is the Anti-iPad.