Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete ties should be broken randomly #381

Open
rooklift opened this issue Jan 6, 2017 · 3 comments
Open

Complete ties should be broken randomly #381

rooklift opened this issue Jan 6, 2017 · 3 comments

Comments

@rooklift
Copy link
Contributor

rooklift commented Jan 6, 2017

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.
});
@Janzert
Copy link
Contributor

Janzert commented Jan 16, 2017

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?

@erdman
Copy link
Contributor

erdman commented Jan 21, 2017

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.

@Janzert
Copy link
Contributor

Janzert commented Jan 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants