Make multiplayer respawn algorithm "fairer" #189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In recent years bad respawn locations have been a pet peeve of many 1v1 players. The existing algorithm tries to respawn players from starts at least 15 segments away from any other player - but often, particularly in smaller levels, there simply is no such spawn point available, and it lands on a purely randomly-chosen player start instead. There has been discussion about whether that minimum segment distance should be reduced, as it was in earlier versions of Rebirth - but I recall it was restored because players weren't happy with that option either (it tended to make spawn positions too predictable).
So instead I just wrote a new algorithm that handles the problem more methodically. It calculates weights for all player starts in the level according to how far away the closest live player is (with those within line-of-sight treated as though the distance is halved). It then picks the best half of the player starts (usually 4 options) and does a weighted random selection from those, with an adjustment to ensure that the outcome isn't too predictable.
I've shared a "beta" build with a number of players on the RDL, which has been circulating for a little over a month; there doesn't seem to have been any alarming feedback so far, so I figure it makes sense to submit the update as an off-by-default optional feature - which maybe we can turn on by default in future. I added some logging that can be used for analysis if players report that the algorithm isn't meeting expectations.