Hi! I was trying to mathematically solve a positioning problem for a game I am playing and while I was able to postulate the problem; I feel my education has fallen me short to find a solution. The problem is as follows:

  • You have N shapes compromized of any number of vertices declared as integer offsets from their origin point (the origin point counts as a vertex).

  • Out of the N shapes you have to pick a group of Y size that maximizes the number of overlapping vertices between them with the following rules:

    – The origin point of each shape must be placed on a 2D integer grid.

    – The origin point of each shape must be different from each other shapes origin point.

    – The shapes can be rotated in steps of 90º any number of times.

    – For a vertex to count as overlapping it must be the exact same position as the vertex of at least one other shape and one of the vertices must be the origin point of a shape.

Where could I read material to advance in this problem? Is there an algorithm for these problems?

  • ns1@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 month ago

    Feels like more of an algorithm problem than combinatorics. Not saying I will know the answer but I can think of a few clarifications:

    • is it right to assume the shapes are on a 2D grid?
    • does overlapping mean vertices at the exact same point, or does it mean lying on an edge, or contained in the interior of the other shapes?
    • are we talking about overlaps between pairs of shapes in the group, or vertices overlapping all shapes in the group?
    • Gonzako@lemmy.worldOP
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      1 month ago

      Hi! Here are some clarifications:

      • Yes, the shapes are in a 2D grid
      • Overlapping here means the vertices are the exact same point
      • For each shape, you want to maximize the number of vertices overlapping between all other shapes on the group.
      • After looking a bit more onto the problem there’s another rule. For a vertex to be considered for the maximization it must be the origin point of a shape of the picked group.

      I’ll be adding these clarifications up above!

    • Gonzako@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      I am looking for a list of origin coordinates and orientations that would occur in the maximum possible number of vector overlaps between these shapes. Maybe looking for the minimum number of distinct vertices helps it?

      I am making a small recreation of the system on Godot to see if I understand the problem better.

      • chilicheeselies@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 month ago

        Like another commenter said, I think this is going to be an algorithmic solution.

        Are you shapes able to be translated across the plane, or must they stay in position and just be rotated? If rotated, by some pivot point in the center, or that origin vertex?

        • Gonzako@lemmy.worldOP
          link
          fedilink
          arrow-up
          2
          ·
          1 month ago

          Hi! I’ve advanced a bit more on the and now got a script that calculates the overlaps between pairs of shapes for each of their cardinal orientation. Source code is avaliable on codeberg. It is quite the brute force approach so while it works with the 30 or so possible configurations of the game I doubt it’d scale with the ~~O(n^4) nature of it.

          What’s left is processing the data structure to figure out which combination of 6 shapes/characters and in which positions and orientations would maximize it.

          Regardless, I want to thank you and @ns1@feddit.uk for helping me clarify through the problem.