Smallest unique number KoTH
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
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
 |Â
show 6 more comments
up vote
5
down vote
favorite
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
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
 |Â
show 6 more comments
up vote
5
down vote
favorite
up vote
5
down vote
favorite
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
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
king-of-the-hill
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
 |Â
show 6 more comments
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
 |Â
show 6 more comments
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.
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 initializeself.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
add a comment |Â
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
New contributor
add a comment |Â
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.
@Mnemonic fixed!
â maxb
17 mins ago
add a comment |Â
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
add a comment |Â
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
New contributor
add a comment |Â
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.
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 initializeself.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
add a comment |Â
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.
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 initializeself.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
add a comment |Â
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.
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.
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 initializeself.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
add a comment |Â
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 initializeself.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
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
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
New contributor
edited 21 mins ago
New contributor
answered 50 mins ago
hidefromkgb
1514
1514
New contributor
New contributor
add a comment |Â
add a comment |Â
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.
@Mnemonic fixed!
â maxb
17 mins ago
add a comment |Â
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.
@Mnemonic fixed!
â maxb
17 mins ago
add a comment |Â
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.
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.
edited 18 mins ago
answered 45 mins ago
maxb
1,219519
1,219519
@Mnemonic fixed!
â maxb
17 mins ago
add a comment |Â
@Mnemonic fixed!
â maxb
17 mins ago
@Mnemonic fixed!
â maxb
17 mins ago
@Mnemonic fixed!
â maxb
17 mins ago
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited 35 mins ago
answered 43 mins ago
Soaku
512423
512423
add a comment |Â
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
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
New contributor
edited 43 secs ago
Rushabh Mehta
634120
634120
New contributor
answered 18 mins ago
Justin
1011
1011
New contributor
New contributor
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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