Tuesday, June 15, 2010

Ready, Fire, Aim (Oops)

I'm working on the fire combat model for the PIC-Guam prototype. I added a FireCombat class to contain the information about the combat. I added a Turn class with lists of FireCombats for the US and Japanese fire phases, and added a list of Turns to the Game class. Then I got down to work. I added a bunch of code to support combat results table (CRT) processing. FireCombatResolution, OddsRatio and FireDieRollModifier are all enums. I also added FireCombatCRT and FireModifier classes, and nonserializable static lists of same to the main FireCombat class. Finally, I added a constructor to FireCombat and a couple of methods to setup the lists of FireCombatCRTs and FireModifiers.


And that was my 49 minutes for today.

Labels: , , , ,

Sunday, June 13, 2010

Fun with Zones of Control

I'm working on elaborating the movement rules by including an awareness of Zones of Control (ZOC). Every unit exerts a zone of control into the surrounding hexes. This has the effect of stopping movement, and triggers Defensive First Fire. I'm implementing movement in the prototype so that entering into movement mode identifies all hexes the unit can move to by highlighting those hexes. It's important to take ZOC's into account, especially since ZOC's stop movement and the rules do not permit movement from one ZOC to another.


This is what I had earlier today. There was a problem in the adjacent hex code...it did not always generate a list of adjacent hexes, resulting in the "jump" over the enemy units shown here.




I fixed the adjacent hex code by providing the proper offsets and better controlling code:

public static List<Hex> AdjacentHexes(int x, int y)
{
List<Hex> adjacentHexes = new List<Hex>();

int[] XOffsets = { 1, 0, -1, -1, 0, 1 };
int[] evenYOffsets = { 1, 1, 1, 0, -1, 0 };
int[] oddYOffsets = { 0, 1, 0, -1, -1, -1 };

int[] YOffsets = (x % 2) == 0 ? evenYOffsets : oddYOffsets;

for (int offset = 0; offset < 6; offset++)
{
adjacentHexes.Add(Hexes.Where(h => h.X == x + XOffsets[offset] && h.Y == y + YOffsets[offset]).First());
}

List<Hex> adjacentHexesOnMap = new List<Hex>();

foreach (Hex h in adjacentHexes)
{
if (IsOnMap(h.Y, h.X))
{
adjacentHexesOnMap.Add(h);
}
}

return adjacentHexesOnMap;
}

This resulted in the following improvement in testing.



I did some more testing, setting up a situation in which hex 1806 should not be in the movement footprint due to the ZOC code. I still had some work to do:



I had added the ZOC logic initially to the first set of adjacent hexes originating from the unit's starting location. I wondered whether I needed to also add that logic to the code that evaluated subsequent hexes further away from the starting point. This proved to be the case:



This finishes off the things on my list now for movement. I'm sure I've forgotten something, even cutting corners as I am for this prototype. Still, I think I have enough for now.

The next task I have is fire combat. This encompases Defensive First Fire, Offensive Fire, and Defensive Fire. This will take some doing.

Labels: , , , ,

Saturday, June 12, 2010

Rolling Along...

I put in another hour and a half on the PIC-Guam prototype today. I am finishing up some additional features for movement. Today I was working on the rule that says a unit can't move from one Zone of Control (ZOC) directly to another. I moved the Hexes from the Game class to be a static member of the Hex class...this makes it easier to access everywhere I need it, and it turns out I need it everywhere. No problem: I relocated the declaration and "rode the compiler" to fix all references.

I'm very pleased with how quickly I can put together meaningful features using C# and LINQ techniques. Using extension methods and lambda expressions, I write terse code with minimal ceremony that is relevant to the requirements.

I like my chances of completing this game in 1000 hours (of effort).

Labels: , , ,