tic tac toe v003
The state of Version 003
In Version 3 I included an AI-Player and added three more game modes. The computer player has its own set of tests to ensure its function.
The AI is essentially asleep until the game state changes. A changed game state triggers the AI and it checks, if an AI move is expected. The AI is keeping a list of the Tic Tac Toe fields and tries to occupy them at random. It keeps trying to occupy fields until the game no longer looks like the AI should move.
Encounters while implementing the feature The players depend on the game, so in order to make testing easier the interface IGame (see picture above) was extracted. The framework Rhino Mocks is easiest to use with Interfaces.
A great advantage of a testproject is, that a whole proof of concept can be integrated entirely within the testproject. This is not listed in the overview, since it does not belong to the gametests. But I had a problem raising events using Rhino Mocks. To solve this issue I created a stand alone selftesting small example which worked fine. Since this will not influence the project in any way I can just let this small example stay there forever. If Rhino Mocks ever changes their behaviour I will be notified by the failing test.
While testing the AI manually, I discovered a bug, which was created during the transition from V001 to V002. A feature was not ensured by testing so a simple change created a bug that was not immediately spotted. This demonstrates the importance of testing even in one person projects.
Next To Do After getting some features done it is wise to spend some time refactoring before implementing the next feature. Looking at IGame it seems like most of the stuff is made to give information in what state the game is currently in. The concept of the gamestate is also visible in the way the computer player tries to infere (see private makemove in the sourcefiles) if it is its turn. And a third indicator is that the gamestate is even a named concept in the viewmodel. We will create a gamestate that answers the questions about the gamestate that the other colaborators have.
Map tiles that are not taken by a player bare the char(32) (= spacebar character) marking. I think they should be taken by ‘NoPlayer’ - so we have to implement an IPlayer interface for NoPlayer and use that instead of char(32).
The feature that we will implement after those refactorings is a sligthly harder AI that actually thinks before making a move.