Keep your distance on a circle This is based on this challenge and Geobits's/CarpetPython's idea to improve it:

Keep your distance!

For this challenge, the distance between two numbers is measured on a loop, so, for example, the distance between 0 and 999 is 1. This should prevent strategies like always picking the lowest or highest number from winning almost every time. The only other change is that the lowest number that can be chosen is now 0 instead of 1.

I'll summarize it here:


Write a function in Java, Python, or Ruby that takes three arguments:

the number of rounds played so far
the number of players
the numbers picked in the previous rounds, as an array of space-separated strings

It should return an integer from 0 to 999, inclusive
The score for a program each round is the sum of the square roots of the distances to the numbers each other program picked
The program with the highest score after 100 rounds wins.
One answer per person


The control program is here:

https://github.com/KSFTmh/src/

Leaderboard

NumberOne, by TheBestOne, is winning.


NumberOne - 9700
NumberOnePlusFourNineNine - 9623
AncientHistorian - 9425
FindCampers - 9259
WowThisGameIsSoDeep - 9069
Sampler - 9014
SabotageCampers - 8545


Apparently, my camper sabotage...er(?) doesn't work very well.

Here are the full results: https://github.com/KSFTmh/src/blob/master/results-3

I think this is different enough to not be a duplicate.

By the way, this is my first time asking a question on Stack Exchange, so let me know if I'm doing something wrong.
Python 2, Sampler

This entry is based on the same code for Keep your distance, Sampler entry. I hope it will do better here where the 1 and 999 advantages do not exist.

Out of a list of places, choose the one that is farthest away from recently used
numbers, ignoring the previous turn (because other entries may predict based on just the previous turn).

def choose(turn, players, history):
    sample = map(int, (' '.join( history[-5:-1] )).split())
    def distance(x):
        return sum(min(1000-abs(x-y), abs(x-y))**0.5 for y in sample)
    score, place = max((distance(x), x) for x in range(1000))
    return place