Complete ties should be broken randomly
Opened this issue · 3 comments
It's possible for both the territory and the territory integral of two players to be the same. (Especially when someone is testing versions of their bots locally -- they may behave identically.)
Such ties should be broken randomly (instead of based on player index).
I believe the relevant piece of code is at:
https://github.com/HaliteChallenge/Halite/blob/master/environment/core/Halite.cpp#L347
Which I think could be replaced with something like this, except I'm not a C++ person. Presumably we also need to import some PRNG function and seed it at some point...
// Sort newRankings by last territory count. If it's the same, use the territory integral instead to break that tie.
// But if that's the same, flip a coin.
std::stable_sort(newRankings.begin(), newRankings.end(), [&](const unsigned int & u1, const unsigned int & u2) -> bool {
if (last_territory_count[u1] != last_territory_count[u2]) {
return last_territory_count[u1] < last_territory_count[u2];
}
if (full_territory_count[u1] != full_territory_count[u2]) {
return full_territory_count[u1] < full_territory_count[u2];
}
return RESULT_OF_SOME_COIN_FLIP; // Don't know the C++ way to do this.
});
It would be nice if ties were actually treated as ties, but I think it's too late to make such a drastic change. Randomization is a compromise that would help, but from what @Sydriax has said before I'm not sure even that would be accepted at this point since it would change results of old replays using the same seed and competitors?
I think these "complete ties" are already broken randomly, because as you say, they are broken by player index -- and the indices were assigned randomly. At least I think they are (should be), I haven't checked the code. If you are using the @smiley1983 halite-match-manager locally, the player indices are certainly assigned randomly (that code I know), so there is no bias in the tiebreak.
Yes, on the competition server this isn't an issue in practice since (except for the seed) the players are listed in a random order.