When I started the project Helvetios I thought how to map each cell individually, to give it an address to each one for when I developed the algorithms to interact with them. Mi first idea was to number the cells form the centre to the outside, making an spiral:
This way, when programming the addressing algorithms I could make an array of numbered cells. Each cell of that array would be a data structure: the colour, if it has ha piece over or not, the illumination effect and the numbers of the neighbour cells.
By this, when addressing a cell I could know which will be the next cell if I move to a certain direction.
Besides I would design the algorithms to calculate distances and ranges. To for example, light the cells to move around a piece, or to light a shooting line from a piece. I thought these algorithms could go through this cells structure and selecting the right neighbour cells based in the direction and the selected function. More or less I had all these though to, when designing the board control library, define these data structures.
But this was before knowing the page Red Blog Games. In this brilliant page there are analysis of a lot of mapping techniques and how to calculate their addressing algorithms. It has a section of hexagonal maps https://www.redblobgames.com/grids/hexagons/ where it establish for types of addressing: Offset, Cube, Axial and Doubled. The coordinate system I’ll choose would be Cube and look like this:
Also defines the algorithms to change from a coordinate system to another, to calculate distances, lines, movements, ranges, intersections, obstacles, rotations, reflections, rings, spirals an line of sight.
So I already have all the needed theory to develop the library to interact with the board. This way I could design the data structures and functions to program the game algorithm.
This algorithm will allow at first a two player in turns game. Initially the two at the same board, but the target is to make an online game. Also will be possible to develop an AI to play against offline so, when the board will be fully developed, I will research for AI algorithms for gaming.
Leave a Reply