I have nothing to show for the last week’s work on Concealed Intent. Not because I haven’t been working, but because the effort was spent behind the scenes. I have been working on rearchitecting the simulation maths (mainly for detection).
Originally all the simulation code was attached to classes representing the spaceships themselves. So a ship has sensors and those sensors knew how to detect other ships – typical OO design. However, during early testing a number of different ways were suggested to handle detection and determine lock. I needed to be able to change between multiple simulation schemes easily. Thus in the last week the maths has been put into its own class using a Strategy Pattern. This change made testing easier (so I wrote some tests – and found a few silly maths errors!) and allowed the ship classes to be greatly simplified.
After that it wasn’t too hard to create a builder system for creating scenarios. Below is the new code for creating my 2-against-1 test scenario. I think this is quite easy to understand what the scenario involves. It can get more complicated with goals and events added, but the declarative syntax remains.
ScenarioBuilder builder = new ScenarioBuilder("Mark's Mission"); builder.Calcs(BasicCalcsBuilder.Create().NoiseMult(5).TimeDecay(1).TargettingGain(1.5f)); builder.Skybox("SkyBoxes/Basic Star Field/Basic Star Field").ViewScale(0.66f); builder.CameraFov(25).CameraPosition(336, 270, -525).CameraRotation(25, 330, 0); builder.AddEntity(EntityBuilder.Create("Sulaco", EntityType.CORVETTE).SetAsPlayer().Position(100, 0, 0).DefaultLoadout()); builder.AddEntity(EntityBuilder.Create("Pirate 1", EntityType.SKIFF).Ctrl(Control.TENTATIVE_CONTROL).Position(0, 0, 400).DefaultLoadout().SetAsEnemy()); builder.AddEntity(EntityBuilder.Create("Pirate 2", EntityType.SKIFF).Ctrl(Control.AGGRESSIVE_CONTROL).Position(-200, 0, -300).DefaultLoadout().SetAsEnemy()); builder.AddEntity(EntityBuilder.Create("Brockley", EntityType.MERCURY).Ctrl(Control.PREVIEW_CONTROL).Position(40, 0, 40)); builder.AddEntity(EntityBuilder.Create("Star", EntityType.G_STAR).Position(0, 0, 40000).Rotation(0, 180, 0));
So after a week, the game is largely where it started – just with more tests and easier to modify maths and scenarios. I think it was worth the effort. Next up, trying out various new systems for detection and lock.