[Question]
  [
Create a bot to choose the smallest unique number.
(Based on a psychology experiment I heard about many years ago but haven't been able to track down again.)
### Rules
* Each game will consist of 10 randomly selected bots playing 1000 rounds.
* Each round, all bots select an integer from 1 to 10 (inclusive). Any bots that choose the same value will be be excluded, and the remaining bot with the smallest value will receive a point.
* In the event that no bot picks a unique value, no points will be awarded.
* At the end of 1000 rounds, the bot with the most points (or all bots tied with the most points) wins the game.
* The tournament will last 200 \* (number of players) games.
* The bot with the highest win percentage wins the tournament.
### Specifications
Bots must be Python 3 classes and must implement two methods: `select` and `update`.  
Bots will be constructed with an index.  
`select` is passed no arguments and returns the bot's choice for the current round.  
`update` is passed a list of the choices made by each bot in the previous round.
### Example
```
class Lowball(object):
    def __init__(self, index):
        # Initial setup happens here.
        self.index = index
    def select(self):
        # Decision-making happens here.
        return 1
    def update(self, choices):
        # Learning about opponents happens here.
        # Note that choices[self.index] will be this bot's choice.
        pass
```
### Controller
```
import numpy as np
from bots import allBotConstructors
allIndices = range(len(allBotConstructors))
games = {i: 0 for i in allIndices}
wins = {i: 0 for i in allIndices}
for _ in range(200 * len(allBotConstructors)):
    # Choose players.
    playerIndices = np.random.choice(allIndices, 10, replace=False)
    players = [allBotConstructors[j](i) for i, j in enumerate(playerIndices)]
    scores = [0] * 10
    for _ in range(1000):
        # Let everyone choose a value.
        choices = [bot.select() for bot in players]
        for bot in players:
            bot.update(choices[:])
        # Find who picked the best.
        unique = [x for x in choices if choices.count(x) == 1]
        if unique:
            scores[choices.index(min(unique))] += 1
    # Update stats.
    for i in playerIndices:
        games[i] += 1
    bestScore = max(scores)
    for i, s in enumerate(scores):
        if s == bestScore:
            wins[playerIndices[i]] += 1
winRates = {i: wins[i] / games[i] for i in allIndices}
for i in sorted(winRates, key=lambda i: winRates[i], reverse=True):
    print('{:>40}: {:.4f} ({}/{})'.format(allBotConstructors[i], winRates[i], wins[i], games[i]))
```
### Additional information
* No bot will play in a game against itself.
* In the unlikely event that a bot is included in less than 100 games, the tournament will be rerun.
* Bots may store state between rounds, but not between games.
* Accessing the controller or other bots is not allowed.
* The number of games and number of rounds per game are subject to increase if the results are too variable.
* Any bots that raise errors or give invalid responses (non-ints, values outside [1, 10], etc.) will be disqualified, and the tournament will be rerun without them.
* There is no time limit for rounds, but I may implement one if bots take too long to think.
* There is no limit on the number of submissions per user.
* ~~The deadline for submissions is 23:59:59 UTC on Friday, September 28.~~ The tournament is now closed for submissions.
### Results
```
                BayesBot: 0.3998 (796/1991)
      WhoopDiScoopDiPoop: 0.3913 (752/1922)
           PoopDiScoopty: 0.3216 (649/2018)
                   Water: 0.3213 (660/2054)
                 Lowball: 0.2743 (564/2056)
                Saboteur: 0.2730 (553/2026)
                OneUpper: 0.2640 (532/2015)
         StupidGreedyOne: 0.2610 (516/1977)
          SecondSaboteur: 0.2492 (492/1974)
                    T42T: 0.2407 (488/2027)
                     T4T: 0.2368 (476/2010)
          OpportunityBot: 0.2322 (454/1955)
              TheGeneral: 0.1932 (374/1936)
             FindRepeats: 0.1433 (280/1954)
                  MinWin: 0.1398 (283/2025)
             LazyStalker: 0.1130 (226/2000)
               FollowBot: 0.1112 (229/2060)
                Assassin: 0.1096 (219/1999)
           MostlyAverage: 0.0958 (194/2024)
             UnchosenBot: 0.0890 (174/1955)
                 Raccoon: 0.0868 (175/2015)
               Equalizer: 0.0831 (166/1997)
       AvoidConstantBots: 0.0798 (158/1980)
WeightedPreviousUnchosen: 0.0599 (122/2038)
               BitterBot: 0.0581 (116/1996)
               Profiteur: 0.0564 (114/2023)
              HistoryBot: 0.0425 (84/1978)
            ThreeFourSix: 0.0328 (65/1984)
                 Stalker: 0.0306 (61/1994)
             Psychadelic: 0.0278 (54/1943)
              Unpopulist: 0.0186 (37/1994)
             PoissonsBot: 0.0177 (35/1978)
         RaccoonTriangle: 0.0168 (33/1964)
              LowHalfRNG: 0.0134 (27/2022)
              VictoryPM1: 0.0109 (22/2016)
            TimeWeighted: 0.0079 (16/2021)
             TotallyLost: 0.0077 (15/1945)
            OneTrackMind: 0.0065 (13/1985)
              LuckySeven: 0.0053 (11/2063)
          FinalCountdown: 0.0045 (9/2000)
                Triangle: 0.0039 (8/2052)
           LeastFrequent: 0.0019 (4/2067)
                Fountain: 0.0015 (3/1951)
             PlayerCycle: 0.0015 (3/1995)
                  Cycler: 0.0010 (2/1986)
               SecureRNG: 0.0010 (2/2032)
             SneakyNiner: 0.0005 (1/2030)
            I_Like_Nines: 0.0000 (0/1973)
```
  
[Answer]
# BayesBot
Tries to make the optimal choice using a simple statistical model.
```
import random
def dirichlet(counts):
    counts = [random.gammavariate(n, 1) for n in counts]
    k = 1. / sum(counts)
    return [n * k for n in counts]
class BayesBot(object):
    def __init__(self, index):
        self.index = index
        self.counts = [[0.2 * (10 - i) for i in range(10)] for _ in range(10)]
    def select(self):
        player_distributions = []
        for i, counts in enumerate(self.counts):
            if i == self.index:
                continue
            player_distributions.append(dirichlet(counts))
        cumulative_unique = 0.
        scores = [0.] * 10
        for i in range(10):
            p_unpicked = 1.
            for d in player_distributions:
                p_unpicked *= (1. - d[i])
            p_unique = p_unpicked * sum(d[i] / (1. - d[i]) for d in player_distributions)
            scores[i] = p_unpicked * (1. - cumulative_unique)
            cumulative_unique += p_unique * (1. - cumulative_unique)
        return scores.index(max(scores)) + 1
    def update(self, choices):
        for i, n in enumerate(choices):
            self.counts[i][n - 1] += 1
```
[Answer]
# Avoid Constant Bots
Keep track of which bots have always returned the same value, and skip those values. Of the remaining values, select them randomly, but biased significantly towards lower values.
```
import numpy as np
class AvoidConstantBots(object):
    all_values = range(1, 11)
    def __init__(self, index):
        self.index = index
        self.constant_choices = None
    def select(self):
        available = set(self.all_values)
        if self.constant_choices is not None:
            available -= set(self.constant_choices)
        if len(available) == 0:
            available = set(self.all_values)
        values = np.array(sorted(available))
        weights = 1. / (np.arange(1, len(values) + 1)) ** 1.5
        weights /= sum(weights)
        return np.random.choice(sorted(available), p=weights)
    def update(self, choices):
        if self.constant_choices is None:
            self.constant_choices = choices[:]
            self.constant_choices[self.index] = None
        else:
            for i, choice in enumerate(choices):
                if self.constant_choices[i] != choice:
                    self.constant_choices[i] = None
```
[Answer]
# WaitWhatBot
Not the most competitive bot and definitely not [GTO](https://en.wikipedia.org/wiki/Nash_equilibrium "Game Theory Optimal"), but will stifle the score of any "always 1" or "nearly always 1" opponent in the same game as in such a scenario WaitWhatBot becomes such a bot too.
Uses evolving probabilities with weighted weights both in time (more recent -> greater weight) and choice value (lower point -> greater weight).
Uses somewhat obfuscated code for a bit of a giggle.
```
from random import choices as weightWeight
class WaitWhatBot(object):
    def __init__(wait,what):
        weight,weightWhat=5,2
        wait.what,wait.weight=what,(weight**(weight/weight/weightWhat)+weightWhat/weightWhat)/weightWhat
        wait.whatWeight,wait.weightWeight=[wait.what==wait.weight]*int(wait.weight**weight),wait.weight
        wait.whatWhat=wait.whatWeight.pop()#wait, when we pop weight off whatWeight what weight will pop?
        wait.waitWait=tuple(zip(*enumerate(wait.whatWeight,wait.weightWeight!=wait.whatWeight)))[weightWeight==wait.weight]
    def select(what):return int(what.weight**what.whatWhat if all(not waitWait for waitWait in what.whatWeight)else weightWeight(what.waitWait,what.whatWeight)[what.weight==what.what])
    def update(waitWhat,whatWait):
        what,wait,weightWhat=set(wait for wait in whatWait[:waitWhat.what]+whatWait[waitWhat.what+1:]if wait in waitWhat.waitWait),-~waitWhat.whatWhat,waitWhat.weightWeight
        while wait not in what:
            waitWhat.whatWeight[wait+~waitWhat.whatWhat]+=weightWhat
            weightWhat/=waitWhat.weight
            wait-=~waitWhat.whatWhat
        if not wait!=(what!=weightWhat):waitWhat.whatWeight[waitWhat.whatWhat]+=weightWhat
        waitWhat.weightWeight*=waitWhat.weight
```
[Answer]
# Flow Like Water
Avoids basic constant bot detection algorithms by doubling up on each number, slowly advancing toward lower values if they're unoccupied.
```
class Water(object):
    def __init__(self, index):
        self.index = index
        self.round = 0
        self.play = 4
        self.choices = [0]*10
    def select(self):
        if self.round > 0 and self.round%2 == 0:
            if not max([1, self.play - 1]) in self.choices:
                self.play -= 1
        return self.play
    def update(self, choices):
        self.round += 1
        self.choices = choices
```
[Answer]
# Stalker
At the start of the game, this bot randomly chooses a specific index as its target. It then stalks that target the entire game, copying the number that it chose in the previous round.
```
import random
class Stalker(object):
  def __init__(self, index):
    # choose a random target to stalk that isn't ourself
    self.targetIndex = random.choice([x for x in range(10) if x != index])
    # get a random number to start with since we haven't seen our target's value yet
    self.targetValue = random.randint(1, 10)
  def select(self):
    return self.targetValue
  def update(self, choices):
    # look at what our target chose last time and do that
    self.targetValue = choices[self.targetIndex]
```
[Answer]
# Whoop-di-scoop-di-poop
```
class WhoopDiScoopDiPoop(object):
    def __init__(self, index):
        self.index = index
        self.guess = 1
        self.tenure = 0
        self.perseverance = 4
    def select(self):
        return self.guess
    def update(self, choices):
        others = {c for i, c in enumerate(choices) if i != self.index}
        for i in range(1, self.guess):
            if i not in others:
                self.guess = i
                self.tenure = 0
                self.perseverance += 1
                return
        if self.guess not in others:
            self.tenure = 0
            return
        self.tenure += 1
        if self.tenure > self.perseverance:
            if self.guess == 10:
                return
            self.guess += 1
            self.tenure = 0
```
# Poop-di-scoopty
```
class PoopDiScoopty(object):
    def __init__(self, index):
        self.index = index
        self.guess = 1
        self.tenure = 0
        self.perseverance = 4
    def select(self):
        return self.guess
    def update(self, choices):
        others = [c for i, c in enumerate(choices) if i != self.index]
        for i in range(1, self.guess):
            if i not in others:
                self.guess = i
                self.tenure = 0
                self.perseverance += 1
                return
        if self.guess not in others:
            self.tenure = 0
            return
        self.tenure += others.count(self.guess) # this is the change
        if self.tenure > self.perseverance:
            if self.guess == 10:
                return
            self.guess += 1
            self.tenure = 0
```
I've never seen or touched Python, is this unpythonic?
[Answer]
# Opportunitybot
This bot keeps track of the lowest number not chosen by any other bots each round (the lowest available number, or opportunity), and plays the number that has been that number most frequently.
```
class OpportunityBot(object):
    def __init__(self, index):
        self.index = index
        self.winOccasions = [0,0,0,0,0,0,0,0,0,0]
    def select(self):
        return self.winOccasions.index(max(self.winOccasions))+1
    def update(self, choices):
        choices.pop(self.index)
        succeeded = [choices.count(i)==0 for i in range(1,11)]
        self.winOccasions[succeeded.index(True)] += 1
```
[Answer]
# Stupid Greedy One
```
class StupidGreedyOne(object):
    def __init__(self, index):
        pass
    def select(self):
        return 1
    def update(self, choices):
        pass
```
This bot assumes that other bots don't want to tie.
I realize this is the same as the provided example but I had the thought before I'd read that far. If this is incongruous with how KoTH challenges are run, let me know.
[Answer]
# The top 50% RNG bot
```
import random
class LowHalfRNG(object):
    def __init__(self, index):
        pass
    def select(self):
        return random.randint(1, 5)
    def update(self, choices):
        pass
```
I was about to post a random bot, but hidefromkgb posted before me (by posting they're making themselves an easy target for the KGB, not a good way to hide). This is my first KOTH answer, just hoping to beat the rng bot.
[Answer]
# HistoryBot
```
import random
class HistoryBot(object):
    def __init__(self, index):
        self.pastWins = []
    def select(self):
        if not self.pastWins:
            return 1
        return random.choice(self.pastWins)
    def update(self, choices):
        unique = [x for x in choices if choices.count(x) == 1]
        if unique:
            self.pastWins.append(min(unique))
```
Implementation of user2390246's comment:
> 
> What about this then? Start with 1. After the first round, keep track
>  of the winning values and pick randomly from them with probability
>  equal to the number of occurrences. E.g. if the winning values in the
>  first three rounds are [2, 3, 2] then in round four, pick [2] with p =
>  2/3 and [3] with p = 1/3.
> 
> 
> 
[Answer]
## OneUpper
```
class OneUpper(object):
    def __init__(self, index):
        self.index = index
    def select(self):
        return 2
    def update(self, choices):
        pass
```
Everyone else's bots are either aiming for 1 or random, so why not just aim for 2?
[Answer]
# The Final Countdown
```
class FinalCountdown(object):
    def __init__(self, index):
        self.round = -1
    def select(self):
        self.round += 1
        return (10 - self.round // 100)
    def update(self, choices):
        pass
```
[Try it online!](https://tio.run/##bY/BCoMwEETvfsUeE2o10lvBU6G/IWmyqSmykSTS9uvtWkSkdI@zM4@Z8Z37QKd5NoNOCa6e9HAJE2UbniTC7YEmy3MBfBYddJ0nn7tOJBxcCZ4svtb3cotaRY5baOHYbDHWmfMN/XcfWmg2PWKeIoFoFBz3prqGRim5UafR6oxrFdMHbzDt8CMPmp3hJj@rGFG4EMFzf4ia7ihUyWS1hsfoKQtnqrW2lPMH "Python 3 – Try It Online")
Returns 10 for the first 100 rounds, 9 for the next 100 and so on.
[Answer]
# PatterMatcher
Looks for repeating sections in the submissions of the bots, tries to predict and avoid there numbers.
```
class PatternMatcher(object):
    def __init__(self, index):
        self.bots=[[]]*9
        self.index=index
    def select(self):
        minVisible=3    #increase these if this bot is to slow
        minOccurences=2
        predictions=set()
        for bot in self.bots:     
            #match patters of the form A+(B+C)*minOccurences+B and use C[0] as a prediction      
            for lenB in range(minVisible,len(bot)//(minVisible+1)+1):
                subBot=bot[:-lenB]
                patterns=[] 
                for lenBC in range(lenB,len(subBot)//minOccurences+1):
                    BC=subBot[-lenBC:]
                    for i in range(1,minOccurences):
                        if BC!=subBot[-lenBC*i-lenBC:-lenBC*i]:
                            break
                    else:
                        patterns.append(BC)
                predictions|={pattern[lenB%len(pattern)] for pattern in patterns}
        other=set(range(1,11))-predictions
        if other: return min(other)
        else: return 1                
    def update(self, choices):
        j = 0
        for i,choice in enumerate(choices):
            if i == self.index:
                continue
            self.bots[j].append(choice)
            j += 1
```
# Triangle
The chance of picking n is `(10-n)/45`
```
import random
class Triangle(object):
    def __init__(self, index):pass
    def select(self):return random.choice([x for x in range(1, 11) for _ in range(10 - x)])
    def update(self, choices):pass
```
# TimeWeighted
The probability a bot chooses a number is proportional to `(10-n)*Δt`. The first round this is identical to triangle. 
```
import random
class TimeWeighted(object):
    def __init__(self, index):
        self.last=[0]*10
        self.round=1 
    def select(self):
        weights=[(self.round-self.last[i])*(10-i) for i in range(10)]
        return 1+random.choice([x for x in range(10) for _ in range(weights[x])])
    def update(self, choices):
        for c in choices:
            self.last[c-1]=self.round
        self.round+=1
```
# LeastFrequent
Submits the least frequently occurring number, if they are equal, take the lowest one.
```
class LeastFrequent(object):
    def __init__(self, index):self.frequenties=[0]*10
    def select(self):return 1+self.frequenties.index(min(self.frequenties))
    def update(self, choices):
        for c in choices:
            self.frequenties[c-1]+=1
```
# LongestTime
Same as with frequenties but with the longest time between submissions.
```
class LongestTime(object):
    def __init__(self, index):
        self.frequencies=[0]*10
        self.round=1
    def select(self):return 1+self.frequencies.index(min(self.frequencies))
    def update(self, choices):
        for c in choices:
            self.frequencies[c-1]=self.round
        self.round+=1
```
# Saboteur
Submits the lowest number which was submitted last time.
```
class Saboteur(object):
    def __init__(self, index):self.last=[1]
    def select(self):return min(self.last)
    def update(self, choices):self.last=choices
```
# SecondSaboteur
Submits the second lowest number which was submitted last time
```
class SecondSaboteur(object):
    def __init__(self, index):self.last=[1,2]
    def select(self):return min({i for i in self.last if i!=min(self.last)})
    def update(self, choices):self.last=choices
```
# Profiteur
Submits the lowest number not submitted last time
```
class Profiteur(object):
    def __init__(self, index):self.last=set()
    def select(self):return min(set(range(1, 11))-self.last, default=1)
    def update(self, choices):self.last=set(choices)
```
Sorry I got a bit carried away, getting idea for new bots while implementing the previous once. I wasn't sure which one would be the best and I'm curious about the performance of each of them. You can find them all here: <https://repl.it/@Fejfo/Lowest-Unique-Number>
[Answer]
# The Cycler
This bot simply cycles through each of the numbers on its turns. Just for fun, it initializes the counter with its index.
```
class Cycler(object):
  def __init__(self, index):
    self.counter = index # Start the count at our index
  def select(self):
    return self.counter + 1 # Add 1 since we need a number between 1-10
  def update(self, choices):
    self.counter = (self.counter + 1) % 10
```
[Answer]
# Totally Lost
```
class TotallyLost(object):
    def __init__(self, index):
        self.index = index
        self.round = 0
        self.numbers = [4,8,1,5,1,6,2,3,4,2]
    def select(self):
        return self.numbers[self.round % len(self.numbers)]
    def update(self, choices):
        self.round = self.round + 1
```
[Answer]
## OneTrackMind
This bot randomly picks a number and sticks with it for 50 rounds, then picks another and repeats.
```
import random
class OneTrackMind(object):
    def __init__(self, index):
        self.round = 0;
        self.target = random.randint(1,10)
    def select(self):
        return self.target
    def update(self, choices):
        self.round += 1;
        if self.round % 50 == 0:
            self.target = random.randint(1,10)
```
[Answer]
# Lucky Seven
```
class LuckySeven(object):
    def __init__(self, index):
        pass
    def select(self):
        return 7
    def update(self, choices):
        pass
```
I'm feeling lucky today! I'm throwing out everything on 7!
[Answer]
My idea is that the strategy is more dependent on the number of bots than on actual evaluation of strategies.
With a significant number of bots, the options are:
* "Greedy" robots aiming to the lower 1-3 numbers 10 bots being "clever" and aiming to get the lower 1-3 numbers, the best is to just let those bots interfere between them.
* "Smart" robots who, once they realize 4 is always picked up, will go elsewhere.
* "Random" and "constant" robots. Not much to do here.
So, I bet on #4.
```
class LazyStalker(object):
    def __init__(self, index):
        pass
    def select(self):
        return 4
    def update(self, choices):
        pass
```
[Answer]
# The essential RNG bot
```
import secrets
class SecureRNG(object):
    def __init__(self, index):
        pass
    def select(self):
        return secrets.randbelow(10) + 1
    def update(self, choices):
        pass
```
[Answer]
# Assassin
Stays in the shadows, then aims for the current lowest guess. Run.
```
class Assassin(object):
    def __init__(self, index):
        self.index = index
        self.round = 0
        self.choices = [0]*10
    def select(self):
        if self.round == 0:
            return 10
        else:
            return min(self.choices)
    def update(self, choices):
        self.round += 1
        self.choices = choices
        self.choices[self.index] = 10
```
[Answer]
# FollowBot
Copy the winner from the last round, or at least the best minimally-tied selection if there was no winner.
```
import collections
class FollowBot(object):
    def __init__(self, index):
        self.lastround = []
    def select(self):
        counter = collections.Counter(self.lastround)
        counts = [(count,value) for (value,count) in counter.items()]
        counts.sort()
        if len(counts) >= 1:
            return counts[0][1]
        else:
            return 1
    def update(self, choices):
        self.lastround = choices
```
[Answer]
## Psychadelic
The only way to win a nuclear war is to make yourself insane. So I'm going to make every predictive bot in the tournament insane.
```
class Psychadelic(object):
    def __init__(self, index):
        self.index = index
    def select(self):
        return random.randint(1, self.index + 1)
    def update(self, choices):
        pass
```
[Answer]
# UnchosenBot
```
class UnchosenBot(object):
    def __init__(self, index):
        self.index = index
        self.answer = 0
    def select(self):
        if self.answer == 0:
            return 1
        return self.answer
    def update(self, choices):
        self.answer = 0
        del choices[self.index]
        for x in range(1, 11):
            if x not in choices:
                self.answer = x
                return
```
Takes the last round's choices, and chooses the lowest unchosen number (ignoring UnchosenBot's choice, of course).
[Answer]
# Fountain
A simple bot, picks the lowest number first and if any other bot chooses it too, it will increment the counter - the floor gets filled and the water flows down. When it reaches 11, it restarts to 1 - the water gets pumped back to the top.
```
class Fountain:
    def __init__(self, index, target=10):
        # Set data
        self.index = index
        self.pick  = 1
        self.target = target+1
    def select(self):
        # Select the number
        return self.pick
    def update(self, choices: list):
        # Remove self from the list
        choices.pop(self.index)  # I hope `choices[:]` is passed, not `choices`.
        # While the selected number is occupied
        while self.pick in choices:
            # Pick next number
            self.pick += 1
            # If target was reached
            if self.pick == self.target:
                # Reset to 1
                self.pick = 1
```
[Answer]
# PoissonsBot
Select numbers from a Poisson distribution which is biased to lower values. Adjust the mean parameter of the distribution up if we are in a tie and down if there are guesses below us. Step size gets progessively smaller as the game proceeds.
```
from numpy.random import poisson
import math
class PoissonsBot(object):
    def __init__(self, index):
        self.index = index
        self.mean = 2
        self.roundsleft = 1000
    def select(self):
        self.roundsleft = max(self.roundsleft-1, 2)
        return max(min(poisson(self.mean),10),1)
    def update(self, choices):
        myval = choices[self.index]
        nequal = len([c for c in choices if c==myval])
        nless = len([c for c in choices if c<myval])
        step = math.log10(self.roundsleft)
        if nequal > 1:
            self.mean += nequal/step
        self.mean -= nless/step
        self.mean = max(self.mean, 0.3)
    
```
[Answer]
# MinWin
Keeps a running count of the winning values and the minimum unselected values (where the minimum unselected value is only considered if it is less than the winning value). It randomly selects among these winning and minimum values.
```
import random
class MinWin:
    def __init__(self, index):
        self.index = index
        self.mins = list(range(1, 11))
        self.wins = list(range(1, 11))
    def select(self):
        return min(random.choice(self.mins), random.choice(self.wins))
    def update(self, choices):
        counts = [0] * 10
        for x in choices:
            counts[x - 1] += 1
        if 0 in counts and (1 not in counts or counts.index(0) < counts.index(1)):
            self.mins.append(counts.index(0) + 1)
        if 1 in counts:
            self.wins.append(counts.index(1) + 1)
```
[Answer]
# PlayerCycle
Cycles through the players. Current player (could be self)'s choice is now this bot's choice. Starts out printing 8, because why not. Sorry I can't python, this is probably bad code.
```
import itertools
class PlayerCycle(object):
    def __init__(self, index):
        self.a = itertools.cycle(range(10))
        self.b = 8
    def select(self):
        return self.b
    def update(self, choices):
        self.b = choices[next(self.a)]
```
Edit: Thanks to Triggernometry for improving my code with itertools
[Answer]
# **Raccoon**
Choose the lowest number not chosen in the previous round, except our own previous choice, which could be chosen again this time. In the first round, choose 1. (Given 9 opponents and 10 choices, there is guaranteed to be one available value.)
I came up with this independently, but now see at least 2 previous bots that are essentially the same.
```
class Raccoon(object):
    def __init__(self, index):
        self.index = index
        self.last_round = None
        self.domain = None
    def select(self):
        # Return the lowest number not chosen last time.
        if self.domain is None:
            return 1
        else:
            # This finds the smallest element of domain, not present in last_round
            return min(self.domain-self.last_round)
    def update(self, choices):
        last_round = choices[:]
        last_round[self.index] = 0 # don't include our own choice
        self.last_round = set(last_round)
        if self.domain is None:
            self.domain = set(range(1,len(choices)+1))
```
# **Raccoon Triangle**
Combines Raccoon and Triangle: from the unchosen values, choose one based on reverse triangle probability.
```
import random
class RaccoonTriangle(object):
    def __init__(self, index):
        self.index = index
        self.unchosen = set([1,])
        self.domain = None
    def select(self):
        # Return the lowest number not chosen last time.
        if self.domain is None:
            return random.randint(1,self.index+1)
        else:
            # Reverse triangle weights for unchosen values
            weighted_choices = [u for i,u in enumerate(sorted(self.unchosen),0) for _ in range(len(self.unchosen)-i)]
            return random.choice(weighted_choices)
    def update(self, choices):
        last_round = choices[:] # make a copy
        last_round[self.index] = 0 # don't include our own choice
        if self.domain is None:
            self.domain = set(range(1,len(choices)+1))
        self.unchosen = self.domain - set(last_round)
```
[Answer]
# The General
The General always fights the last war*(s)*.
```
import numpy
import random
class TheGeneral:
    def __init__(self, index):
        self.round = 0
        self.index = index
        self.would_have_won = [0] * 10
    def select(self):
        if self.round <= 100:
            return random.choice((list(numpy.nonzero(self.would_have_won)[0]) + [0, 1])[:2]) + 1
        return random.choice(numpy.argsort(self.would_have_won)[-2:]) + 1
    def update(self, choices):
        for i, s in enumerate(numpy.bincount([c - 1 for i, c in enumerate(choices)
            if i != self.index], minlength=10)):
            if s == 0:
                self.would_have_won[i] += 1
            elif s == 1:
                break
        self.round += 1
```
[Answer]
# No-Repeat Random
```
import secrets
class NoRepeats(object):
    def __init__(self, index):
        self.lastround = secrets.randbelow(10) + 1
    def select(self):
        i = secrets.randbelow(10) + 1
        while i == self.lastround:
             i = secrets.randbelow(10) + 1
        self.lastround = i
        return self.lastround
    def update(self, choices):
        pass
```
Bot picks randomly, but avoids picking the same number it did the previous round.
]