the structure of my robocode implementation

There has been a lot of code on this blog for my robocode series and I thought I would illustrate the current structure of the codebase to provide some clarity to those following my growing implementation.

Here's the structure of my code so far:

model

The "Adapter" namespace is where my robot resides and this is the only area that knows about the robocode library and its types. This keeps a clean separation between my own model and the robocode library and acts as an anti corruption layer.

The "Battles" namespace is where all my battle code lives for parsing battle results and running acceptance tests - I covered the creation of these in earlier blog posts.

The "Decision" namespace is my new bounded context for decision making. I have a DecisionContextTranslator that knows how to convert the world state into decision state and from there the code is pretty much isolated (although at present it uses the statistics manager directly and I plan to change this in the future if statistics writing requirements grow).

The "Manipulation" namespace is where my robot engine lives and the robot interface that the adapter robot implements so I can speak to it in my model's terms.  I plan on having a context translator here that will know how to issue instructions to the ImARobot interface, through the robot engine.

The "Service" namespace is where I keep my service locator that abstracts from the underlying IOC container. I need this because the robot is created by robocode itself and I need a hook into service resolution to get the robot engine and the resulting dependency tree.

The "Statistics" namespace contains the classes for writing statistics out to assist with acceptance testing requirements.

Finally, the "World" namespace separates out the world state as this transcends into the context translators in each bounded context and resides as an instance in the robot engine. Pulling it out seemed a logical thing to do.

From my original design when thinking about bounded contexts I expect to have a new calculation context introduced soon that will deal with calculations based on the decisions made by the decision context.

There we have it, the "Slayer" robocode implementation so far.
So much code to do so very little! (as my robot doesn't even move, scan or fire yet)
Regardless of battle achievements it has been a really valuable exercise in context specification, test driving something new, acceptance test first development, using domain driven design concepts and experimenting with the new RX framework.

I just hope I can now build on this foundation and get the robot to do some interesting things!



0 comments: