how to calculate the opposite tile of the world

It's 5am again and you are still sitting in front of your computer and chatting with some tv's while watching a bloody duel? Welcome friend :)
User avatar
Posts: 7
Joined: Sat Feb 21, 2015 10:39 am

how to calculate the opposite tile of the world

Postby fritzeeh » Sat Feb 21, 2015 7:45 pm

I thought about calculating the opposite tile of the world for the perfect trade route according to distance. After a few minutes I gave up cause I am confused by the coordinates since there is no constant (1, 1), (2, 2), (3, 3) and so on.
Could you help me please?

User avatar
Posts: 327
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg

Re: how to calculate the opposite tile of the world

Postby dunnoob » Thu Jan 14, 2016 2:07 pm

fritzeeh wrote:Could you help me please?
It depends on the "topology", e.g., if you have "WRAPX", but not "WRAPY", you get hard northern and southern borders (the poles, all glaciers unless you set "alltemperate" or hot average temperatures to melt the ice.) If that's your case you can ignore y in (x,y), either the south pole or the north pole are nearer to your position, and there are most likely no cities on glaciers to trade with.

That leaves x in (x,y). If you defined the map size by xsize and ysize, e.g., 64x64, it's simple: Add 32 to your x-position, and if the result is 64 or more subtract 64. Example, from (12,55) on this map (44,55) is "on the other side" of a WRAPX-topology, and any (44,y) with a city is better than (44,55).

What you are actually looking for is an (x,y) with a city and the biggest (x-12)*(x-12)+(y-55)*(y-55) distance from your position (12,55) in this example. For a rectangular tileset like trident that's mostly also what you see on the map. For an iso-tileset like iso-trident or Amplio the internal x-axis is what you see as south-west to north-east (SW-NE instead of simply S-N), and the internal y-axis is what you see as north-west to south-east (NW-SE instead of W-E).

If you used one of the two other methods to define the map size, i.e., tiles per player, or thousands of tiles (default 4, and 4000 is roughly the same as 4096=64x64), then you have to open options + server options to figure out which xsize and ysize the map generator actually picked. Normally you want ysize greater than xsize, because most tilesets use "landscape" format (width = 2 * height as in Amplio 96x48). The tile size is unrelated to trade route distances, the server doesn't know or care which tileset you use. But ysize > xsize also reduces the length of the boring hard map borders for the poles.