Battle analysis

 

Notes about programming

Images and Data

The main components of a wargame are a map and counters.

The map and counters are images

To program a wargame, a hexagon grid coordinate system is used to locate positions on the map. Map coordinates are used to place counters and record terrain data. The counter image id is used to index force data from a unit database.

Hexagon map

The wargame map has a hexagon overlay. Hexagons are used for movement and combat. Hexagons have names associated with them to identify their location for movement. The hexagon name is not a coordinate. The hexagon name is calculated from hexagon points calculations. There are various hexagon naming systems. The most common uses the column count plus the row count down from the top. Others use a letter to reference the column count. The hexagon naming system is very useful for the user interaction. Converting the hexagon name into a hexagon grid coordinate is extremely easy. The hexagon grid provides a common coordinate system for all wargames.

Terrain information is stored in a database with the hexagon point.

Hexagon Map is a set of algorithms to calculate the hexagon coordinates from the screen coordinates.

The hexagon name is also calculated.

Hexagon grid coordinate system

THERE IS NO PRACTICABLE COORDINATE SYSTEM USING HEXAGON NAMES!!!

If you go to HexagonGrids from Red Blob Games, you will find numerous coordinate systems for hexagon grids.

They are trying to create a coordinate system from the hexagon names. This is impractical when calculating geometry.

There is only one workable coordinate system. It is the Cartesian coordinate system from geometry.

Hexagon Grid using hexagon coordinates

Draw a horizonal line thru the hexagon centers and draw a vertical line thru the hexagon centers. This is a workable coordinate system.

This coordinate gives the accurate position on the map or screen.
 
Multiply the coordinate by the x interval (3/4 hexagon width) and the y interval (1/2 hexagon height) .
 
Since this is a real coordinate, all the math and functions of Analytical Geometry work!

There is no need to calculate for offset odd-even columns.

to move N: 0,-2
to move NE: +1,-1
to move SE: +1,+1
to move S: 0,+2
to move SW: -1,+1
to move NW: -1,-1

Bonus: There are some very useful math algorithms for range, direction, line of sight using the grid numbers.

 

Hexagon Grid using hexagon and hexside coordinates

Draw a horizonal line thru the hexagon/hexside centers and draw a vertical line thru the hexagon/hexside centers. This is workable coordinate system if hexsides need to be located.

There is no need to calculate for offset odd-even columns.

to move N: 0,-4
to move NE: +2,-2
to move SE: +2,+2
to move S: 0,+4
to move SW: -2,+2
to move NW: -2,-2

Bonus: There are some very useful math algorithms for range, direction, line of sight using the grid numbers.