Archive for November, 2009

Bought an XBOX 360 – just for playtesting :-)

Wednesday, November 4th, 2009

Xbox360full_500x526 Just bought a somewhat battered XBOX 360 cheaply online.

So soon we will have the XBOX version ready to rumble as well, now that we can playtest.
Since I don't have any other games for it, I guess I will be extra motivated to make Climate Conflict ever more interesting :)

The first thing I guess I will have to cope with is creating an adapter class which adapts to either keyboard or controller so the gamecode can stay clean and blissfully unaware of what kind of hardware is telling it to do something :) ... and then screen resolution will have to be handled gracefully of course.

Plug-n-Play pathfinding

Wednesday, November 4th, 2009

I once implemented the A* (A-star) pathfinding algorithm in Java, and was ready to do it again in C# for the Klima Konflikt game, but while Googling a bit for referenceimplementations I stumbled across Eric Lippert's very, very elegant solution.
He has basically created a class with a static generic method which will pathfind on anything if you just supply:

1) Items which can tell what their neighbors are - by implementing:
interface IHasNeighbours
IEnumerable Neighbours { get; }
2) A "Begin" and "End" item
3) A function which gives an estimate on the expected distance from an item to an item (WalledTiles in my case).
The distance can be calculated easily using the Pythagorean theorem.
4) [optional] A function which returns a cost for a tile (based on a weighting system you decide).

Here's the signature for the method:

static public Path FindPath(
Node start, Node destination,
Func distance,
Func estimate)
where Node : IHasNeighbours

It took me 20 minutes to implement, just because I am fairly new to the idea of the Func keyword. Thank you Jesper for walking me through it :)
Pathfinding takes approximately 46 ms on our 10x10 tile board.

Screenshot from the current version of the game

Screenshot from the current version of the game

A very, very elegant solution - thanks Eric!

Now in Widescreen :)

Wednesday, November 4th, 2009

Found the default WP theme (which I happen to like) in a wider format at

Nice and easy to install - and with quite a bit more space for your XNA reading enjoyment.

Playable singleplayer version out :)

Sunday, November 1st, 2009

It's amazing what you can do with a few wellplaced questions. The AI for controlling the Oilbarrel in Climate Conflict only has a handful of IF's, but actually does an okay job :)

I will write a proper AI, breadth-first A* algorithm or similar, weighting tiles that are in the opponent's possesion higher.

The entire game also needs some finish as the graphics and music still don't give a cohesive appearance. But we're still building the framework for reuse as we go along.

I'm pretty happy with the AI implementation. My idea is that it should be possible to instantiate a Controller class which then gives input to the gamecomponent to control. The Controller is so far implemented in three different types:

  • KeyBoardController - listens for the users Up/Down/Left/Right keys and request to move in that direction (if possible).
  • RandomController - tries to go in one of the open directions when it enters a tile
  • SimpleDirectionController - tries to move towards a specific tile. This is used to steer the opponent around after his restock-place, but is just as usable to make enemies chase you :)

The abstract base class GameBoardControllerBase is implemented with a method that moves a playing piece forward, and if the piece crosses the center of the tile it calls the methods that are to be implemented in the specific controllers:

protected abstract void SetWantedDirection(Sprite controllee);
protected abstract void UpdateDirection(Sprite controllee);

The first method asks for a wanted direction (e.g. random, based on keyboard, networkplayer's input, recorded, etc...) and then UpdateDirection checks to see whether that is possible right now and adjusts for the current state of the gameboard.

It's working a charm though I've had to write a LOT more Console.WriteLine's than I have in a long time to figure out what the */(¤%(/% the AI was thinking at times :)

Go download the newest release at and let us have some feedback.