sub-article in the series Distances in Freeciv
Definition[]
The Manhattan Distance between two points in a rectangular grid is the number of non-diagonal moves between the two points. In other words, if the destination tile is x tiles horizontal distance and y tiles vertical distance, then |x+y| is the Manhattan Distance.
The name comes from how far a taxi must travel in a city whose streets are in a square grid, such as in Manhattan.
Manhattan Distance in Freeciv[]
Manhattan Distance is one of several different ways Freeciv may calculate distance for certain in-game effects and mechanics. It is used in distance calculation for the following mechanics:
- Minimum distance between cities for a trade route to be legal. (Server setting
trademindist
) - The cost to bribe a unit decreases as its Manhattan Distance from the capital city increases.
- The cost to incite a city decreases as its Manhattan Distance from the capital city increases.
Graphic Illustration[]
Hex Maps[]
On hexagonal tiled maps, mechanics which use Manhattan Distance are substituted by "least number of moves required to arrive at destination tile". In other words, Manhattan Distance and Real Distance become identical on hex maps.
Notes[]
In Freeciv server, Manhattan Distance is rendered by the function:
int map_distance(const struct tile *tile0, const struct tile *tile1)
in: common/map.c