Find Desired Amount of Furthest Away Objects From Each Other
A method for selecting a specific number of objects that maintain maximum spacing from one another using a spatial sampling algorithm.

This method provides a way to select a specific number of objects that are spread out as evenly as possible across an area. By utilizing a variation of "Farthest Point Sampling," the algorithm ensures that every selected object maintains maximum "breathing room" from the rest of the group.
Spatial Sampling Logic
A common mistake when attempting to find widely spaced objects is searching for the "maximum distance to any single object." This can result in the algorithm selecting a point that is very far from one existing object but touching another.
To achieve proper distribution, the logic must instead find the point whose closest neighbor is as far away as possible from the entire existing set. This is known as Maximizing the Minimum Distance.
Implementation Workflow
The algorithm builds the set one point at a time through a three-level nested loop structure.
Setup: Use Get All Spawn Points (or a similar object retrieval node) to populate an
All Pointslist. UseCreate Empty Listto initialize aSelected Pointslist and define aTarget Count.Initial Selection: Use
Get Random ItemfromAll Pointsto add the first point to theSelected Pointslist, then useRemove Itemto take it out ofAll Points.Main Loop: While the
CountofSelected Pointsis less than theTarget Count, perform the following:
Outer Loop: For each
CandidateinAll Points:Inner-Inner Loop: For each
Selected PointinSelected Points:Calculate the
Distancebetween theCandidateand theSelected Point.Track the smallest distance found; this is the candidate's "safety buffer."
Comparison: Once the Inner-Inner Loop finishes, check if this candidate's smallest distance is greater than the current
Max Min Distance. If it is, updateMax Min Distanceand set this candidate as theBest Candidate.Finalize Round: After the Outer Loop completes, add the
Best CandidatetoSelected Pointsand remove it fromAll Points.



Variable Management
To ensure the algorithm correctly identifies the most isolated candidate, variables must be reset at different stages of the loop hierarchy.
Max Min Distance
0
Start of the Main Loop
Tracks the largest "safety buffer" found during the current selection round.
Min Distance
10000
Start of the Outer Loop
Tracks the distance to the closest neighbor for the current candidate.
Source Data
Discord thread: Find Desired Amount of Furthest Away Objects From Each Other
Contributors
Okom Guild Archivist swagonflyyyy (Mr. Blackwell)
Last updated