We are currently developing a tile-based and turn-based game. In our game, there are characters that can attack others from afar. However, the attack range seems a little bit hard to describe using algorithms. It is illustrated below, every number indicates the range between the tile ‘0’ and itself.
5 4 3 3 3 4 5
4 3 2 2 2 3 4
3 2 1 1 1 2 3
3 2 1 0 1 2 3
3 2 1 1 1 2 3
4 3 2 2 2 3 4
5 4 3 3 3 4 5
Is it possible to implement a function like this?
int GetRange( const Grid & a, const Grid & b );
Only 3 possible cases need to be dealt with:
In C++: