# [1.0.0.194] Map.GetPlotDistance API Bug (Effects Tilted Axis, Start Locations, Etc.)

Discussion in 'Civ6 - Bug Reports' started by blackbutterfly, Nov 18, 2017.

Tags:
1. ### blackbutterflyEmperor

Joined:
May 9, 2016
Messages:
1,196
Gender:
Male
Location:
Leeds, UK
While developing the map scripts for Scrambled Arctic Ocean and AEP Earth, which are radial maps, I stumbled upon a bug with the Map API.

Map.GetPlotDistance() doesn't work correctly, so instead of producing nice circular ice shelves it was producing hexagonal ones.

Here's the correction/fix:

-- bugfix - remember Pythagoras?
function __GetPlotDistance(iX1, iY1, iX0, iY0)
return math.sqrt((iX1-iX0)^2 + (iY1-iY0)^2);
end

Minimal impact on Outback Tycoon scenario map (which is the template for all my map scripts).

Last edited: Nov 22, 2017
Pfeffersack likes this.
2. ### blackbutterflyEmperor

Joined:
May 9, 2016
Messages:
1,196
Gender:
Male
Location:
Leeds, UK
This is what Map.GetPlotDistance will produce if used in map generation. A hex.

This is using Pythagoras:

Note: a vertical line will zig-zag on a hex grid, so a circle will be distorted.

The point is if Map.GetPlotDistance is used to find the distance between points A and B, it will be wrong. Use Pythagoras to calculate distance instead.

Pfeffersack likes this.
3. ### Scrum LordWarlord

Joined:
Jul 2, 2017
Messages:
182
Actually this function is working as designed: Map.GetPlotDistance() determines the number of plots from one point to another on a hex grid. You can use this to space out natrual wonders, for example, like in NaturalWonderGenerator.lua. FXS probably should have called this function Map.GetHexDistance() instead to be extra clear that this is intentionally not Pythagorean distance.

I agree that this is not a good function for drawing circles. Speaking of which, you can remove the zig-zag distortion by adjusting the Pythagorean distance on odd rows like so:
Code:
```function GetPythagoreanDistance(x1, y1, x2, y2)
-- Shift x by half a plot on odd rows to account for hex grid.
if ((y1 % 2) == 1) then
x1 = x1 + 0.5;
end
if ((y2 % 2) == 1) then
x2 = x2 + 0.5;
end
return math.sqrt((x1 - x2)^2 + (y1 - y2)^2);
end```

uhu, blackbutterfly and Laurana Kanan like this.
4. ### blackbutterflyEmperor

Joined:
May 9, 2016
Messages:
1,196
Gender:
Male
Location:
Leeds, UK
Exactly!

I believe it may have even confused FXS own developers.

This is Tilted Axis map (released in 2019):

Scrum Lord likes this.
5. ### Scrum LordWarlord

Joined:
Jul 2, 2017
Messages:
182
Yeah, there's definitely some confusion going on with those hexagonal coastlines and latitude bands. And that diamond-shaped ice cap makes even less sense than a hexagon imo.

But what really confuses me about this map is that it doesn't even match the Tilted Axis map type from Civ 5. What Civ 6 calls "Tilted Axis" is really an Azimuthal projection (Wikipedia) of a world that spins with an Earth-like axis, as opposed to a world whose axis is tilted on its side with one pole always facing the sun which results in hot desert / fertile band on one half of the map and frozen wasteland on the other.

blackbutterfly likes this.
6. ### blackbutterflyEmperor

Joined:
May 9, 2016
Messages:
1,196
Gender:
Male
Location:
Leeds, UK
Yeah, it seems like Tilted Axis was reimagined for Civ VI.
I concur it's trying to be an Azimuth projection.

Tilted Axis was a very flawed map, half developed.
I fixed it and uploaded it -> https://steamcommunity.com/sharedfiles/filedetails/?id=2730207061

Just FYI I posted this bug report back in 2017 (see date OP) almost two years before Tilted Axis shipped (in Sep 2019 update).

Last edited: Jan 25, 2022
7. ### blackbutterflyEmperor

Joined:
May 9, 2016
Messages:
1,196
Gender:
Male
Location:
Leeds, UK
Just to highlight how Firaxis' Map.GetPlotDistance gets worse at larger distances, compare Azimuth Equidistant Earth without and with Pythagoras:

Last edited: Jan 26, 2022
Scrum Lord likes this.