Robot Roulette: High stakes robot gambling
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
Everyone starts with 100 hp. Each round, 2 players are chosen at random from the pool of contestants who have not yet competed in that round. Both players pick a number between 0 and their current hp, and reveal those numbers at the same time. The player who chose the lower number immediately dies. The other player subtracts their chosen number from their remaining hp and goes on to the next round.
The tournament works like this:
From the bracket of contestants, 2 are chosen at random. They face off, and one or both of them dies. A player dies if:
- They choose a number smaller than that of their opponent
- Their hp drops to or below zero
- They tie three times in a row with their opponent
In the case of ties, both players simply generate new numbers, up to 3 times. After the faceoff, the survivor (if any) is moved to the pool for the next round, and the process repeats until we have exhausted the current round pool. If there is an odd number in the pool, then the odd one out moves on to the next round for free.
Your task is to write a function in python2.7 which takes as inputs your current hp
, a list of your opponent's guess history
, and an integer ties
which tells you how many times you have already tied with your current opponent, and an integer which tells you how many bots are still alive
(including you). Note that the history does not include ties. The function must return an integer between 0 and your current total hp. A few simple examples, which ignore ties, are shown below:
def last(hp, history, ties, alive):
''' Bet a third of your hp at first, then bet your opponent's last guess, if possible '''
if history:
return np.minimum(hp-1, history[-1])
else:
return hp/3
def average(hp, history, ties, alive):
''' Bet the average opponent's guess so far, on the assumption that guesses will tend downward '''
if history:
num = np.minimum(hp-1, int(np.average(history))+1)
else:
num = hp/2
return num
def random(hp, history, ties, alive):
''' DO YOU WANT TO LIVE FOREVER?! '''
return 1 + np.random.randint(0, hp)
If your function returns a number larger than your hp, it will be reset to 0. Yes, it is possible to kill yourself. Under these rules it is possible that there is no winner, and the last two contestants kill each other. In that case both finalists get half a point each.
Once I get a pool of candidates I will run a few thousand tournaments to get some statistics. The goal of this is to find interesting ways to predict opponents' bets, so I am open to providing more input information for your function if it would make it more interesting to do so. I'm not married to the tournament format, so if someone suggests a more interesting or fair format I'll implement both and we can compare.
This will be a very high-variability puzzle, so I will run at least N=100000 tournaments to gather good statistics before declaring a winner.
This is my first programming puzzle attempt, so critiques are welcome!
EDIT: bots have really interesting interactions depending on their history-dependent behavior. The presence or absence of a particular bot type can dramatically impact the average performance of another bot if the betting pattern of one has big effects on the others. This should be pretty neat to analyze.
king-of-the-hill python
New contributor
add a comment |Â
up vote
3
down vote
favorite
Everyone starts with 100 hp. Each round, 2 players are chosen at random from the pool of contestants who have not yet competed in that round. Both players pick a number between 0 and their current hp, and reveal those numbers at the same time. The player who chose the lower number immediately dies. The other player subtracts their chosen number from their remaining hp and goes on to the next round.
The tournament works like this:
From the bracket of contestants, 2 are chosen at random. They face off, and one or both of them dies. A player dies if:
- They choose a number smaller than that of their opponent
- Their hp drops to or below zero
- They tie three times in a row with their opponent
In the case of ties, both players simply generate new numbers, up to 3 times. After the faceoff, the survivor (if any) is moved to the pool for the next round, and the process repeats until we have exhausted the current round pool. If there is an odd number in the pool, then the odd one out moves on to the next round for free.
Your task is to write a function in python2.7 which takes as inputs your current hp
, a list of your opponent's guess history
, and an integer ties
which tells you how many times you have already tied with your current opponent, and an integer which tells you how many bots are still alive
(including you). Note that the history does not include ties. The function must return an integer between 0 and your current total hp. A few simple examples, which ignore ties, are shown below:
def last(hp, history, ties, alive):
''' Bet a third of your hp at first, then bet your opponent's last guess, if possible '''
if history:
return np.minimum(hp-1, history[-1])
else:
return hp/3
def average(hp, history, ties, alive):
''' Bet the average opponent's guess so far, on the assumption that guesses will tend downward '''
if history:
num = np.minimum(hp-1, int(np.average(history))+1)
else:
num = hp/2
return num
def random(hp, history, ties, alive):
''' DO YOU WANT TO LIVE FOREVER?! '''
return 1 + np.random.randint(0, hp)
If your function returns a number larger than your hp, it will be reset to 0. Yes, it is possible to kill yourself. Under these rules it is possible that there is no winner, and the last two contestants kill each other. In that case both finalists get half a point each.
Once I get a pool of candidates I will run a few thousand tournaments to get some statistics. The goal of this is to find interesting ways to predict opponents' bets, so I am open to providing more input information for your function if it would make it more interesting to do so. I'm not married to the tournament format, so if someone suggests a more interesting or fair format I'll implement both and we can compare.
This will be a very high-variability puzzle, so I will run at least N=100000 tournaments to gather good statistics before declaring a winner.
This is my first programming puzzle attempt, so critiques are welcome!
EDIT: bots have really interesting interactions depending on their history-dependent behavior. The presence or absence of a particular bot type can dramatically impact the average performance of another bot if the betting pattern of one has big effects on the others. This should be pretty neat to analyze.
king-of-the-hill python
New contributor
1
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Everyone starts with 100 hp. Each round, 2 players are chosen at random from the pool of contestants who have not yet competed in that round. Both players pick a number between 0 and their current hp, and reveal those numbers at the same time. The player who chose the lower number immediately dies. The other player subtracts their chosen number from their remaining hp and goes on to the next round.
The tournament works like this:
From the bracket of contestants, 2 are chosen at random. They face off, and one or both of them dies. A player dies if:
- They choose a number smaller than that of their opponent
- Their hp drops to or below zero
- They tie three times in a row with their opponent
In the case of ties, both players simply generate new numbers, up to 3 times. After the faceoff, the survivor (if any) is moved to the pool for the next round, and the process repeats until we have exhausted the current round pool. If there is an odd number in the pool, then the odd one out moves on to the next round for free.
Your task is to write a function in python2.7 which takes as inputs your current hp
, a list of your opponent's guess history
, and an integer ties
which tells you how many times you have already tied with your current opponent, and an integer which tells you how many bots are still alive
(including you). Note that the history does not include ties. The function must return an integer between 0 and your current total hp. A few simple examples, which ignore ties, are shown below:
def last(hp, history, ties, alive):
''' Bet a third of your hp at first, then bet your opponent's last guess, if possible '''
if history:
return np.minimum(hp-1, history[-1])
else:
return hp/3
def average(hp, history, ties, alive):
''' Bet the average opponent's guess so far, on the assumption that guesses will tend downward '''
if history:
num = np.minimum(hp-1, int(np.average(history))+1)
else:
num = hp/2
return num
def random(hp, history, ties, alive):
''' DO YOU WANT TO LIVE FOREVER?! '''
return 1 + np.random.randint(0, hp)
If your function returns a number larger than your hp, it will be reset to 0. Yes, it is possible to kill yourself. Under these rules it is possible that there is no winner, and the last two contestants kill each other. In that case both finalists get half a point each.
Once I get a pool of candidates I will run a few thousand tournaments to get some statistics. The goal of this is to find interesting ways to predict opponents' bets, so I am open to providing more input information for your function if it would make it more interesting to do so. I'm not married to the tournament format, so if someone suggests a more interesting or fair format I'll implement both and we can compare.
This will be a very high-variability puzzle, so I will run at least N=100000 tournaments to gather good statistics before declaring a winner.
This is my first programming puzzle attempt, so critiques are welcome!
EDIT: bots have really interesting interactions depending on their history-dependent behavior. The presence or absence of a particular bot type can dramatically impact the average performance of another bot if the betting pattern of one has big effects on the others. This should be pretty neat to analyze.
king-of-the-hill python
New contributor
Everyone starts with 100 hp. Each round, 2 players are chosen at random from the pool of contestants who have not yet competed in that round. Both players pick a number between 0 and their current hp, and reveal those numbers at the same time. The player who chose the lower number immediately dies. The other player subtracts their chosen number from their remaining hp and goes on to the next round.
The tournament works like this:
From the bracket of contestants, 2 are chosen at random. They face off, and one or both of them dies. A player dies if:
- They choose a number smaller than that of their opponent
- Their hp drops to or below zero
- They tie three times in a row with their opponent
In the case of ties, both players simply generate new numbers, up to 3 times. After the faceoff, the survivor (if any) is moved to the pool for the next round, and the process repeats until we have exhausted the current round pool. If there is an odd number in the pool, then the odd one out moves on to the next round for free.
Your task is to write a function in python2.7 which takes as inputs your current hp
, a list of your opponent's guess history
, and an integer ties
which tells you how many times you have already tied with your current opponent, and an integer which tells you how many bots are still alive
(including you). Note that the history does not include ties. The function must return an integer between 0 and your current total hp. A few simple examples, which ignore ties, are shown below:
def last(hp, history, ties, alive):
''' Bet a third of your hp at first, then bet your opponent's last guess, if possible '''
if history:
return np.minimum(hp-1, history[-1])
else:
return hp/3
def average(hp, history, ties, alive):
''' Bet the average opponent's guess so far, on the assumption that guesses will tend downward '''
if history:
num = np.minimum(hp-1, int(np.average(history))+1)
else:
num = hp/2
return num
def random(hp, history, ties, alive):
''' DO YOU WANT TO LIVE FOREVER?! '''
return 1 + np.random.randint(0, hp)
If your function returns a number larger than your hp, it will be reset to 0. Yes, it is possible to kill yourself. Under these rules it is possible that there is no winner, and the last two contestants kill each other. In that case both finalists get half a point each.
Once I get a pool of candidates I will run a few thousand tournaments to get some statistics. The goal of this is to find interesting ways to predict opponents' bets, so I am open to providing more input information for your function if it would make it more interesting to do so. I'm not married to the tournament format, so if someone suggests a more interesting or fair format I'll implement both and we can compare.
This will be a very high-variability puzzle, so I will run at least N=100000 tournaments to gather good statistics before declaring a winner.
This is my first programming puzzle attempt, so critiques are welcome!
EDIT: bots have really interesting interactions depending on their history-dependent behavior. The presence or absence of a particular bot type can dramatically impact the average performance of another bot if the betting pattern of one has big effects on the others. This should be pretty neat to analyze.
king-of-the-hill python
king-of-the-hill python
New contributor
New contributor
edited 58 mins ago
New contributor
asked 2 hours ago
KBriggs
1193
1193
New contributor
New contributor
1
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago
add a comment |Â
1
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago
1
1
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
1
down vote
Kamikaze
Why bother with complicated logic when we are all going to die anyway...
def kamikaze(hp, history, ties, alive):
return hp
One shot
It's going to survive at least a single round if it doesn't encounter the kamikaze.
def one_shot(hp, history, ties, alive):
if hp == 1:
return 1
else:
return hp - 1
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
add a comment |Â
up vote
1
down vote
def outbid(hp, history, ties, alive):
if history:
return np.minimum(hp-1,99-sum(history))
if hp == 1:
return 1
return np.random.randint(hp/5, hp/2)
Bot will attempt to bid higher than its opponent can bid. Won't win against a kamikazi, but against future bots, it might work out.
There is a conditionwhere np.random.randint(hp/5, hp/2)
can fail ifhp/5 == hp/2
, ie ifhp==0
orhp==1
â KBriggs
36 mins ago
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
add a comment |Â
up vote
1
down vote
1/2 Punch Man
I think it will die pretty quickly. Worth it.
def kamikaze(hp, history, ties, alive):
if hp > 1:
return ceil(hp/2)
else:
return 1
New contributor
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your functionceil
appears not to be defined.
â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
add a comment |Â
up vote
1
down vote
The pathetic attempt at a bot that analyzes the history of its opponent
def pathetic_attempt_at_analytics_bot(hp, history, ties, alive):
'''Not a good bot'''
if history:
opp_hp = 100 - sum(history)
if alive == 2:
if hp > opp_hp:
return hp - 1
return hp
if hp > opp_hp + 1:
if opp_hp <= 15:
return opp_hp +1
if ties > 0:
return hp #Just give up, kamikaze mode
return opp_hp + 1
return opp_hp
else:
n = 100 // (alive - 1) + 1 #greater than
if n >= hp:
n = hp - 1
return n
If there is previous history of its opponent, then it calculates its opponent's hp. Then, it does one of the following:
- If its opponent is the last opponent alive, then it will bid one less than its hp.
- If its opponent is not the last opponent alive but the opponent has less than 16 hp, then it will outbid its opponent's hp.
- If its opponent is not the last opponent alive and there is a history of ties, then it will bid its hp because it is bored of ties.
- Otherwise, it will outbid its opponent.
If there is no history, then it does some fancy calculations that I hacked together and bids that. If the value exceeds 100, then it automatically bids its hp minus 1.
I hacked this code together during work and this is my first submission, so it probably won't win or anything, and it'll lose to the kamikaze.
New contributor
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.
â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Kamikaze
Why bother with complicated logic when we are all going to die anyway...
def kamikaze(hp, history, ties, alive):
return hp
One shot
It's going to survive at least a single round if it doesn't encounter the kamikaze.
def one_shot(hp, history, ties, alive):
if hp == 1:
return 1
else:
return hp - 1
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
add a comment |Â
up vote
1
down vote
Kamikaze
Why bother with complicated logic when we are all going to die anyway...
def kamikaze(hp, history, ties, alive):
return hp
One shot
It's going to survive at least a single round if it doesn't encounter the kamikaze.
def one_shot(hp, history, ties, alive):
if hp == 1:
return 1
else:
return hp - 1
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Kamikaze
Why bother with complicated logic when we are all going to die anyway...
def kamikaze(hp, history, ties, alive):
return hp
One shot
It's going to survive at least a single round if it doesn't encounter the kamikaze.
def one_shot(hp, history, ties, alive):
if hp == 1:
return 1
else:
return hp - 1
Kamikaze
Why bother with complicated logic when we are all going to die anyway...
def kamikaze(hp, history, ties, alive):
return hp
One shot
It's going to survive at least a single round if it doesn't encounter the kamikaze.
def one_shot(hp, history, ties, alive):
if hp == 1:
return 1
else:
return hp - 1
edited 1 hour ago
answered 1 hour ago
DobromirM
1715
1715
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
add a comment |Â
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
Welp, that was inevitable
â KBriggs
1 hour ago
Welp, that was inevitable
â KBriggs
1 hour ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
I was going to add a pacifist bot as well but I don't want to flood your challenge with brain dead bots
â DobromirM
56 mins ago
1
1
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
Based on some quick testing, the kamikaze bot deosn't change much - all it does is remove another bot from the round at random, which, over a large enough number of tournaments, simply averages to zero. The One hot is neat, though. Without it, my AverageBot tends to do the best - but if there are a few OneShots in play, is skews the average toward large numbers and tends to make the AverageBots die off quickly. Same for LastBot. You can really mess with the behavior of other robots by skewing your own betting patterns. With OneShot in play, RandomBot wins . Without it, AverageBot wins.
â KBriggs
56 mins ago
add a comment |Â
up vote
1
down vote
def outbid(hp, history, ties, alive):
if history:
return np.minimum(hp-1,99-sum(history))
if hp == 1:
return 1
return np.random.randint(hp/5, hp/2)
Bot will attempt to bid higher than its opponent can bid. Won't win against a kamikazi, but against future bots, it might work out.
There is a conditionwhere np.random.randint(hp/5, hp/2)
can fail ifhp/5 == hp/2
, ie ifhp==0
orhp==1
â KBriggs
36 mins ago
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
add a comment |Â
up vote
1
down vote
def outbid(hp, history, ties, alive):
if history:
return np.minimum(hp-1,99-sum(history))
if hp == 1:
return 1
return np.random.randint(hp/5, hp/2)
Bot will attempt to bid higher than its opponent can bid. Won't win against a kamikazi, but against future bots, it might work out.
There is a conditionwhere np.random.randint(hp/5, hp/2)
can fail ifhp/5 == hp/2
, ie ifhp==0
orhp==1
â KBriggs
36 mins ago
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
def outbid(hp, history, ties, alive):
if history:
return np.minimum(hp-1,99-sum(history))
if hp == 1:
return 1
return np.random.randint(hp/5, hp/2)
Bot will attempt to bid higher than its opponent can bid. Won't win against a kamikazi, but against future bots, it might work out.
def outbid(hp, history, ties, alive):
if history:
return np.minimum(hp-1,99-sum(history))
if hp == 1:
return 1
return np.random.randint(hp/5, hp/2)
Bot will attempt to bid higher than its opponent can bid. Won't win against a kamikazi, but against future bots, it might work out.
edited 34 mins ago
answered 53 mins ago
Draco18s
1,080518
1,080518
There is a conditionwhere np.random.randint(hp/5, hp/2)
can fail ifhp/5 == hp/2
, ie ifhp==0
orhp==1
â KBriggs
36 mins ago
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
add a comment |Â
There is a conditionwhere np.random.randint(hp/5, hp/2)
can fail ifhp/5 == hp/2
, ie ifhp==0
orhp==1
â KBriggs
36 mins ago
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
There is a condition
where np.random.randint(hp/5, hp/2)
can fail if hp/5 == hp/2
, ie if hp==0
or hp==1
â KBriggs
36 mins ago
There is a condition
where np.random.randint(hp/5, hp/2)
can fail if hp/5 == hp/2
, ie if hp==0
or hp==1
â KBriggs
36 mins ago
1
1
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
â Draco18s
34 mins ago
add a comment |Â
up vote
1
down vote
1/2 Punch Man
I think it will die pretty quickly. Worth it.
def kamikaze(hp, history, ties, alive):
if hp > 1:
return ceil(hp/2)
else:
return 1
New contributor
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your functionceil
appears not to be defined.
â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
add a comment |Â
up vote
1
down vote
1/2 Punch Man
I think it will die pretty quickly. Worth it.
def kamikaze(hp, history, ties, alive):
if hp > 1:
return ceil(hp/2)
else:
return 1
New contributor
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your functionceil
appears not to be defined.
â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
1/2 Punch Man
I think it will die pretty quickly. Worth it.
def kamikaze(hp, history, ties, alive):
if hp > 1:
return ceil(hp/2)
else:
return 1
New contributor
1/2 Punch Man
I think it will die pretty quickly. Worth it.
def kamikaze(hp, history, ties, alive):
if hp > 1:
return ceil(hp/2)
else:
return 1
New contributor
New contributor
answered 18 mins ago
Belhenix
111
111
New contributor
New contributor
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your functionceil
appears not to be defined.
â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
add a comment |Â
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your functionceil
appears not to be defined.
â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
You'll have to rename him, there is already a kamikaze bot ^_^
â KBriggs
14 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
So far this one is the winner, though
â KBriggs
12 mins ago
Your function
ceil
appears not to be defined.â Jonathan Frech
10 mins ago
Your function
ceil
appears not to be defined.â Jonathan Frech
10 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
I changed to np.ceil() to run it
â KBriggs
9 mins ago
add a comment |Â
up vote
1
down vote
The pathetic attempt at a bot that analyzes the history of its opponent
def pathetic_attempt_at_analytics_bot(hp, history, ties, alive):
'''Not a good bot'''
if history:
opp_hp = 100 - sum(history)
if alive == 2:
if hp > opp_hp:
return hp - 1
return hp
if hp > opp_hp + 1:
if opp_hp <= 15:
return opp_hp +1
if ties > 0:
return hp #Just give up, kamikaze mode
return opp_hp + 1
return opp_hp
else:
n = 100 // (alive - 1) + 1 #greater than
if n >= hp:
n = hp - 1
return n
If there is previous history of its opponent, then it calculates its opponent's hp. Then, it does one of the following:
- If its opponent is the last opponent alive, then it will bid one less than its hp.
- If its opponent is not the last opponent alive but the opponent has less than 16 hp, then it will outbid its opponent's hp.
- If its opponent is not the last opponent alive and there is a history of ties, then it will bid its hp because it is bored of ties.
- Otherwise, it will outbid its opponent.
If there is no history, then it does some fancy calculations that I hacked together and bids that. If the value exceeds 100, then it automatically bids its hp minus 1.
I hacked this code together during work and this is my first submission, so it probably won't win or anything, and it'll lose to the kamikaze.
New contributor
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.
â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
add a comment |Â
up vote
1
down vote
The pathetic attempt at a bot that analyzes the history of its opponent
def pathetic_attempt_at_analytics_bot(hp, history, ties, alive):
'''Not a good bot'''
if history:
opp_hp = 100 - sum(history)
if alive == 2:
if hp > opp_hp:
return hp - 1
return hp
if hp > opp_hp + 1:
if opp_hp <= 15:
return opp_hp +1
if ties > 0:
return hp #Just give up, kamikaze mode
return opp_hp + 1
return opp_hp
else:
n = 100 // (alive - 1) + 1 #greater than
if n >= hp:
n = hp - 1
return n
If there is previous history of its opponent, then it calculates its opponent's hp. Then, it does one of the following:
- If its opponent is the last opponent alive, then it will bid one less than its hp.
- If its opponent is not the last opponent alive but the opponent has less than 16 hp, then it will outbid its opponent's hp.
- If its opponent is not the last opponent alive and there is a history of ties, then it will bid its hp because it is bored of ties.
- Otherwise, it will outbid its opponent.
If there is no history, then it does some fancy calculations that I hacked together and bids that. If the value exceeds 100, then it automatically bids its hp minus 1.
I hacked this code together during work and this is my first submission, so it probably won't win or anything, and it'll lose to the kamikaze.
New contributor
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.
â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The pathetic attempt at a bot that analyzes the history of its opponent
def pathetic_attempt_at_analytics_bot(hp, history, ties, alive):
'''Not a good bot'''
if history:
opp_hp = 100 - sum(history)
if alive == 2:
if hp > opp_hp:
return hp - 1
return hp
if hp > opp_hp + 1:
if opp_hp <= 15:
return opp_hp +1
if ties > 0:
return hp #Just give up, kamikaze mode
return opp_hp + 1
return opp_hp
else:
n = 100 // (alive - 1) + 1 #greater than
if n >= hp:
n = hp - 1
return n
If there is previous history of its opponent, then it calculates its opponent's hp. Then, it does one of the following:
- If its opponent is the last opponent alive, then it will bid one less than its hp.
- If its opponent is not the last opponent alive but the opponent has less than 16 hp, then it will outbid its opponent's hp.
- If its opponent is not the last opponent alive and there is a history of ties, then it will bid its hp because it is bored of ties.
- Otherwise, it will outbid its opponent.
If there is no history, then it does some fancy calculations that I hacked together and bids that. If the value exceeds 100, then it automatically bids its hp minus 1.
I hacked this code together during work and this is my first submission, so it probably won't win or anything, and it'll lose to the kamikaze.
New contributor
The pathetic attempt at a bot that analyzes the history of its opponent
def pathetic_attempt_at_analytics_bot(hp, history, ties, alive):
'''Not a good bot'''
if history:
opp_hp = 100 - sum(history)
if alive == 2:
if hp > opp_hp:
return hp - 1
return hp
if hp > opp_hp + 1:
if opp_hp <= 15:
return opp_hp +1
if ties > 0:
return hp #Just give up, kamikaze mode
return opp_hp + 1
return opp_hp
else:
n = 100 // (alive - 1) + 1 #greater than
if n >= hp:
n = hp - 1
return n
If there is previous history of its opponent, then it calculates its opponent's hp. Then, it does one of the following:
- If its opponent is the last opponent alive, then it will bid one less than its hp.
- If its opponent is not the last opponent alive but the opponent has less than 16 hp, then it will outbid its opponent's hp.
- If its opponent is not the last opponent alive and there is a history of ties, then it will bid its hp because it is bored of ties.
- Otherwise, it will outbid its opponent.
If there is no history, then it does some fancy calculations that I hacked together and bids that. If the value exceeds 100, then it automatically bids its hp minus 1.
I hacked this code together during work and this is my first submission, so it probably won't win or anything, and it'll lose to the kamikaze.
New contributor
edited 8 mins ago
New contributor
answered 26 mins ago
Yodie
112
112
New contributor
New contributor
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.
â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
add a comment |Â
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.
â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
Very nice, thanks for the bot! I'll give some stats when I get a few more.
â KBriggs
20 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
I'm a novice at python so I'm not sure if the syntax is correct, feel free to let me know if that happens
â Yodie
17 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
It runs, so no worries there
â KBriggs
15 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);
opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.â Jonathan Frech
11 mins ago
@Yodie As a mini code review: Your function body should be indented by a level (syntactic necessity);
opp_hp +1
is missing a space to be pythonic; your comments start with unbalanced amounts of whitespace. Finally, your function is lacking a docstring.â Jonathan Frech
11 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
@JonathanFrech sorry I copied from a text document so there might've been some copy-and-paste errors. I'll fix them quickly.
â Yodie
9 mins ago
add a comment |Â
KBriggs is a new contributor. Be nice, and check out our Code of Conduct.
KBriggs is a new contributor. Be nice, and check out our Code of Conduct.
KBriggs is a new contributor. Be nice, and check out our Code of Conduct.
KBriggs is a new contributor. Be nice, and check out our Code of Conduct.
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%2f173209%2frobot-roulette-high-stakes-robot-gambling%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
1
Should there also be a parameter for how many opponents are left in the tournament? Having a rough idea of how many rounds the bot has left could be useful information.
â mypetlion
1 hour ago
Good point, I will add that to the contest definition
â KBriggs
1 hour ago
Can we submit more than one bot?
â DobromirM
1 hour ago
Absolutely, the more the merrier
â KBriggs
1 hour ago