Fair (equidistant) metal distribution and spawns

Discussion in 'Mapping and stuff' started by zihuatanejo, February 12, 2015.

  1. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    Wrote some code to generate coordinates for N equidistant (approximately) points on a planet, mainly with the goal of having fair spawns for large free for all games, but you can also use it for the distribution of metal spots.



    It is a bit clunky, you have to copy and paste the coordinates into a .pas file, but there's room for improvement and automation. The placement isn't 100% perfect because it turns out that 'generating n equidistant points on the surface of a sphere of a given radius' is actually quite tricky and doesn't have a perfect solution. My approach uses a Fibonacci Sphere/Spiral to generate points.

    Large drawback for using it for metal spots is that it assumes a perfect sphere, so unless the heightRange variable is set to zero for the generation of the planet, you'll get points above the surface (or possibly below the surface, hard to tell.

    However, I think it is ideal for generating spawn zones for single planet FFA games, especially for more than ten players. And where the algorithm fails, you can normally tweak the landing zones by eye.

    I might try a different algorithm whereby the points 'repel' each other instead of the Fibonacci sphere method. Will share the code if anyone wants it, it just needs a bit of polish.
    xankar, kalherine, proeleert and 6 others like this.
  2. eroticburrito

    eroticburrito Post Master General

    Messages:
    1,633
    Likes Received:
    1,836
    Water looks better on 0 Height Range, and as far as game-changing terrain goes, pathable CSG currently functions better than leaving it up to procedural height ranges.

    So this looks great man! I'm sure are interesting unique map ideas to be had here.
    stuart98 likes this.
  3. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    I haven't tried anything to do with CSG stuff, bit beyond me. Last week's custom server shenanigans with The Realm just got me thinking about single planet FFA maps with fair equidistant spawns. Current system editor doesn't let you do it.

    Also, @guest1, any chance of merging this somehow with your DirectEdit mod? Importing/exporting .pas files is a real chore, it'd be great to integrate this.
  4. Alpha2546

    Alpha2546 Post Master General

    Messages:
    977
    Likes Received:
    1,561
    I need this for spawn placement. Can I has this amazing code of yours? I'm trying to make a huge FFA planet but I want the spawns to be fair ofcourse. How do I do this? Thanks!
    zihuatanejo likes this.
  5. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    I'm tr ying to make a huge FFA planet too! That was pretty much the sole motivation for working on this code last night. PM me or hit me up in IRC and I'll send you the code. Ultimately I'd like to make it a PAMM mod and maybe even integrate it with DirectEdit, or into the system designer itself. Tried it last night with 12 spawns, which end up being perfectly equidistant because you can use an icosahedron - using a dodecahedron should yield 20 equidistant spawns. For other numbers it isn't perfect, but good enough.

    How many spawns did you have in mind?
    guest1 and Alpha2546 like this.
  6. Alpha2546

    Alpha2546 Post Master General

    Messages:
    977
    Likes Received:
    1,561
    Lol I just checked wiki for some number. Right now I only want 8 spawns. Is that possible? Thanks for the quick response!
  7. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    8can be done accurately using an octohedron but i haven't done the coordinates for that yet. What radius do you want the planet to be?

    EDIT: oops, octahedron is 6 vertices, not 8. 6 is a perfect case, 8 is not. Currently my code for arbitrary cases of N does not do a good job for 8 spawns, but you can improve it easily by eye.
    Last edited: February 13, 2015
    Alpha2546 likes this.
  8. Alpha2546

    Alpha2546 Post Master General

    Messages:
    977
    Likes Received:
    1,561
  9. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    I pm'd you mate :)
    Alpha2546 likes this.
  10. teddythebear

    teddythebear Member

    Messages:
    50
    Likes Received:
    21
    We have these things called cubes you know.
  11. crizmess

    crizmess Well-Known Member

    Messages:
    434
    Likes Received:
    317
    I LOLed a bit :)
  12. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    Are you referring to using a cube's eight vertices for spawns? Because not all vertices in a cube are equidistant from each other, obviously... and equidistant points on the surface of a sphere is what I'm aiming for.
  13. crizmess

    crizmess Well-Known Member

    Messages:
    434
    Likes Received:
    317
    All vertices of a cube are equidistant from each of its adjacent neighbours - per definition. Even more: All vertices of a cube can be "mapped" to any other vertex by a simple isometric transformation (e.g. rotation) in a way that the remaining vertices are congruent(*) at the end, that means that all vertices on a cube are non-distinguishable from each other within the given metric of R3. This is as far as a definition of equidistant (**) can go in my opinion.
    In fact, a cube is one of the five platonic solids we have in three dimensions.

    (*) Well, this may be the wrong words, I'm sorry for that. Never tried to do geometry in English.

    EDIT: (**) equidistant spawns is the wrong word, it is more like equal spawns.
    In an n-dimensional flat euclidean space, you can only place n+1 points in a way that all points are equidistant from each other, and without loss of generality you can place them on the n-dimensional unitsphere.
    So on a planet, we can only place up to 4 points that are all truly equidistant from each other.
    Last edited: February 13, 2015
  14. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    Pretty sure you're wrong mate, I don't think you're considering the diagonals, so to speak. The four corners of a square are not all equidistant from each other, are they? Which translates into 3D space as a cube, so same thing holds. I might not be fully understanding you, and I was up all night, so I might be making rudimentary mistakes, I don't know, but pretty sure you're wrong about the cube :p
  15. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    If you start considering diagonals straight through the body then the images of your mex spots are also very very far away from equidistant mex.
  16. crizmess

    crizmess Well-Known Member

    Messages:
    434
    Likes Received:
    317
    Yes, equidistant is the wrong word.
    But imagine a dice (or a cube) without any markings.
    You pick one vertex from this dice. If someone rotates the dice (in 90 degree steps) a few times without you noticing it (this is the isometric transformation), there is no way how you can find your vertex again. This is because (this is the non-distinguishable part) in fact all the vertices are the same. And this is why the eight vertices of a cube can be considered as equal spawns.
    Try this with a pyramid (the one with a square base) if you pick the top one vertex you will always find this vertex again, because the top always stands out. If you pick one of the base vertices you will find the base vertices again, but you will not know which of the four it was. This is all deeply bound to symmetry in geometry. The pyramid has one symmetric axis, on the other hand a cube has three symmetric axis, so you can map any vertex to any other vertex with rotation.
  17. crizmess

    crizmess Well-Known Member

    Messages:
    434
    Likes Received:
    317
    You don't even need to consider diagonals through the body. Every distribution with more than 4 mexes has mexes that are farther away then others. Just look at the first picture in this thread.
  18. trilioth

    trilioth Member

    Messages:
    93
    Likes Received:
    36
  19. zihuatanejo

    zihuatanejo Well-Known Member

    Messages:
    798
    Likes Received:
    577
    Yeah but once you subdivide an icosahedron twice you have like 60 points. don't think we need 60 spawns ;) the planet generator probably starts with a geodesic dome like that to represent a sphere and is then deformed.

    Anyway, this thread is a bit crazy now. I need to clarify I think, that i'm talking about spawns being equidistant from their adjacent neighbours. Obviously all points are not going to be equidistant from all other points!
  20. earth75

    earth75 Member

    Messages:
    93
    Likes Received:
    25
    then you can use a cube to make 8 spawns

Share This Page