I've been working on a boardgame that has a hex grid as this board:
Since the board will never change and the spaces on the board will always be linked to the same other spaces around it, should I just hard code every space with the values that I need? Or should I use various algorithms to calculate links and traversals?
To be more specific, my board game is a 4 player game where each player has a 5x5x5x5x5x5 hex grid (again, the image above). The object is to get from the bottom of the grid to the top, with various obstacles in the way, and each players being able to attack each other from the edge of their grid onto other players based on a range multiplier.
Since the players grid will never change and the distance of any arbitrary space from the edge of the grid will always be the same, should I just hard code this number into each of the spaces, or should I still use a breadth first search algorithm when players are attacking?
The only con I can think of for hard coding everything is that I'm going to code 9+ 2(5+6+7+8) = 61 individual cells. Is there anything else that I'm missing that I should consider using more complex algorithms?
int numberOfHexagonsInArea(int rows) { int area = 1; while(rows>0) { area += (rows-1)*6; rows--; } return area; }
\$\endgroup\${X,Y}
you can obviously go to{X-1, Y}
and{X+1, Y}
on the same row. On the rows below and above you can go to{X, Y-1}
and{X, Y+1}
. Finally, depending on the even-ness ofY
, you can go to{X-1, Y-1}
and{X-1, Y+1}
or {X+1, Y-1}` and{X+1, Y+1}
\$\endgroup\$