So a few years ago (here) I raised the prospect of a donut-shaped map. The premise was that because of a hole in the center, each player would only have two fronts to worry about, rather than having to worry about the space all around them (depending on start location). This makes some things easier strategically -- for example, you only have to face two other players at any given time, at your clockwise and counter-clockwise fronts -- but some things more difficult -- for example, a runaway Psilon on the other end of the map is harder to reach, though it also means it'll take him longer to reach you (giving you more time to prepare). RefSteel kindly made some trial maps of the concept here.
Well I never got around to testing (i.e. playing) them, but the mathematical problem related to this has stuck around in my head. The problem is, given an initial distribution of stars, how do I map the stars' coordinates into a map with a hole in the middle, while maintaining an equal density of stars all across the map? By "equal" I mean that if the initial map is uniformly distributed (i.e. each region of the initial map has an equal likelihood of stars), the mapping would end up with a final map that is also uniformly distributed (i.e. each region of the final map still has an equal likelihood of stars), within the donut-shaped region. The reason why this is important is that without this consideration, the mapping may end up with clumps of stars next to each other depending on what part of the map the stars were at. Note that I don't know if MoO's placement of stars really is uniformly distributed (other than a blank area near the borders), but I'll assume that it is.
I got around to solving this mathematical problem a few days ago. I'm not sure if it's correct, but I *think* it is. There's basically two components to this: from a radial direction (i.e. inward or outward from the center of the map), and a tangential direction (i.e. moving along a circle of a given radius from center of map).
For the radial component, assume that the width of the initial map is 2*s1, the height of the initial map is 2*s2, the inner radius of the new donut is r1, and the outer radius of the new donut is r2. The star is currently located at (x, y), where these are the horizontal and vertical distances, respectively, from the center of the map (both positive and negative numbers possible; the save file stores them as from the upper left corner of the map, i.e. positive numbers only). Let d/s be the max of abs(x/s1) or abs(y/s2), i.e. a ratio of how far the star is from the center of the map, relative to the edge of the map, in concentric rectangles. Then, radially, the radius of that star in the new donut is given by:
r = (r1^2 + (d/s)^2*(r2^2-r1^2))^0.5
For the tangential component, if you took slices of equal radians (i.e. same number of degrees) from the center of the map, you'll find that the slices toward the corners have more stars compared with the slices toward the middles of each side. But say you took slices such that it divides each side into the same sized chunks, i.e. say to each quarter of each side (i.e. draw lines to 0*s, 0.25*s, 0.50*s, 0.75*s, 1*s where s is the length of each side), each of those slices have the same area and thus the same density of stars. So to equalize to theta, you just project each star's coordinates to the border and measure how far it's moved along the border. The formula for this is a bit more complicated simply because there are if cases, but if the star is in the right part of the map (i.e. a line from the center of the map to the star's coordinates projects to the right border), the formula for the theta (in degrees) is 45*y/x, if it's to the top it's 90 - 45*x/y, if it's to the left it's 180 + 45*y/x, if it's to the bottom it's 270 - 45*x/y. Note that these coordinates are for standard Cartesian plane, not MoO's coordinate system, but the transformation is easy to do.
Finally, if you want to (roughly) maintain the same distance between stars, the area of the donut has to match the area of the original map, so that the overall star density remains the same. This is easy; the original map's area is simply width * height, while the area of the donut is simply pi * outer radius^2 - pi * inner radius^2. Note that this requirement plus the donut's inner radius will uniquely determine the donut's outer radius; similarly, this requirement plus the ratio (outer radius/inner radius) will uniquely determine both the inner and outer radii.
An image showing the mapping using Excel is below:
As you can see, the new map is somewhat bigger than the old map, because of the hole in the center. To maintain the same density, stars that were originally near the center of the map tend to be squeezed (closer together) radially, while stretched (farther apart) tangentially. The closer they were to the center the bigger this distortion is. For example, in this case, a star originally along the edge of the map (i.e. d/s = 1) has very little distortion; it's stretched tangentially by around 2.3%. A star that was about halfway in (i.e. d/s = 0.5) is stretched tangentially by around 35%, while a star that was about 3/4 of the way in (i.e. d/s = 0.25) is stretched tangentially by around 123%, with the reciprocal change in being squeezed radially. If I did the derivation correctly, though, each unit area of the original map should be transformed to an area of the same size in the new map.
So how does this work with MoO? Putting this into a script into Matlab that changes the stars' coordinates in the MoO savefile (as well as adjusting the size of the map), the original and new maps for a huge sized map look like:
Note that the new map is actually bigger -- as evidenced by the location of the nebulae, whose coordinates were not changed. However, for whatever reason, the size of the viewing area (the rectangle indicated by the 4 corners that's supposed to represent how much area you see when in regular view) didn't get smaller to reflect the larger map size; I don't know where that parameter is located in the save file. (Note: I know that MoO apparently only grabs that parameter the first time you load a game, and after that it doesn't change this parameter, even if you load games of different map sizes; however, this was from a fresh load of MoO.) A view of the area around the starting point, for the original and then the new map, is below:
The right, bottom right, bottom left, and left stars used to be 3, 3, 4, and 3 parsecs away, respectively. After the transformation, they're now 4, 4, 5, and 3 parsecs away. Meanwhile, the purple star to the upper left used to be 10 parsecs away but is now 5 parsecs away, due to the squeezing in the radial direction. So the bottom left star (which was close to a tangential direction) is now somewhat farther away, while the purple star (which was close to a radial direction) is now closer. The other stars, which were a mix of the two, had their distances adjusted somewhat but not too much. I don't know if this is ideal; I think "ideal" is really something more like if a typical star usually has say 5 stars within 5 parsecs, then after the mapping it should still (on average) have 5 stars within parsecs. I don't know if maintaining the same density achieves this, but hopefully it's a "good enough" approximation to start.
(more in the next post due to attachment limit)
Well I never got around to testing (i.e. playing) them, but the mathematical problem related to this has stuck around in my head. The problem is, given an initial distribution of stars, how do I map the stars' coordinates into a map with a hole in the middle, while maintaining an equal density of stars all across the map? By "equal" I mean that if the initial map is uniformly distributed (i.e. each region of the initial map has an equal likelihood of stars), the mapping would end up with a final map that is also uniformly distributed (i.e. each region of the final map still has an equal likelihood of stars), within the donut-shaped region. The reason why this is important is that without this consideration, the mapping may end up with clumps of stars next to each other depending on what part of the map the stars were at. Note that I don't know if MoO's placement of stars really is uniformly distributed (other than a blank area near the borders), but I'll assume that it is.
I got around to solving this mathematical problem a few days ago. I'm not sure if it's correct, but I *think* it is. There's basically two components to this: from a radial direction (i.e. inward or outward from the center of the map), and a tangential direction (i.e. moving along a circle of a given radius from center of map).
For the radial component, assume that the width of the initial map is 2*s1, the height of the initial map is 2*s2, the inner radius of the new donut is r1, and the outer radius of the new donut is r2. The star is currently located at (x, y), where these are the horizontal and vertical distances, respectively, from the center of the map (both positive and negative numbers possible; the save file stores them as from the upper left corner of the map, i.e. positive numbers only). Let d/s be the max of abs(x/s1) or abs(y/s2), i.e. a ratio of how far the star is from the center of the map, relative to the edge of the map, in concentric rectangles. Then, radially, the radius of that star in the new donut is given by:
r = (r1^2 + (d/s)^2*(r2^2-r1^2))^0.5
For the tangential component, if you took slices of equal radians (i.e. same number of degrees) from the center of the map, you'll find that the slices toward the corners have more stars compared with the slices toward the middles of each side. But say you took slices such that it divides each side into the same sized chunks, i.e. say to each quarter of each side (i.e. draw lines to 0*s, 0.25*s, 0.50*s, 0.75*s, 1*s where s is the length of each side), each of those slices have the same area and thus the same density of stars. So to equalize to theta, you just project each star's coordinates to the border and measure how far it's moved along the border. The formula for this is a bit more complicated simply because there are if cases, but if the star is in the right part of the map (i.e. a line from the center of the map to the star's coordinates projects to the right border), the formula for the theta (in degrees) is 45*y/x, if it's to the top it's 90 - 45*x/y, if it's to the left it's 180 + 45*y/x, if it's to the bottom it's 270 - 45*x/y. Note that these coordinates are for standard Cartesian plane, not MoO's coordinate system, but the transformation is easy to do.
Finally, if you want to (roughly) maintain the same distance between stars, the area of the donut has to match the area of the original map, so that the overall star density remains the same. This is easy; the original map's area is simply width * height, while the area of the donut is simply pi * outer radius^2 - pi * inner radius^2. Note that this requirement plus the donut's inner radius will uniquely determine the donut's outer radius; similarly, this requirement plus the ratio (outer radius/inner radius) will uniquely determine both the inner and outer radii.
An image showing the mapping using Excel is below:
As you can see, the new map is somewhat bigger than the old map, because of the hole in the center. To maintain the same density, stars that were originally near the center of the map tend to be squeezed (closer together) radially, while stretched (farther apart) tangentially. The closer they were to the center the bigger this distortion is. For example, in this case, a star originally along the edge of the map (i.e. d/s = 1) has very little distortion; it's stretched tangentially by around 2.3%. A star that was about halfway in (i.e. d/s = 0.5) is stretched tangentially by around 35%, while a star that was about 3/4 of the way in (i.e. d/s = 0.25) is stretched tangentially by around 123%, with the reciprocal change in being squeezed radially. If I did the derivation correctly, though, each unit area of the original map should be transformed to an area of the same size in the new map.
So how does this work with MoO? Putting this into a script into Matlab that changes the stars' coordinates in the MoO savefile (as well as adjusting the size of the map), the original and new maps for a huge sized map look like:
Note that the new map is actually bigger -- as evidenced by the location of the nebulae, whose coordinates were not changed. However, for whatever reason, the size of the viewing area (the rectangle indicated by the 4 corners that's supposed to represent how much area you see when in regular view) didn't get smaller to reflect the larger map size; I don't know where that parameter is located in the save file. (Note: I know that MoO apparently only grabs that parameter the first time you load a game, and after that it doesn't change this parameter, even if you load games of different map sizes; however, this was from a fresh load of MoO.) A view of the area around the starting point, for the original and then the new map, is below:
The right, bottom right, bottom left, and left stars used to be 3, 3, 4, and 3 parsecs away, respectively. After the transformation, they're now 4, 4, 5, and 3 parsecs away. Meanwhile, the purple star to the upper left used to be 10 parsecs away but is now 5 parsecs away, due to the squeezing in the radial direction. So the bottom left star (which was close to a tangential direction) is now somewhat farther away, while the purple star (which was close to a radial direction) is now closer. The other stars, which were a mix of the two, had their distances adjusted somewhat but not too much. I don't know if this is ideal; I think "ideal" is really something more like if a typical star usually has say 5 stars within 5 parsecs, then after the mapping it should still (on average) have 5 stars within parsecs. I don't know if maintaining the same density achieves this, but hopefully it's a "good enough" approximation to start.
(more in the next post due to attachment limit)