Robot Roulette: High stakes robot gambling

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











up vote
3
down vote

favorite
3












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:



  1. They choose a number smaller than that of their opponent

  2. Their hp drops to or below zero

  3. 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.










share|improve this question









New contributor




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















  • 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














up vote
3
down vote

favorite
3












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:



  1. They choose a number smaller than that of their opponent

  2. Their hp drops to or below zero

  3. 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.










share|improve this question









New contributor




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















  • 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












up vote
3
down vote

favorite
3









up vote
3
down vote

favorite
3






3





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:



  1. They choose a number smaller than that of their opponent

  2. Their hp drops to or below zero

  3. 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.










share|improve this question









New contributor




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











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:



  1. They choose a number smaller than that of their opponent

  2. Their hp drops to or below zero

  3. 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






share|improve this question









New contributor




KBriggs 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 question









New contributor




KBriggs 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 question




share|improve this question








edited 58 mins ago





















New contributor




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









asked 2 hours ago









KBriggs

1193




1193




New contributor




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





New contributor





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






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







  • 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




    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










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





share|improve this answer






















  • 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


















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.






share|improve this answer






















  • 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




    If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
    – Draco18s
    34 mins ago

















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





share|improve this answer








New contributor




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

















  • 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 function ceil appears not to be defined.
    – Jonathan Frech
    10 mins ago










  • I changed to np.ceil() to run it
    – KBriggs
    9 mins ago

















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.






share|improve this answer










New contributor




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

















  • 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










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



);






KBriggs is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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






























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





share|improve this answer






















  • 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















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





share|improve this answer






















  • 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













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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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











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.






share|improve this answer






















  • 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




    If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
    – Draco18s
    34 mins ago














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.






share|improve this answer






















  • 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




    If HP is 0, then I shouldn't be invoked. :P You're right about HP 1 though.
    – Draco18s
    34 mins ago












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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited 34 mins ago

























answered 53 mins ago









Draco18s

1,080518




1,080518











  • 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




    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







  • 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










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





share|improve this answer








New contributor




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

















  • 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 function ceil appears not to be defined.
    – Jonathan Frech
    10 mins ago










  • I changed to np.ceil() to run it
    – KBriggs
    9 mins ago














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





share|improve this answer








New contributor




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

















  • 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 function ceil appears not to be defined.
    – Jonathan Frech
    10 mins ago










  • I changed to np.ceil() to run it
    – KBriggs
    9 mins ago












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





share|improve this answer








New contributor




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









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






share|improve this answer








New contributor




Belhenix 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






New contributor




Belhenix 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









Belhenix

111




111




New contributor




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





New contributor





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






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











  • 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 function ceil 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










  • 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










  • 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










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.






share|improve this answer










New contributor




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

















  • 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














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.






share|improve this answer










New contributor




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

















  • 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












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.






share|improve this answer










New contributor




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









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.







share|improve this answer










New contributor




Yodie 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 8 mins ago





















New contributor




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









answered 26 mins ago









Yodie

112




112




New contributor




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





New contributor





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






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











  • 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










  • 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










KBriggs is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery