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 http://klimakonflikt.codeplex.com and let us have some feedback.