Geeks With Blogs
Boy Meets 'Hello World' Blogging the journey from College Grad to .NET Developer

Ok, in the spirit of DRY, I'm going to write this blog post once, describing my main ideas for the game I've finally decided to start working on. More than just slappy fun, I've decided to implement this game in a hard-core message-passing style, taking hints from the likes of Udi Dahan and Greg Young (note I said hints, so if one of them is reading any future post of mine, beware, your concepts might be twisted to do evil deeds, bwahaha).

The game is planned to be a 4x style turn-based strategy game, similar to the Civilization series, although it may end up being closer to SMAC. A player starts the game in a world that consists of many plots aligned on a 2D grid. They have one or two units, one of which can build a new city. Every turn, a city gains resources based on it's surrounding plots, where it can build city improvements (buildings), or produce units. By balancing your military, technology, economy, foreign diplomacy and politics, you try to forge your empire to victory.

As much as the gameplay details are fun, I'm drooling over the technological aspects of the implementation. Before learning concepts like patterns, TDD, inversion of control, etc., I did some modding on the PC game Civilization 4 (Civ4). Civ4 offered a great amount of modding flexability with their c++ SDK and python scripts. The thing is, you really couldn't unit-test this thing. The CvPlot.cpp class, for instance, was a few thousand lines of code, dealing with every detail of the plot. The AI was built using the CvPlotAI.cpp, a subclass of CvPlot that would override abstract methods on CvPlot. You would have to change something, compile it, then load the entire game, which probably took all of 3 minutes on a reasonably fast computer.

In other words, once I learned unit testing, and found myself working on projects where the time to determine if things worked were nearly instantaneous (run tests, hurray green!), my desire to work on such a large project as Civ4 mods faltered.

I'm hoping to avoid the CvPlot motherload by separating out the various parts into their own services. For example, one service might have a Plot entity that just contains items relating to whether a unit can enter a plot (the owner of the plot, whether the plot is a water/land plot, etc), while another service will contain just info relating to what defensive bonuses units gain if defending on that plot. Still another service will actually determine the results of combat.

Now, this may sound like a recipe for an anemic domain model, but the reality is that each of these "services" really takes in messages, and as a result calls some method on a real entity. This entity is part of my domain model, built using quasi-DDD tactics. However, there isn't one "Plot" entity, or one "Unit" entity, but actually multiple such entities, one for each specific concern, and maybe a few for some aggregate concerns.

So, there in a nutshell is my project. It doesn't yet have a name, and I probably won't release more than the snippets I post here just for simplicity's sake. Right now, I'm working on some core classes. I'll probably start small; 9x9 grid of dots with a moveable X in the console, small. Hopefully the architecture will allow for a gui to be built without much change at all.

Posted on Tuesday, May 27, 2008 6:25 PM TheGame | Back to top

Comments on this post: Introducing "The Game"

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © mhildreth | Powered by: