Smallest unique number KoTH

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
1












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


Additional information



  • No bot will play in a game against itself. (Until there are 10 submissions, games will need to run with less than 10 bots.)

  • 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 tournament will end on Friday, September 28 (two weeks from when this question is posted).









share|improve this question























  • Can we import modules/libraries in our classes?
    – maxb
    48 mins ago










  • Is there a controller?
    – Erik the Outgolfer
    46 mins ago










  • @maxb Yes, so long as I can get it running.
    – Mnemonic
    45 mins ago










  • @EriktheOutgolfer Not yet. I'll link as soon as it's finished.
    – Mnemonic
    44 mins ago






  • 1




    @Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
    – Mnemonic
    39 mins ago














up vote
5
down vote

favorite
1












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


Additional information



  • No bot will play in a game against itself. (Until there are 10 submissions, games will need to run with less than 10 bots.)

  • 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 tournament will end on Friday, September 28 (two weeks from when this question is posted).









share|improve this question























  • Can we import modules/libraries in our classes?
    – maxb
    48 mins ago










  • Is there a controller?
    – Erik the Outgolfer
    46 mins ago










  • @maxb Yes, so long as I can get it running.
    – Mnemonic
    45 mins ago










  • @EriktheOutgolfer Not yet. I'll link as soon as it's finished.
    – Mnemonic
    44 mins ago






  • 1




    @Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
    – Mnemonic
    39 mins ago












up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





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


Additional information



  • No bot will play in a game against itself. (Until there are 10 submissions, games will need to run with less than 10 bots.)

  • 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 tournament will end on Friday, September 28 (two weeks from when this question is posted).









share|improve this 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


Additional information



  • No bot will play in a game against itself. (Until there are 10 submissions, games will need to run with less than 10 bots.)

  • 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 tournament will end on Friday, September 28 (two weeks from when this question is posted).






king-of-the-hill






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 57 mins ago

























asked 1 hour ago









Mnemonic

4,0721424




4,0721424











  • Can we import modules/libraries in our classes?
    – maxb
    48 mins ago










  • Is there a controller?
    – Erik the Outgolfer
    46 mins ago










  • @maxb Yes, so long as I can get it running.
    – Mnemonic
    45 mins ago










  • @EriktheOutgolfer Not yet. I'll link as soon as it's finished.
    – Mnemonic
    44 mins ago






  • 1




    @Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
    – Mnemonic
    39 mins ago
















  • Can we import modules/libraries in our classes?
    – maxb
    48 mins ago










  • Is there a controller?
    – Erik the Outgolfer
    46 mins ago










  • @maxb Yes, so long as I can get it running.
    – Mnemonic
    45 mins ago










  • @EriktheOutgolfer Not yet. I'll link as soon as it's finished.
    – Mnemonic
    44 mins ago






  • 1




    @Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
    – Mnemonic
    39 mins ago















Can we import modules/libraries in our classes?
– maxb
48 mins ago




Can we import modules/libraries in our classes?
– maxb
48 mins ago












Is there a controller?
– Erik the Outgolfer
46 mins ago




Is there a controller?
– Erik the Outgolfer
46 mins ago












@maxb Yes, so long as I can get it running.
– Mnemonic
45 mins ago




@maxb Yes, so long as I can get it running.
– Mnemonic
45 mins ago












@EriktheOutgolfer Not yet. I'll link as soon as it's finished.
– Mnemonic
44 mins ago




@EriktheOutgolfer Not yet. I'll link as soon as it's finished.
– Mnemonic
44 mins ago




1




1




@Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
– Mnemonic
39 mins ago




@Soaku It's absolutely possible, but the cleverness on this site never ceases to impress me.
– Mnemonic
39 mins ago










5 Answers
5






active

oldest

votes

















up vote
1
down vote













Stupid Greedy One



class StupidGreedyOne(object):
def __init__(self, index):
pass
def select(self):
return 1
def update(self, choices):
pass


This bot presume that other bots will presume 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.






