January 2, 2023

Combat Simulation II

Previously, I discussed basic, unhindered movement. But movement is rarely unhindered, and so we'll need to add constraints and obstacles.

The trickiest part of this was figuring out how to represent a battle map in memory. I want to use an inefficient format like JSON because its human readable and we can check it into source control easily. As I was going over old combats, I realized that this tool could be very helpful to review both your own historical fights but also those of others, like a quarterback going over old game film.

For now, I'll try to use the simplest possible case. Map hexes are flat-topped and have an equal movement cost. To represent buildings or other structures, one of the sides of the hex is denoted "blocked": that is, no movement may take place through that side. If all 6 sides are blocked, the entire hex is impassable: perhaps a large tree. If two or more sides are blocked, the hex is considered a partial hex and movement/combat buffs may apply.

The following diagram shows two groups of combatants: blue and red. The thick black lines show the outline of a small keep, with several broken walls providing gaps.

Let us say that the blue combatant entering the keep at the bottom wishes to move elsewhere. He'll have to spend 1 AP disengaging from combat, leaving him with 1 or 2 AP for movement. His possible moves are then as follows:

For our purposes here, we'll ignore certain moves that would end in an opponent's hex, such as charging or overbearing.

Later, we can make the map more complex by introducing travel costs for each hex, but this will be fine for now.

No comments:

Post a Comment