Closed Ukendio closed 3 years ago
We have gotten a lot of traction on this problem 😅.
A few comments to take into account from developers:
Boswwalurus:
Evaera:
Osyris: I'd loop through each player, loop through each spawn, find spawn farthest from any enemy. O(n*m) is perfectly fine here, you won't have more than 100 players and you won't have more than 100 spawns.
sircfenner: I don't think "naive" is the right adjective; it's just a simple solution, and probably the best one
Decided to go with the general consensus. We will take the O(m*n) approach because the size of neither m
or n
will never grow to a size that warrants further optimisation.
Note: A divide-and-conquer algorithm could potentially make it into a O(nlogn).
In this FFA game, we want players that die to respawn at a location with the least enemy players around.
We have a set of spawn locations which are essentially just positions stored in an intrinsic set. A naive O(mn) approach would be iterate through the set and add all players distance relative to the position and compare with last spawn in the set. Another solution could be using Region3 which is relatively expensive, only check players within a certain radius of the spawn and add amount of players to that value in the set.