share|improve this answer






















  • In general I prefer not to have duplicate bots, but I don't mind leaving it.
    – Mnemonic
    37 mins ago






  • 1




    @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
    – hidefromkgb
    36 mins ago










  • @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
    – Engineer Toast
    23 mins ago











  • No worries. Welcome to the wonderful world of KoTH!
    – Mnemonic
    22 mins ago

















up vote
1
down vote













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





share|improve this answer










New contributor




hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote













    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.






    share|improve this answer






















    • @Mnemonic fixed!
      – maxb
      17 mins ago

















    up vote
    0
    down vote













    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):

    self.index = index
    self.pick = 1

    def select(self):

    return self.pick

    def update(self, choices: list):

    choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.

    for choice in choices:

    if choice == self.pick:

    self.pick += 1

    if self.pick == 11:

    self.pick = 1





    share|improve this answer





























      up vote
      0
      down vote













      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





      share|improve this answer










      New contributor




      Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

















        Your Answer




        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172178%2fsmallest-unique-number-koth%23new-answer', 'question_page');

        );

        Post as a guest






























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1
        down vote













        Stupid Greedy One



        class StupidGreedyOne(object):
        def __init__(self, index):
        pass
        def select(self):
        return 1
        def update(self, choices):
        pass


        This bot presume that other bots will presume 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.






        share|improve this answer






















        • In general I prefer not to have duplicate bots, but I don't mind leaving it.
          – Mnemonic
          37 mins ago






        • 1




          @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
          – hidefromkgb
          36 mins ago










        • @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
          – Engineer Toast
          23 mins ago











        • No worries. Welcome to the wonderful world of KoTH!
          – Mnemonic
          22 mins ago














        up vote
        1
        down vote













        Stupid Greedy One



        class StupidGreedyOne(object):
        def __init__(self, index):
        pass
        def select(self):
        return 1
        def update(self, choices):
        pass


        This bot presume that other bots will presume 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.






        share|improve this answer






















        • In general I prefer not to have duplicate bots, but I don't mind leaving it.
          – Mnemonic
          37 mins ago






        • 1




          @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
          – hidefromkgb
          36 mins ago










        • @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
          – Engineer Toast
          23 mins ago











        • No worries. Welcome to the wonderful world of KoTH!
          – Mnemonic
          22 mins ago












        up vote
        1
        down vote










        up vote
        1
        down vote









        Stupid Greedy One



        class StupidGreedyOne(object):
        def __init__(self, index):
        pass
        def select(self):
        return 1
        def update(self, choices):
        pass


        This bot presume that other bots will presume 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.






        share|improve this answer














        Stupid Greedy One



        class StupidGreedyOne(object):
        def __init__(self, index):
        pass
        def select(self):
        return 1
        def update(self, choices):
        pass


        This bot presume that other bots will presume 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.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 24 mins ago

























        answered 44 mins ago









        Engineer Toast

        4,9041036




        4,9041036











        • In general I prefer not to have duplicate bots, but I don't mind leaving it.
          – Mnemonic
          37 mins ago






        • 1




          @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
          – hidefromkgb
          36 mins ago










        • @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
          – Engineer Toast
          23 mins ago











        • No worries. Welcome to the wonderful world of KoTH!
          – Mnemonic
          22 mins ago
















        • In general I prefer not to have duplicate bots, but I don't mind leaving it.
          – Mnemonic
          37 mins ago






        • 1




          @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
          – hidefromkgb
          36 mins ago










        • @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
          – Engineer Toast
          23 mins ago











        • No worries. Welcome to the wonderful world of KoTH!
          – Mnemonic
          22 mins ago















        In general I prefer not to have duplicate bots, but I don't mind leaving it.
        – Mnemonic
        37 mins ago




        In general I prefer not to have duplicate bots, but I don't mind leaving it.
        – Mnemonic
        37 mins ago




        1




        1




        @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
        – hidefromkgb
        36 mins ago




        @Mnemonic well technically it`s not a dupe, as it doesn`t initialize self.index.
        – hidefromkgb
        36 mins ago












        @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
        – Engineer Toast
        23 mins ago





        @Mnemonic No problem! Honestly, this is my first KoTH and my first anything in Python so I just followed the first two posters and didn't change it despite my suspicion that I should have. I also wasn't sure if you were going to include Lowball in your tests or it was really just an example for the post.
        – Engineer Toast
        23 mins ago













        No worries. Welcome to the wonderful world of KoTH!
        – Mnemonic
        22 mins ago




        No worries. Welcome to the wonderful world of KoTH!
        – Mnemonic
        22 mins ago










        up vote
        1
        down vote













        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





        share|improve this answer










        New contributor




        hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





















          up vote
          1
          down vote













          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





          share|improve this answer










          New contributor




          hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.



















            up vote
            1
            down vote










            up vote
            1
            down vote









            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





            share|improve this answer










            New contributor




            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            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






            share|improve this answer










            New contributor




            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer








            edited 21 mins ago





















            New contributor




            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered 50 mins ago









            hidefromkgb

            1514




            1514




            New contributor




            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            hidefromkgb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















                up vote
                1
                down vote













                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.






                share|improve this answer






















                • @Mnemonic fixed!
                  – maxb
                  17 mins ago














                up vote
                1
                down vote













                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.






                share|improve this answer






















                • @Mnemonic fixed!
                  – maxb
                  17 mins ago












                up vote
                1
                down vote










                up vote
                1
                down vote









                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.






                share|improve this 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.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 18 mins ago

























                answered 45 mins ago









                maxb

                1,219519




                1,219519











                • @Mnemonic fixed!
                  – maxb
                  17 mins ago
















                • @Mnemonic fixed!
                  – maxb
                  17 mins ago















                @Mnemonic fixed!
                – maxb
                17 mins ago




                @Mnemonic fixed!
                – maxb
                17 mins ago










                up vote
                0
                down vote













                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):

                self.index = index
                self.pick = 1

                def select(self):

                return self.pick

                def update(self, choices: list):

                choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.

                for choice in choices:

                if choice == self.pick:

                self.pick += 1

                if self.pick == 11:

                self.pick = 1





                share|improve this answer


























                  up vote
                  0
                  down vote













                  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):

                  self.index = index
                  self.pick = 1

                  def select(self):

                  return self.pick

                  def update(self, choices: list):

                  choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.

                  for choice in choices:

                  if choice == self.pick:

                  self.pick += 1

                  if self.pick == 11:

                  self.pick = 1





                  share|improve this answer
























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    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):

                    self.index = index
                    self.pick = 1

                    def select(self):

                    return self.pick

                    def update(self, choices: list):

                    choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.

                    for choice in choices:

                    if choice == self.pick:

                    self.pick += 1

                    if self.pick == 11:

                    self.pick = 1





                    share|improve this 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):

                    self.index = index
                    self.pick = 1

                    def select(self):

                    return self.pick

                    def update(self, choices: list):

                    choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.

                    for choice in choices:

                    if choice == self.pick:

                    self.pick += 1

                    if self.pick == 11:

                    self.pick = 1






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 35 mins ago

























                    answered 43 mins ago









                    Soaku

                    512423




                    512423




















                        up vote
                        0
                        down vote













                        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





                        share|improve this answer










                        New contributor




                        Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          up vote
                          0
                          down vote













                          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





                          share|improve this answer










                          New contributor




                          Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.



















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            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





                            share|improve this answer










                            New contributor




                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            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






                            share|improve this answer










                            New contributor




                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer








                            edited 43 secs ago









                            Rushabh Mehta

                            634120




                            634120






                            New contributor




                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 18 mins ago









                            Justin

                            1011




                            1011




                            New contributor




                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172178%2fsmallest-unique-number-koth%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                What does second last employer means? [closed]

                                Installing NextGIS Connect into QGIS 3?

                                One-line joke