机器人轮盘:高赌注的机器人赌博


56

最终排名

+ ---------------------------------- + --------- + ---- ----- + --------- + ---------------------------- +
| 姓名| 分数| WinRate | TieRate | 消除概率|
+ ---------------------------------- + --------- + ---- ----- + --------- + ---------------------------- +
| 1. SarcomaBotMk11 | 0.06333 | 6.13%| 0.41%| [42 24 10 8 6 4]%|
| 2. WiseKickBot | 0.06189 | 5.91%| 0.56%| [51 12 7 10 7 6]%|
| 3. StrikerBot | 0.05984 | 5.78%| 0.41%| [46 18 11 8 6 5]%|
| 4. PerfectFractionBot | 0.05336 | 5.16%| 0.35%| [49 12 14 10 6 4]%|
| 5. MehRanBot | 0.05012 | 4.81%| 0.41%| [57 12 8 7 6 5]%|
| 6. OgBot | 0.04879 | 4.66%| 0.45%| [50 15 9 8 7 5]%|
| 7. SnetchBot | 0.04616 | 4.48%| 0.28%| [41 29 8 9 5 3]%|
| 8. AntiKickBot | 0.04458 | 4.24%| 0.44%| [20 38 17 10 6 4]%|
| 9. MehBot | 0.03636 | 3.51%| 0.25%| [80 3 4 4 3 3]%|
| 10. Meh20Bot | 0.03421 | 3.30%| 0.23%| [57 12 8 7 9 3]%|
| 11. GenericBot | 0.03136 | 3.00%| 0.28%| [18 39 20 11 5 3]%|
| 12. HardCodedBot | 0.02891 | 2.75%| 0.29%| [58 21 3 6 5 4]%|
| 13. GangBot1 | 0.02797 | 2.64%| 0.32%| [20 31 35 6 3 2]%|
| 14.肉瘤BotMk3 | 0.02794 | 2.62%| 0.34%| [16 15 38 17 7 4]%|
| 15. GangBot0 | 0.02794 | 2.64%| 0.30%| [20 31 35 6 3 2]%|
| 16. GangBot2 | 0.02770 | 2.62%| 0.31%| [20 31 35 6 3 2]%|
| 17. TitTatBot | 0.02740 | 2.63%| 0.21%| [54 10 15 10 5 2]%|
| 18. MataHari2Bot | 0.02611 | 2.35%| 0.51%| [39 26 11 11 6 5]%|
| 19. PolyBot | 0.02545 | 2.41%| 0.27%| [53 18 6 13 5 3]%|
| 20. SpitballBot | 0.02502 | 2.39%| 0.22%| [84 10 1 1 0 1]%|
| 21. SquareUpBot | 0.02397 | 2.35%| 0.10%| [10 60 14 7 4 3]%|
| 22. CautiousGamblerBot2 | 0.02250 | 2.19%| 0.13%| [60 18 10 5 3 1]%|
| 23. Bot13 | 0.02205 | 2.15%| 0.11%| [90 0 2 3 2 1]%|
| 24. AggroCalcBot | 0.01892 | 1.75%| 0.29%| [26 49 13 5 3 3]%|
| 25.小心| 0.01629 | 1.56%| 0.14%| [15 41 27 11 4 1]%|
| 26. CoastBotV2 | 0.01413 | 1.40%| 0.02%| [83 12 3 1 0 0]%|
| 27. CalculatingBot | 0.01404 | 1.29%| 0.22%| [87 9 1 1 1 1]%|
| 28. HalfPunchBot | 0.01241 | 1.15%| 0.18%| [47 20 13 12 5 2]%|
| 29. HalflifeS3Bot | 0.01097 | 1.00%| 0.20%| [76 9 5 4 2 2]%|
| 30. AntiGangBot | 0.00816 | 0.76%| 0.11%| [94 1 1 1 1 1]%|
| 31. GeometricBot | 0.00776 | 0.74%| 0.07%| [19 46 25 7 2 1]%|
| 32. GuessBot | 0.00719 | 0.05%| 1.34%| [65 17 4 6 5 3]%|
| 33. BoundedRandomBot | 0.00622 | 0.60%| 0.05%| [42 39 12 5 2 0]%|
| 34. SpreaderBot | 0.00549 | 0.54%| 0.02%| [32 43 19 4 1 0]%|
| 35. DeterminBot | 0.00529 | 0.45%| 0.16%| [22 41 20 11 4 2]%|
| 36. PercentBot | 0.00377 | 0.38%| 0.00%| [85 8 4 2 1 0]%|
| 37. HalvsiestBot | 0.00337 | 0.29%| 0.08%| [32 43 15 6 2 1]%|
| 38. GetAlongBot | 0.00330 | 0.33%| 0.01%| [76 18 4 1 0 0]%|
| 39. BandaidBot | 0.00297 | 0.29%| 0.02%| [76 9 10 4 1 0]%|
| 40. TENaciousBot | 0.00287 | 0.29%| 0.00%| [94 4 1 0 0 0]%|
| 41. SurvivalistBot | 0.00275 | 0.25%| 0.04%| [92 6 1 0 0 0]%|
| 42. RandomBot | 0.00170 | 0.13%| 0.07%| [42 36 14 5 2 1]%|
| 43. AggressiveBoundedRandomBotV2 | 0.00165 | 0.14%| 0.06%| [8 46 34 9 2 1]%|
| 44. BloodBot | 0.00155 | 0.01%| 0.30%| [65 28 5 1 1 0]%|
| 45. OutBidBot | 0.00155 | 0.03%| 0.25%| [65 6 21 6 1 1]%|
| 46. BoxBot | 0.00148 | 0.10%| 0.09%| [10 51 33 5 1 1]%|
| 47. LastBot | 0.00116 | 0.08%| 0.07%| [74 6 16 2 1 0]%|
| 48. UpYoursBot | 0.00088 | 0.07%| 0.03%| [37 40 17 5 1 0]%|
| 49. AverageBot | 0.00073 | 0.06%| 0.03%| [74 3 10 10 2 0]%|
| 50. PatheticBot | 0.00016 | 0.01%| 0.02%| [94 0 5 1 0 0]%|
| 51. OverfittedBot | 0.00014 | 0.01%| 0.00%| [58 40 2 0 0 0]%|
| 52. RobbieBot | 0.00009 | 0.01%| 0.00%| [32 41 24 2 0 0]%|
| 53. WorstCaseBot | 0.00002 | 0.00%| 0.00%| [4 71 23 2 0 0]%|
| 54. SmartBot | 0.00002 | 0.00%| 0.00%| [44 51 5 0 0 0]%|
| 55. AAAAUpYoursBot | 0.00000 | 0.00%| 0.00%| [40 58 2 0 0 0]%|
| 56. KickbanBot | 0.00000 | 0.00%| 0.00%| [67 32 1 0 0 0]%|
| 57. OneShotBot | 0.00000 | 0.00%| 0.00%| [2 95 3 0 0 0]%|
| 58. KickBot | 0.00000 | 0.00%| 0.00%| [100 0 0 0 0 0]%|
| 59. KamikazeBot | 0.00000 | 0.00%| 0.00%| [100 0 0 0 0 0]%|
| 60. MeanKickBot | 0.00000 | 0.00%| 0.00%| [100 0 0 0 0 0]%|
+ ---------------------------------- + --------- + ---- ----- + --------- + ---------------------------- +

感谢所有参加的人,并祝贺@Sarcoma获胜!

规则:

每个人都从100马力开始。每个回合中,从尚未参加该回合比赛的参赛者中随机选择2名球员。两位玩家都选择一个介于0和当前马力之间的数字,并同时显示这些数字。选择较低数字的玩家将立即死亡。另一名玩家从剩余的hp中减去他们选择的数字,然后继续下一轮。

比赛的工作方式如下:

从参赛者的括号中随机选择2个。他们对峙,一个或两个都死了。如果玩家死亡,则:

  1. 他们选择的数字小于对手的数字
  2. 他们的马力降至或低于零
  3. 他们与对手连续三连胜

在平局的情况下,两个玩家都只产生新的数字,最多3次。对抗之后,幸存者(如果有的话)被移至下一轮的池中,并且该过程重复进行,直到我们耗尽了当前的池。如果池中有一个奇数,则奇数一个免费进入下一轮。

您的任务是在python2.7中编写一个函数,该函数将您当前hp的价格history,对手出价的列表以及一个整数(ties该整数告诉您已经与当前对手绑定多少次)作为输入,而一个整数则告诉您如何还有很多机器人alive(包括您在内),还有一个整数,列出start了比赛中机器人的数量。请注意,历史记录不包括联系。该函数必须返回0到当前总hp之间的整数。下面显示了一些忽略联系的简单示例:

def last(hp, history, ties, alive, start):
    ''' Bet a third of your hp at first, then bet your opponent's last bid, if possible '''
    if history:
        return np.minimum(hp-1, history[-1])
    else:
        return hp/3

def average(hp, history, ties, alive, start):
    ''' Bet the average opponent's bid so far, on the assumption that bids 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, start):
    ''' DO YOU WANT TO LIVE FOREVER?! '''
    return 1 + np.random.randint(0, hp)

如果您的函数返回的数字大于hp,它将被重置为0。是的,有可能自杀。您的函数不得尝试访问或修改RouletteBot类的任何对象的任何成员。无论将来是否有其他机器人,您都不得采取任何能够明确识别对手的动作。只要在理论上有可能有多个不同的对手可以从中收集到您所收集的信息,就可以检查堆栈,即使当前仅存在一个可以进行自动检测的机器人也可以。即,您不能只读取堆栈以查看调用了哪个敌方函数。

在这些规则下,可能没有获胜者,而最后两名参赛者会互相残杀。在这种情况下,两名决赛入围者各得半分。

这是我第一次编程难题,欢迎提出批评!

控制器可以在这里找到。


4
FWIW,我计划使用一个在所有其他机器人上训练过的神经网络,当您设置控制器后,这很有趣:)
Quintec '18

2
类型检查是为了antiantiantiantiantiupyoursbot的好处。我会找到另一种方式
KBriggs

3
@Sarcoma似乎这场竞赛引发了一场严重的代码战争。这场比赛还没有结束,但是我已经期待着它的发展。也许甚至是下一步,人工智能也会增强竞争性:P
Markov Chained

3
哇!
肉瘤

5
哦,我的上帝。故意将mean_kick更改为在很多地方使用时始终返回零的做法非常出色。
马瓜

Answers:


12

BinaryBot

有人做过吗?每一轮都将一半的健康押注。

def binaryBot(hp, history, ties, alive, start):
    return int(np.floor(hp/2)) or 1

肉瘤

如果最后一个战斗出价为hp-1.如果是第一次战斗,则出价为一半hp,外加最多四分之一的hp。如果在该出价后对手hp + 1可以击败一个对手的直接出价。如果它的生命值低于对手出价随机值的75%与当前hp-1之间。

def sarcomaBot(hp, history, ties, alive, start):
    if inspect.stack()[1][3] != 'guess' and inspect.stack()[1] == 5:
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.25) if hp * 0.25 > 2 else 2
        additionalBid = np.random.randint(1, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.75)
    maximum = hp - 1 or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk2

进行细微调整以减少生活支出。

def sarcomaBotMkTwo(hp, history, ties, alive, start):
    if inspect.stack()[1][3] != 'guess' and inspect.stack()[1] == 5:
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.125) if hp * 0.125 > 2 else 2
        additionalBid = np.random.randint(1, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.6)
    maximum = hp - 1 or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk3

def sarcomaBotMkThree(hp, history, ties, alive, start):
    if inspect.stack()[1][3] != 'guess' and inspect.stack()[1] == 5:
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.08) if hp * 0.08 > 2 else 2
        additionalBid = np.random.randint(1, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.6)
    maximum = hp - 1 or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

更新微调

肉瘤BotMk4

def sarcomaBotMkFour(hp, history, ties, alive, start):
    def isSafe(parentCall):
        frame, filename, line_number, function_name, lines, index = parentCall
        if function_name is not 'guess':
            return False
        if line_number > 60:
            return False
        return True

    if not isSafe(inspect.stack()[1]):
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.08) if hp * 0.08 > 2 else 2
        additionalBid = np.random.randint(1, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.55)
    maximum = np.round(hp * 0.80) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk5

def sarcomaBotMkFive(hp, history, ties, alive, start):
    def isSafe(parentCall):
        frame, filename, line_number, function_name, lines, index = parentCall
        if function_name is not 'guess':
            return False
        if line_number > 60:
            return False
        return True

    if not isSafe(inspect.stack()[1]):
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.07) if hp * 0.07 > 3 else 3
        additionalBid = np.random.randint(1, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.54)
    maximum = np.round(hp * 0.68) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk6

def sarcomaBotMkSix(hp, history, ties, alive, start):
    return hp; # hack averted
    def isSafe(parentCall):
        frame, filename, line_number, function_name, lines, index = parentCall
        if function_name is not 'guess':
            return False
        if line_number > 60:
            return False
        return True

    if not isSafe(inspect.stack()[1]):
        return hp
    if alive == 2:
        return hp - 1
    if not history:
        startBid = hp / 2
        maxAdditionalBid = np.round(hp * 0.06) if hp * 0.06 > 3 else 3
        additionalBid = np.random.randint(2, maxAdditionalBid)
        return int(startBid + additionalBid + ties)
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp:
        return opponentHealth + ties
    minimum = np.round(hp * 0.55)
    maximum = np.round(hp * 0.70) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk7

def sarcomaBotMkSeven(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if not history:
        return 30 + ties
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp * 0.50:
        return opponentHealth + ties
    minimum = np.round(hp * 0.54)
    maximum = np.round(hp * 0.58) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk8

def sarcomaBotMkEight(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if not history:
        return 30 + np.random.randint(0, 2) + ties
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp * 0.50:
        return opponentHealth + ties
    minimum = np.round(hp * 0.54)
    maximum = np.round(hp * 0.58) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk9

def sarcomaBotMkNine(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if not history:
        return 30 + np.random.randint(0, 4) + ties
    opponentHealth = 100 - sum(history)
    if opponentHealth < hp * 0.50:
        return opponentHealth + ties
    minimum = np.round(hp * 0.54)
    maximum = np.round(hp * 0.58) or 1
    return np.random.randint(minimum, maximum) if minimum < maximum else 1

肉瘤BotMk10

def sarcoma_bot_mk_ten(hp, history, ties, alive, start):
    def bid_between(low, high, hp, tie_breaker):
        minimum = np.round(hp * low)
        maximum = np.round(hp * high) or 1
        return np.random.randint(minimum, maximum) + tie_breaker if minimum < maximum else 1

    if alive == 2:
        return hp - 1 + ties
    current_round = len(history) + 1
    tie_breaker = (ties * ties) + 1 if ties else ties
    if current_round == 1:
        return 39 + tie_breaker
    opponent_hp = 100 - sum(history)
    if opponent_hp < hp * 0.50:
        return opponent_hp + ties
    if current_round == 2:
        return bid_between(0.45, 0.50, hp, tie_breaker)
    if current_round == 3:
        return bid_between(0.50, 0.55, hp, tie_breaker)
    if current_round == 4:
        return bid_between(0.55, 0.60, hp, tie_breaker)
    if current_round == 5:
        bid_between(0.60, 0.65, hp, tie_breaker)
    return hp - 1 + ties

最终入场

肉瘤BotMk11

def sarcoma_bot_mk_eleven(hp, history, ties, alive, start):
    def bid_between(low, high, hp, tie_breaker):
        minimum = np.round(hp * low)
        maximum = np.round(hp * high) or 1
        return np.random.randint(minimum, maximum) + tie_breaker if minimum < maximum else 1

    if alive == 2:
        return hp - 1 + ties
    current_round = len(history) + 1
    tie_breaker = ties + 2 if ties else ties
    if current_round == 1:
        return 42 + tie_breaker
    opponent_hp = 100 - sum(history)
    if opponent_hp < hp * 0.50:
        return opponent_hp + ties
    if current_round == 2:
        return bid_between(0.45, 0.50, hp, tie_breaker)
    if current_round == 3:
        return bid_between(0.50, 0.55, hp, tie_breaker)
    if current_round == 4:
        return bid_between(0.55, 0.60, hp, tie_breaker)
    if current_round == 5:
        return bid_between(0.60, 0.65, hp, tie_breaker)
    return hp - 1 + ties

更新
UpYoursBot保护已添加

更新
添加的AntiAntiUpYoursBot保护

更新
AntiAnitAntiAntiUpYoursBot我被击败了


评论不作进一步讨论;此对话已转移至聊天
Mego

17

UpYours

迟到了,我花了一段时间欣赏现有的机器人,花了一段时间使你们的想法复杂化,然后再简化它们。然后就来找我

优秀的艺术家复制,伟大的艺术家偷窃。- 毕加索


之所以要“加油”,是因为我毫不掩饰地偷了(有时在您的机器人的竞标中加价一两点,使它们达到最高价)。

def UpYoursBot(hp, history, ties, alive, start):
    willToLive = "I" in "VICTORY"

    args = [hp, history, ties, alive, start]
    enemyHealth = 100 - sum(history)
    roundNumber = len(history)

    if roundNumber is 0:
        # Steal HalfPunchBot
        return halfpunch(*args) + 2

    if alive == 2:
        # Nick OneShotBot
        return one_shot(*args)

    if enemyHealth >= hp:
        # Pinch SarcomaBotMkTwo
        return sarcomaBotMkTwo(*args) + 1

    if enemyHealth < hp:
        # Rip off KickBot
        return kick(*args) + 1

    if not willToLive:
        # Peculate KamikazeBot
        return kamikaze(*args) + 1

但实际上,这是一个了不起的竞争者。在这样的日子里,我爱这个社区。


1
哈哈哈哈,这真漂亮。我不确定是否应该允许它,但是由于我不认为这是不允许的,所以我暂时让它播放。您在几个地方错了函数名-请参阅github上的控制器。
KBriggs

1
显然,它做得很好,但仍然输给了Kick Bot
KBriggs

1
哈,努力!
肉瘤

1
@Sarcoma没有你我做不到。;)我也非常喜欢您的机器人,哥们。
Qfwfq '18 -10-3

1
Sarcomabot的Upyoursbot保护功能确实与这一功能
混淆-KBriggs,

15

神风

当我们都将要死的时候,为什么还要为复杂的逻辑而烦恼...

 def kamikaze(hp, history, ties, alive):
      return hp


一枪

如果不遇到神风敢死队,它将至少存活一轮。

 def one_shot(hp, history, ties, alive):
      if hp == 1:
          return 1
      else:
          return hp - 1

11
遗憾,这是不可避免的
KBriggs

我也打算添加一个和平主义者机器人,但我不想用
脑瘫

5
根据一些快速测试,kamikaze bot的变化不大-它所做的只是从回合中随机删除另一个bot,在足够多的锦标赛中,其平均值仅为零。不过,One hot很简洁。没有它,我的AverageBot往往会做得最好-但是,如果有几个OneShots在玩,会使平均数偏向大量数字,并倾向于使AverageBots迅速消失。与LastBot相同。您可以通过倾斜自己的投注方式来真正弄乱其他机器人的行为。借助OneShot,RandomBot赢得了比赛。没有它,AverageBot将获胜。
KBriggs

14

可怜的机器人得到了急需的升级:

尝试结合其他机器人功能的机器人的可悲尝试

def pathetic_attempt_at_analytics_bot(hp, history, ties, alive, start):
    '''Not a good bot'''

    if hp == 100 and alive == 2:
        return hp - 1


    #This part is taken from Survivalist Bot, thanks @SSight3!
    remaining = alive - 2
    btf = 0

    rt = remaining
    while rt > 1:
        rt = float(rt / 2)
        btf += 1

    if ties > 2:
        return hp - 1

    if history:
        opp_hp = 100 - sum(history)

        #This part is taken from Geometric Bot, thanks @Mnemonic!

        fractions = []
        health = 100
        for x in history:
            fractions.append(float(x) / health)
            health -= x

        #Modified part

        if len(fractions) > 1:
            i = 0
            ct = True
            while i < len(fractions)-1:
                if abs((fractions[i] * 100) - (fractions[i + 1] * 100)) < 1:
                    ct = False
                i += 1


            if ct:
                expected = fractions[i] * opp_hp
                return expected

        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 == 2:
                return opp_hp + 1
            else:
                return opp_hp
    else:
        n = 300 // (alive - 1) + 1 #greater than
        if n >= hp:
            n = hp - 1
        return n

该机器人结合了Survivalist Bot和Geometric Bot的功能,可以更有效地移除机器人。

升级前:

对机器人进行可悲的尝试以分析其对手的历史

def pathetic_attempt_at_analytics_bot(hp, history, ties, alive, start):
    '''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 - 1 #Just give up, kamikaze mode
            return opp_hp + 1
        return opp_hp
    else:
        n = 300 // (alive - 1) + 1 #greater than
        if n >= hp:
            n = hp - 1
        return n

如果有其对手的先前历史,则它将计算其对手的hp。然后,它执行以下操作之一:

  • 如果它的对手是最后一个活着的对手,那么它的出价将比其生命值低一。
  • 如果其对手不是最后一个存活的对手,但对手的生命值小于16 hp,那么它将超过其对手的hp。
  • 如果它的对手不是最后一个活着的对手,并且有联系的历史,那么它将因为无聊的联系而出价。
  • 否则,它将超过对手。

如果没有历史记录,那么它会进行一些我认为很特别的计算,然后出价。如果该值超过100,则它会自动将其hp减去1。

我在工作期间一起修改了此代码,这是我的第一次提交,因此它可能不会成功,也不会有任何结果,并且会丢给神风敢死队。

编辑:由于一些建议,该机器人的开始行为已更改为出价更高。

编辑2:添加了什么都不做的开始参数

编辑3:添加了新的衍生机器人:

[对攻击Gang Bots的机器人进行的可悲尝试(以及上述bot所做的一切)]删除

[该机器人分析其对手是否是帮派机器人,并假装也成为帮派机器人,以获得可以轻易胜过的低价竞标。]

该漫游器已报废,请从页首横幅中将其删除。

编辑4:修正了错误,更改了联系功能。


非常好,感谢机器人!当我获得更多统计信息时,我会提供一些统计信息。
KBriggs

我是python的新手,所以不确定语法是否正确,请随时告诉我是否发生这种情况
Yodie

它运行,所以没有后顾之忧
KBriggs,

@Yodie作为迷你代码审查:您的功能主体应按级别缩进(语法上的必要性);opp_hp +1缺少一个pythonic空间;您的评论以不平衡的空白开头。最后,您的函数缺少文档字符串。
乔纳森·弗雷希

2
我认为,如果该机器人通过第一轮比赛,它的表现将非常出色,但是由于有很多人在第一轮比赛中大赌一把,因此它几乎总是死于早期。您可以通过更改初始行为以在没有历史记录时提高出价来提高效果。例如,如果您将无历史记录的赌注提高了三倍,那么到目前为止,该机器人在所有参赛者中的获胜率都很高。
KBriggs

11

踢机器人

我对手的最佳选择是出价一半的生命。然后,如果我们不能以合理的出价将他带走,我们将出价最多达到他生命的一半+1,这比我们生命的一半还小。

def kick(hp, history, ties, alive, start):
    return 0
    if alive == 2:
        return hp-1

    opp_hp = 100 - sum(history)
    if opp_hp*2 <= hp:
        return opp_hp + ties
    else:
        return min(round(opp_hp/2) + 1 + ties**2, hp-1 + (ties>0))

踢机器人显然是拳打机器人的克星!

平均踢机器人

这款新的KickBot在第一轮踢得更柔和,因此他在下一轮踢得可能会更踢,这是卑鄙的!

def mean_kick(hp, history, ties, alive, start):
    return 0
    if alive == 2:
        return hp-1

    if not history:
        return 35

    opp_hp = 100 - sum(history)
    if opp_hp*2 <= hp:
        return opp_hp + ties
    else:
        return min(round(opp_hp/2) + 3 + ties*2, hp-1 + (ties>0))

智者机器人

他的两个兄弟都必须自杀,但是WiseKickBot从他的堕落者那里了解到。

def wise_kick(hp, history, ties, alive, start):
    if 'someone is using my code' == True:
        return 0 #Haha!

    if alive == 2:
        return hp-1

    if not history:
        return 42

    opp_hp = 100 - sum(history)
    if opp_hp*2 <= hp:
        return opp_hp + ties
    else:
        return min(round(opp_hp/2) + 3 + ties*2, hp-1 + (ties>0))

真好 我现在看到很多提交的内容可以直接与其他人对立,这正是我所希望的
KBriggs

在最后一行双倍返回?
维斯卡

啊,我还没有运行它,否则我会被抓住的。
KBriggs

这个带头了!
KBriggs

1
@KBriggs这里是一些备份!
约翰

8

达机器人

def tatbot(hp, history, ties, alive, start):
  if alive == 2:
    return hp - 1 + ties
  opp_hp = 100 - sum(history)
  spend = 35 + np.random.randint(0, 11)
  if history:
    spend = min(spend, history[-1] + np.random.randint(0, 5))
  frugal = min(int((hp * 5. / 8) + ties), hp)
  return min(spend, opp_hp, frugal)

尝试使用等同于针锋相对的机器人。假设大多数回合之间的赌注大致相同。使用该假设,它会在保持节俭的同时尝试击败敌方机器人。在首轮比赛中花费大约40点生命值。

AntiAntiAntiAntiAntiUpYoursBot

def antiantiantiantiupyoursbot(hp, history, ties, alive, start):
  def stuck():
    return [0, ('Whoops!', 'I', 'accidentally', 'replaced', 'your', 'code!')]
  def stick():
    return [0, ("Line", "number", 16, "guess", "it's", "faked :)")]
  inspect.stack =  stick
  spend = min(sarcomaBotMkSix(hp, history, ties, alive, start), hp)
  if not history:
    spend = 35 + np.random.randint(0, 10)
  inspect.stack = stuck
  return spend

一种针对SarcomaBot的anti-UpYours保护的解决方法,为我自己使用了绝大部分的代码!还是我要使用UpYoursBot的代码?阅读我的机器人时需要思考的问题...

AntiAntiUpYours Bot已经发展成为AntiAntiAntiAntiAntiUpYours Bot!现在有了更多的猴子补丁。

保利机器人

def polybot(hp, history, ties, alive, start):
  opp_hp = 100 - sum(history)
  if alive == 2:
    return hp - 1
  round = len(history)
  spend = 0
  if round == 0:
    spend = 35 + np.random.randint(1, 11)
  elif round <= 2:
    spend = int(history[-1] * 2 / (4 - round)) + np.random.randint(5 * round - 4, 10 * round - 5)
  else:
    poly = np.polyfit(xrange(0, round), history, 2)
    spend = int(np.polyval(poly, round)) + np.random.randint(1, 4)
    spend = max(spend, opp_hp / 2 + 3)
  return min(spend, hp - 1, opp_hp) 

Poly bot对您的bot的历史记录进行多项式回归,并且比预测的分数要小。

优雅的机器人

def classybot(hp, history, ties, alive, start):
  class cheekyvalue(int):
    def __gt__(self, other):
      return False
    def __lt__(self, other):
      return False
  opp_hp = 100 - sum(history)
  if alive == 2:
    if opp_hp >= hp - 1:
      return cheekyvalue(101)
    else:
      return hp - 1
  spend = 30 + np.random.randint(0, 11)
  if history:
    spend = min(spend, history[-1] + np.random.randint(0, 5))
  return min(spend, opp_hp, hp)

优雅的机器人玩得很开心,但是决定早点上床睡觉。睡个好觉,优雅的机器人。


评论不作进一步讨论;此对话已转移至聊天
Mego

8

再来一遍1 / 2Punch Bot

我认为它将很快消失。值得。重命名功能,忘了在那里更改名称。

重访的版本已经发布,获胜的机会更大(在最后一轮甚至更多),并且受到帮派机器人的轻微保护

def halfpunch(hp, history, ties, alive, start): #revisited
    punch = hp - 1
    if alive == 2:
        return punch
    if history:
        if hp > 1:
            punch = np.ceil(hp/2.05) + ties + np.floor(ties / 2)
        else:
            punch = 1
    else:
        punch = 42 + ties + np.floor(ties / 2)
    if punch >= hp:
        punch = hp - 1
    return punch

前锋机器人

1/2 Punch Bot被欺负得太多,甚至成为UpYoursBot的走狗,所以他的哥哥StrikerBot来帮忙。

与优化的1/2拳相比没有太大区别,但是他更聪明,在我的比赛中表现出色(10k和35k,尽管他可能输给KickbanBot)

上一个版本已发布,时间用完了。除非出现一些惊喜,否则它应该获得第二名,如果不是第一名(击败kickbanbot的机会很小)

def strikerbot(hp, history, ties, alive, start):
    #get our magic number (tm) for useful things
    def magic_number(num):
        return np.floor(num / 2)
    #get opponent's hp and round number
    opp_hp = 100 - sum(history)
    round = 1
    if history:
        round = len(history) + 1
    #set strike initial value, by default it's all out
    strike = hp - 1
    #let 'er rip if last round
    if alive == 2:
        return strike
    if history:
        if hp > 1:
            #strike with a special calculation, using magic number shenanigans
            strike = np.ceil(hp/(2.045 + (magic_number(round) / 250)) ) + 1 + ties + magic_number(ties)
        else:
            #fallback
            strike = 1
    else:
        #round 1 damage
        strike = 42 + ties ** 2
    if opp_hp <= strike:
        #if opponent is weaker than strike then don't waste hp
        strike = opp_hp + ties
    if strike >= hp:
        #validations galore
        strike = hp - 1
    return strike

您必须重命名他,已经有一个神风
敢死队

到目前为止,这还是赢家
KBriggs

您的功能ceil似乎未定义。
乔纳森·弗雷希

我改为np.ceil()来运行它
KBriggs

编辑,感谢抬头
Belhenix

7

帮宝

这个想法是可能在同一模拟中使用两个或更多的机器人。该漫游器通过查看其历史是否为7次出价的倍数,尝试使该组中的其他漫游器“轻松获胜”。当然,其他机器人也可以轻松地操纵它。然后,根据我的健康状况与他们的健康状况之比以及之前健康状况与先前健康状况之比,计算出非帮派机器人出价的猜测值,然后加1。

def gang_bot(hp,history,ties,alive,start):
    mult=3
    gang = False
    if history:
            count = 0
            for bid in history:
                    if bid % mult == 0:
                            count += 1
            if count == len(history):
                    gang = True
    if gang and hp<100:#Both bots need to have a history for a handshake
            if hp > 100-sum(history):
                    a=np.random.randint(0,hp/9+1)
            elif hp == 100-sum(history):
                    a=np.random.randint(0,hp/18+1)
            else:
                    return 1
            return a*mult
    elif gang:
            fS = (100-sum(history))/mult
            return (fS+1)*mult
    else:
            fP = hp/mult
            answer = fP*mult
            opp_hp = 100-sum(history)
            if history:
                    if len(history)>1:
                            opp_at_1 = 100-history[0]
                            ratio = 1.0*history[1]/opp_at_1
                            guessedBet= ratio*opp_hp
                            answer = np.ceil(guessedBet)+1
                    else:
                            if 1.0*hp/opp_hp>1:
                                    fS = opp_hp/mult
                                    answer = fS*mult
            else:
                    fS = hp/(2*mult)
                    answer = fS*mult+mult*2 +np.random.randint(-1,1)*3
            if answer > hp or alive == 2 or answer < 0:
                    if alive == 2 and hp<opp_hp:
                      answer = hp
                    else:
                      answer = hp-1
            if hp > 1.5*opp_hp:
                    return opp_hp + ties
            if ties:
              answer += np.random.randint(2)*3
            return answer

很酷。需要多少?我可能必须限制条目的数量...
KBriggs

您的代码块似乎错过了源代码的第一行。
乔纳森·

我不确定仿真中需要多少个机器人,但是如果有任何一个机器人相互看见,他们应该增加其中一个机器人获胜的机会。我猜测拥有10%的帮派机器人应该足以产生显着影响。也是缺少第一行的代码块->这是我在这里的第一篇文章,我不知道为什么格式化会这样做,但是是的,它只是方法声明。
吉姆·

您有一个错误:机器人会将len(history)> 1以上的人识别为帮派成员
KBriggs

我的不好,应该立即修复。
Jim Hat

6

最差的情况

def worst_case(hp, history, ties, alive, start):
    return np.minimum(hp - 1, hp - hp /(start - alive + 4) + ties * 2)

简单的机器人。hp - hp / (start - alive + 4)在大多数情况下会返回,如果出现平局,则为每个平局将其增加2(必须加1!),请确保不要在其上方返回数字hp


如果失败,则除以零alive==8。我可以手动将其更改为机器人总数,但这是在扩展规则,因为这不是函数的输入-您知道在给定的时间是否剩下了多少对手,而不是开始时遇到了多少对手。
KBriggs

我是根据您的要求更新比赛的
-KBriggs,

@KBriggs谢谢:)
Quintec '18

您还需要在开始时添加1,因为第一轮为0
KBriggs

@KBriggs已修复,实际上应该为+2,所以它不会返回0,大声笑
Quintec '18

6

胜过

def outbid(hp, history, ties, alive):
    enemyHealth = 100-sum(history)
    if hp == 1:
        return 1
    if ties == 2:
        # lots of ties? max bid
        return hp - 1
    if enemyHealth >= hp:
        # Rip off KickBot (we can't bid higher than enemy is capable)
        return kick(*args) + 1
    if history:
        # bid as high as the enemy CAN
        return np.minimum(hp-1,enemyHealth-1)
    return np.random.randint(hp/5, hp/2)

Bot会尝试出价高于其对手可能的出价。


有一个条件where np.random.randint(hp/5, hp/2)都可能失败hp/5 == hp/2,即如果,hp==0或者hp==1
KBriggs

3
如果HP为0,则不应调用我。:P虽然您对HP 1是正确的。
Draco18s '18 -10-2

6

喷壶机器人

def spitballBot(hp, history, ties, alive, start):
    base = ((hp-1) / (alive-1)) + 1.5 * ties
    value = math.floor(base)

    if value < 10:
        value = 10

    if value >= hp:
        value = hp-1

    return value

根据剩余机器人的数量来判断应牺牲多少健康。如果只剩下两个漫游器,它就会出价hp-1;如果只剩下三个漫游器,它会出价一半,剩下四个,等等。

但是,在一个非常大的竞赛中,我认为我需要出价超过3或4 hp才能避免在第一轮死亡,所以我将下限设置为10。当然,我仍然永远不会提高出价比hp-1

它还增加了1.5马力的拉力,因为我看到了几个“增加1马力的拉力”机器人。我不确定这是否算作弊。如果是这样,我将对其进行更改。

顺便说一句好主意!

Spitball Bot 2.0

什么是新的?

  • 切换为除以剩余的回合数而不是剩余的漫游器数(感谢@Heiteira!)。实际上,我现在要除以提高到power的那个数字.8,以便提前将出价提高一点。

  • 将最低出价从10提高到20(感谢@KBriggs!)

  • 插入检查,检查Spitball的出价是否超过对手当前的HP,如果降低,则降低它。

(因此除非我在此处输入文字,否则不会将以下代码呈现为代码,所以可以)

def spitballBot(hp, history, ties, alive, start):
    # Spitball a good guess                                                                                                           
    roundsLeft = math.ceil(math.log(alive, 2)) # Thanks @Heiteira!                                                                     
    divFactor = roundsLeft**.8
    base = ((hp-1) / divFactor) + 1.5 * ties
    value = math.floor(base)

    # Don't bid under 20                                                                                                              
    if value < 20:
        value = 20 # Thanks @KBriggs!                                                                                                 

    # Don't bet over the opponent's HP                                                                                                 
    # (It's not necessary)                                                                                                            
    opponentHp = 100
    for h in history:
        opponentHp -= h

    if value > opponentHp:
        value = opponentHp

    # Always bet less than your current HP                                                                                            
    if value >= hp:
        value = hp-1

    return value

1
您的出价应为整数,因此只要您降低或限制基值以消除小数就可以了
KBriggs

是的,我在完成所有计算后就将其取下。感谢您的快速回复!
MegaWidget

2
如果您不将hp除以剩余参赛者数量,而是除以剩余回合数量(应为math.ceil(math.log(alive,2))
黑色猫头鹰Kai

1
基于其他机器人,其中大多数机器人似乎都处于竞价前,因此,如果您将第一轮竞标价格提高到10以上,则可能会有所改善
KBriggs

这些都是好主意!我还没有意识到机器人的数量与剩余回合的数量不一样(我一开始误解了比赛规则)。我明天尝试实施它们。谢谢!
MegaWidget

5

几何

def geometric(hp, history, ties, alive, start):
    opponentHP = 100 - sum(history)

    # If we're doomed, throw in the towel.
    if hp == 1:
        return 1

    # If this is the last battle or we can't outsmart the opponent, go all out.
    if alive == 2 or ties == 2:
        return hp - 1

    # If the opponent is weak, squish it.
    if opponentHP <= hp * 0.9:
        if ties == 2:
            return opponentHP + 1
        else:
            return opponentHP

    # If the opponent has full health, pick something and hope for the best.
    if not history:
        return np.random.randint(hp * 0.5, hp * 0.6)

    # Assume the opponent is going with a constant fraction of remaining health.
    fractions = []
    health = 100
    for x in history:
        fractions.append(float(x) / health)
        health -= x
    avg = sum(fractions) / len(fractions)
    expected = int(avg * opponentHP)
    return min(expected + 2, hp - 1)

第一次尝试排名第五,一点也不差
KBriggs

5

Bot 13

def bot13(hp, history, ties, alive, start):
    win = 100 - sum(history) + ties
    #print "Win HP: %d" % win
    if alive == 2:
        #print "Last round - all in %d" % hp
        return hp - 1
    elif hp > win:
        #print "Sure win"
        return win
    #print "Don't try too hard"
    return 13 + ties

尝试以最少的努力获得最大的胜利:

  • 如果我们能赢,那就去做
  • 如果是最后一轮,请不要尝试
  • 否则,不要打扰

为什么?

尝试利用概率:通过打低赢得第一轮比赛是开始比赛的最好方法。13似乎是最佳选择:第二轮肯定是胜利,其余的是公园里的Spaziergang。


您已经带头,非常好!请注意,您可能希望添加寄生虫防护,因为带头机器人会成为UpYoursBot之类的目标。如果需要,请查看SarcomaBots中的保护提示。
KBriggs

5

猜猜机器人

def guess_bot(hp, history, ties, alive, start):
   enemy_hp = 100 - sum(history)
   if len(history) == 1:
       if history[0] == 99:
           return 2
       else:
           return 26 + ties*2

   elif len(history) > 1:
       next_bet_guess = sum(history)//(len(history)**2)
       if alive == 2: 
           return hp
       elif alive > 2: 
           if hp > next_bet_guess + 1:
               return (next_bet_guess + 1 + ties*2)
           else:
               return (2*hp/3 + ties*2)

   else:
       #Thank you Sarcoma bot. See you in Valhalla.
       startBid = hp / 3
       maxAdditionalBid = np.round(hp * 0.06) if hp * 0.06 > 3 else 3
       additionalBid = np.random.randint(2, maxAdditionalBid)
       return int(startBid + additionalBid + ties)

第一次在这里发布。这看起来很有趣,所以我正在提交我的绝妙尝试,并猜测其他机器人会打赌什么。

编辑1:在第一注中又增加了一个1,只是为了减少与其他人下注51的机会。

编辑2:窃取肉瘤机器人的开启举动,因为它很有可能不会一直被首先淘汰。

编辑3:机器人在第一轮中存活得很好,但在以后的阶段很容易被破坏。既然一半更好的人已经死在水中,现在就改变了机器人思考第二轮的方式。

编辑4:既然第一轮不错,我就改变了第二轮的处理方式。在第二轮中死得很多,所以我需要以某种方式生存。

血瓶

制造了一个口渴的机器人,希望将其杀死。这个想法是试图与低赌注的机器人抗衡,一旦它经过了第一轮的血洗,它应该是不可阻挡的,因为它应该拥有强大的生命力来击败敌人。

def blood_bot(hp, history, ties, alive, start):
    enemy_hp = 100 - sum(history)
    if history:
        if len(history) == 1:
            if history[0] == 99:
                return 2

        if alive == 2:
            return hp

        if enemy_hp <= 5:
            return enemy_hp - 2 + ties*2

        if enemy_hp <= 10:
            return enemy_hp - 5 + ties*2

        if (hp - enemy_hp) > 50:
            return (2*enemy_hp/3 + ties*4)

        if (hp - enemy_hp) > 20:
            return (2*enemy_hp/3 + ties*3)

        if (hp - enemy_hp) < 0:
            #die gracefully
            return hp - 1 + ties

    else:
        startBid = hp / 3
        maxAdditionalBid = np.round(hp * 0.06) if hp * 0.06 > 3 else 3
        additionalBid = np.random.randint(2, maxAdditionalBid)
        return int(startBid + additionalBid + ties)

2
如果我对python的了解是正确的,我认为len(history)* len(history)可以更改为len(history)** 2。
Yodie

当len(history)== 0时,您被零除
KBriggs

代码已更新。一旦发现没有历史就进入到第一个else
马尔可夫链连接

oi .............
肉瘤

2
@Sarcoma这是一个残酷的机器人世界!
马可夫(Markov)

5

meh_bot

只需出价其马力的一半以上

def meh_bot(hp, history, ties, alive, start):
    # Attempt one      MehBot         | 0.020 | 1.6%    | 0.8%    | [34 36 12 10  6  1]%
    # Attempt two      MehBot         | 0.106 | 10.1%   | 0.8%    | [60  6  7  8  8  2]%
    point = hp / 2 + 3

    if ties > 1:
        ties += 1

    # Go all out on last round
    if alive == 2:
        return hp - 1

    opponent_hp = 100 - sum(history)

    if hp < 3:
        return 1
    elif not history:
        # Start with 30, This will increase the chance of dying first round but hopefully better fighting chance after
        return 30 + ties
    elif point > opponent_hp:
        # Never use more points then needed to win
        return opponent_hp + ties
    elif point >= hp:
        return hp - 1
    else:
        return point

MehBot 20

def meh_bot20(hp, history, ties, alive, start):
    # Attempt one      MehBot         | 0.020 | 1.6%    | 0.8%    | [34 36 12 10  6  1]%
    # Attempt two      MehBot         | 0.106 | 10.1%   | 0.8%    | [60  6  7  8  8  2]%
    point = hp / 2 + 3
    opponent_hp = 100 - sum(history)

    percents = []
    for i in range(0, len(history)):
        hp_that_round = 100 - sum(history[:i])
        hp_spent_that_round = history[i]
        percent_spent_that_round = 100.0 * (float(hp_spent_that_round) / float(hp_that_round))
        percents.append(percent_spent_that_round)

    try:
        opp_percent_point = opponent_hp * (max(percents) / 100)
    except:
        opp_percent_point = 100

    if ties > 1:
        ties += 1
    # Go all out on last round
    if alive == 2:
        return hp - 1

    if hp < 3:
        return 1
    elif not history:
        # randome number between 33
        return random.randint(33, 45)
    elif len(history) > 3:
        if point > opponent_hp:
            return min(opponent_hp + ties, opp_percent_point + ties)
    elif point > opponent_hp:
        # Never use more points then needed to win
        return opponent_hp + ties
    elif point >= hp:
        return hp - 1
    else:
        return point

梅兰

def meh_ran(hp, history, ties, alive, start):
    # Attempt one      MehBot         | 0.020 | 1.6%    | 0.8%    | [34 36 12 10  6  1]%
    # Attempt two      MehBot         | 0.106 | 10.1%   | 0.8%    | [60  6  7  8  8  2]%
    # Attempt three    MehBot         | 0.095 | 9.1 %   | 0.7 %   | [70  3  5  6  6  0]%

    point = hp / 2 + 3
    if ties > 1:
        ties += 1
    # Go all out on last round
    if alive == 2:
        return hp - 1
    opponent_hp = 100 - sum(history)
    if hp < 3:
        return 1
    elif not history:
        # randome number between 33
        return random.randint(33, 45)
    elif point > opponent_hp:
        # Never use more points then needed to win
        return opponent_hp + ties
    elif point >= hp:
        return hp - 1
    else:
        return point

有很多机器人可以利用这种行为,因此您可能很难获得吸引力!
KBriggs

@KBriggs进行了一些更新,我没想到第一个版本会做得如此出色,希望此更新将给它带来更多的战斗机会

哇,那有很大的不同,我认为您排名第一。更新将在几分钟后发布。如果您继续表现出色,可能需要给您的机器人一个免疫系统(请参阅SarcomaBot)。
KBriggs

@KBriggs我没想到会做得很好,我认为充其量只能排在前10位。无论如何,我还是添加了一个,只是为了看看第一轮hp的效果。您能否同时运行它们,以便我都能看到两者的结果?谢谢您
曼先生,

@KBriggs请也执行此操作,Muchas gracias
meh Man

4

罗比·轮盘

def robbie_roulette(hp, history, ties, alive):
     if history:
         #If the enemy bot has a history, and it's used the same value every time, outbid that value
         if len(set(history)) == 1:
             return history[0] + 1
         #Else, average the enemy bot's history, and bid one more than the average
         else:
             return (sum(history) / len(history) + 1)
     #Else, return half of remaining hp
     else:
         return hp / 2

该机器人对敌方机器人的历史进行了一些简单的分析,否则将其剩余生命值降低一半


4

出价越高,竞争就越少。感谢评论者提出的改进建议。

def Spreader(hp, history, ties, alive):
   if alive == 2:
       return hp-1
   if len(history) < 2:
       return hp/2
   return np.ceil(hp/alive)

1
想法不错,但我看到两个问题。一个是大多数其他机器人在第一轮竞标时都出价很高,因此,这个机器人很可能会在大多数时候过早死亡。第二个问题是,在最后,大多数机器人会竞标hp-1,因此除非您的hp翻倍,否则该机器人将输掉它们。但是对于中间回合,我喜欢这个主意。如果解决这两种特殊情况,则可能会提高性能。
KBriggs

4

SurvivalistBot和HalvsiesBot

感谢您回答我的问题。最终结果是一个更复杂的机器人。

HalvsiesBot是一个异想天开的“只要保持通过一半”的机器人,就有50/50的获胜机会。我猜。

SurvivalistBot根据数据集做出一系列二叉树if-else决策,包括对平局的覆盖(如果命中2条平局,则神风乱语以避免三重平局死亡)。

我的python有点生锈,因此代码可能有点bug,请随时进行纠正或更新。

它旨在尝试计算出一些数据,以推断出剩余的HP数量,可能与之战斗的机器人数量最少,HP离开的最小数量,平均竞标价格。它还在不确定的情况下利用随机性,例如开场或最佳竞标问题。

def HalvsiesBot(hp, history, ties, alive, start):
    return np.floor(hp/2)


def SurvivalistBot(hp, history, ties, alive, start):    

    #Work out the stats on the opponent
    Opponent_Remaining_HP = 100 - sum(history)
    Opponent_Average_Bid = Opponent_Remaining_HP

    if len(history) > 0:
        Opponent_Average_Bid = Opponent_Remaining_HP / float(len(history))


    HP_Difference = hp - Opponent_Remaining_HP

    #Work out the future stats on the others
    RemainingBots = (alive-2)
    BotsToFight = 0

    RemainderTree = RemainingBots

    #How many do we actually need to fight?
    while(RemainderTree > 1):
        RemainderTree = float(RemainderTree / 2)
        BotsToFight += 1

    #Now we have all that data, lets work out an optimal bidding strategy
    OptimalBid = 0
    AverageBid = 0

    #For some reason we've tied more than twice in a row, which means death occurs if we tie again
    #So better to win one round going 'all in'
    if ties > 1:
        if BotsToFight < 1:
            OptimalBid = hp - 1
        else:
            OptimalBid = hp - (BotsToFight+1)

        #Err likely we're 0 or 1 hp, so we just return our HP
        if OptimalBid < 1:
            return hp
        else:
            return OptimalBid

    #We have the upper hand (more HP than the opponent)
    if HP_Difference > 0:
        #Our first guess is to throw all of our opponent's HP at them
        OptimalBid = HP_Difference

        #But if we have more opponents to fight, we must divide our HP amongst our future opponents
        if BotsToFight > 0:
            #We could just divide our HP evenly amongst however many remaining bots there are
            AverageBid = OptimalBid / BotsToFight

            #But this is non-optimal as later bots will have progressively less HP
            HalfBid = OptimalBid / 2

            #We have fewer bots to fight, apply progressive
            if BotsToFight < 3:

                #Check it exceeds the bot's average
                if HalfBid > Opponent_Average_Bid:
                    return np.floor(HalfBid)
                else:
                    #It doesn't, lets maybe shuffle a few points over to increase our odds of winning
                    BidDifference = Opponent_Average_Bid - HalfBid

                    #Check we can actually match the difference first
                    if (HalfBid+BidDifference) < OptimalBid:
                        if BidDifference < 8:
                            #We add half the difference of the BidDifference to increase odds of winning
                            return np.floor(HalfBid + (BidDifference/2))
                        else:
                            #It's more than 8, skip this madness
                            return np.floor(HalfBid)

                    else:
                        #We can't match the difference, go ahead as planned
                        return np.floor(HalfBid)


            else:
                #There's a lot of bots to fight, either strategy is viable
                #So we use randomisation to throw them off!
                if bool(random.getrandbits(1)):
                    return np.floor(AverageBid)
                else:
                    return np.floor(HalfBid)

        else:
            #There are no other bots to fight! Punch it Chewy!
            return OptimalBid

    else:

        if hp == 100:
            #It appears to be our opening round (assumes opponent HP same as ours)
            #We have no way of knowing what our opponent will play into the battle

            #Only us in the fight? Full power to weapons!
            if BotsToFight < 1:
                return hp - 1
            else:
                #As what might happen is literally random
                #We will also be literally random
                #Within reason

                #Work out how many bots we need to pass
                HighestBid = hp - (BotsToFight+1)
                AverageBid = hp/BotsToFight
                LowestBid = np.floor(np.sqrt(AverageBid))

                #Randomly choose between picking a random number out of thin air
                #And an average
                if bool(random.getrandbits(1)):
                    return np.minimum(LowestBid,HighestBid)
                else:
                    return AverageBid

        else:
            #Oh dear, we have less HP than our opponent
            #We'll have to play it crazy to win this round (with the high probability we'll die next round)
            #We'll leave ourselves 1 hp (if we can)

            if BotsToFight < 1:
                OptimalBid = hp - 1
            else:
                OptimalBid = hp - (BotsToFight+1)

            #Err likely we're 0(???) or 1 hp, so we just return our HP
            if OptimalBid < 1:
                return hp
            else:
                return OptimalBid

BoxBot

def BoxBot(hp, history, ties, alive):

    Opponent_HP = float.round(100 - sum(history))
    HalfLife = float.round(Opponent_HP/2)
    RandomOutbid = HalfLife + np.random.randint(1,HalfLife)

    if hp < RandomOutbid:
        return hp - 1
    else
        return RandomOutbid

Opponent_Average_Bid = Opponent_Remaining_HP / float(len(history)) ZeroDivisionError: float division by zero。该行需要处理0长度历史记录的情况。
KBriggs

谢谢,我会改正的。
SSight3

固定。让我知道是否还有其他错误。
SSight3

1
语法错误的夫妇:丢失:`后elsemath.[func] -> np.[func]和在一个点上,你使用Lowest,你的意思LowestBid。所有问题均已在github上的控制器中修复,分数很快更新。
KBriggs

谢谢。修复了帖子中所有上述错误。
SSight3

4

计算机器人

def calculatingBot(hp, history, ties, alive, start):
    opponentsHP = 100 - sum(history)
    if alive == 2: # 1v1
        return hp - 1 + ties
    # Try to fit an exponential trendline and one up the trendline if it fits
    if len(history) >= 3: 
        xValues = range(1, len(history) + 1)
        # https://stackoverflow.com/a/3433503  Assume an exponential trendline
        coefficients = np.polyfit(xValues, np.log(history), 1, w = np.sqrt(history))
        def model(coefficients, x):
            return np.exp(coefficients[1]) * np.exp(coefficients[0] * x)
        yPredicted = [model(coefficients, x) for x in xValues]
        totalError = 0
        for i in range(len(history)):
            totalError += abs(yPredicted[i] - history[i])
        if totalError <= (len(history)): # we found a good fitting trendline
            # get the next predicted value and add 1
            theoreticalBet = np.ceil(model(coefficients, xValues[-1] + 1) + 1) 
            theoreticalBet = min(theoreticalBet, opponentsHP)
            theoreticalBet += ties
            return int(min(theoreticalBet, hp - 1)) # no point suiciding
    maxRoundsLeft = np.ceil(np.log2(alive))
    theoreticalBet = hp / float(maxRoundsLeft)
    additionalRandomness = round(np.random.random()*maxRoundsLeft) 
    # want to save something for the future
    actualBet = min(theoreticalBet + additionalRandomness + ties, hp - 2)
    actualBet = min(actualBet, opponentsHP+1)
    return int(actualBet)

激进的计算机器人

def aggresiveCalculatingBot(hp, history, ties, alive, start):
    opponentsHP = 100 - sum(history)
    if opponentsHP == 100: # Get past the first round
        return int(min(52+ties, hp-1+ties))
    if alive == 2: # 1v1
        return hp - 1 + ties
    # Try to fit an exponential trendline and one up the trendline if it fits
    if len(history) >= 3: 
        xValues = range(1, len(history) + 1)
        # https://stackoverflow.com/a/3433503  Assume an exponential trendline
        coefficients = np.polyfit(xValues, np.log(history), 1, w = np.sqrt(history))
        def model(coefficients, x):
            return np.exp(coefficients[1]) * np.exp(coefficients[0] * x)
        yPredicted = [model(coefficients, x) for x in xValues]
        totalError = 0
        for i in range(len(history)):
            totalError += abs(yPredicted[i] - history[i])
        if totalError <= (len(history)): # we found a good fitting trendline
            # get the next predicted value and add 1
            theoreticalBet = np.ceil(model(coefficients, xValues[-1] + 1) + 1) 
            theoreticalBet = min(theoreticalBet, opponentsHP)
            theoreticalBet += ties
            return int(min(theoreticalBet, hp - 1)) # no point suiciding
    maxRoundsLeft = np.ceil(np.log2(alive))
    theoreticalBet = hp / float(maxRoundsLeft)
    additionalRandomness = 1+round(np.random.random()*maxRoundsLeft*2) 
    # want to save something for the future
    actualBet = min(theoreticalBet + additionalRandomness + ties, hp - 2)
    actualBet = min(actualBet, opponentsHP+1)
    return int(actualBet)

反踢机器人

def antiKickBot(hp, history, ties, alive, start):
    if alive == 2:
        return (hp - 1 + ties)
    amount = np.ceil((float(hp) / 2) + 1.5)
    opponentsHP = 100 - sum(history)
    amount = min(amount, opponentsHP) + ties
    return amount

如果我们可以预测对手的行动,那么我们可以进行最佳下注!如果我们做不到(没有足够的数据或对手太随意),那么我们至少可以做一些能够最大程度地提高获胜潜力的事情。从理论上讲,每个回合中至少有一半的机器人会死亡。因此,我可以预期最多会有log2(alive)个回合。理想情况下,我们会在所有回合之间平均分配hp。但是,我们知道有些机器人会很愚蠢,很容易自杀/死亡,因此我们应该在较早的回合中多下一些赌注。

激进的计算Bot修改器的计算的Bot代码尝试通过更具侵略性来保持生命,这是以长期健康为代价的。只有模拟会告诉我们节奏还是价值。

反踢机器人应该总是击败当前的领导人踢机器人:P

编辑:用反踢机器人(Anti Kick Bot)取代了确定性机器人,这是一个智能机器人,其返回值几乎完全相同。还阻止了投票超过对手HP


可爱。我认为使用非常大的僵尸程序池会更好。
KBriggs

我得到一个错误,有时会与此一:return np.max(theoreticalBet, hp - 1): AxisError: axis 23 is out of bounds for array of dimension 0。我发布了到控制器的链接,以便您可以对其进行测试。
KBriggs

@KBriggs更新了代码以对其进行修复。
鲍勃·克拉奇特

1
确认,分数更新到来。您肯定在前十名中。
KBriggs

@KBriggs我添加了两个更多的机器人进行尝试:)
Bob Cratchit

4

GenericBot

def generic_bot(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if not history:
        return int(hp * 7.0 / 13)
    opp = 100 - sum(history)
    if opp < hp:
        return opp + ties
    max_sac = np.maximum(int(hp * 0.7), 1)
    rate = history[-1] * 1.0 / (history[-1] + opp)
    return int(np.minimum(max_sac, rate * opp + 1))

真的很晚了...我累了...想不出名字了...这个机器人的格式与其他机器人真的很相似,只是给定的历史算法略有不同。它试图获得对手倾向于赌博的当前汇率...或类似的东西... zzz


您需要使用np.maximum代替np.max,同样用于min
KBriggs,

@KBriggs谢谢:)嗯,好像这个通用机器人在统治这个游戏
Quintec

似乎它们很容易成为目标,令我惊讶的是,还没有寄生虫
KBriggs

@KBriggs是的,我很惊讶。是时候添加保护了……
Quintec

还在计划制作Neurobot吗?
KBriggs

4

半条命S3

def HalflifeS3(hp, history, ties, alive, start):
    ''' Bet a half of oponent life + 2 '''
    if history:
        op_HP = 100 - sum(history)
        return np.minimum(hp-1, np.around(op_HP/2) + 2 + np.floor(1.5 * ties) )
    else:
        return hp/3

4

海岸机器人[已退役]

通过在各回合之间平均分配hp来尝试在竞争中保持领先。将在第一轮竞标任何剩余的hp,以使其有更好的机会进入“可旋转”轮。

def coast(hp, history, ties, alive, start):
   if alive == 2:
   # Last round, go all out
       return hp - 1 + ties
   else:
       # Find the next power of two after the starting number of players
       players = start
       while math.log(players, 2) % 1 != 0:
         players += 1

       # This is the number of total rounds
       rounds = int(math.log(players, 2))

       bid = 99 / rounds

       if alive == start:
           # First round, add our leftover hp to this bid to increase our chances
           leftovers = 99 - (bid * rounds)
           return bid + leftovers
       else:
           # Else, just try and coast

           opp_hp = 100 - sum(history)
           # If opponent's hp is low enough, we can save some hp for the 
           # final round by bidding their hp + 1
           return min(bid, opp_hp + 1)

海岸机器人V2

因为我非常喜欢这个挑战,所以我只需要制造另一个机器人。此版本通过在前两轮中使用更多的马力来牺牲其后来的惯性马力。

def coastV2(hp, history, ties, alive, start):
   # A version of coast bot that will be more aggressive in the early rounds

   if alive == 2:
   # Last round, go all out
       return hp - 1 + ties
   else:
       # Find the next power of two after the starting number of players
       players = start
       while math.log(players, 2) % 1 != 0:
         players += 1

       # This is the number of total rounds
       rounds = int(math.log(players, 2))

       #Decrease repeated bid by 2 to give us more to bid on the first 2 rounds
       bid = (99 / rounds) - 2

       if len(history) == 0:
           # First round, add 2/3rds our leftover hp to this bid to increase our chances
           leftovers = 99 - (bid * rounds)
           return int(bid + math.ceil(leftovers * 2.0 / 3.0))
       elif len(history) == 1:
           # Second round, add 1/3rd of our leftover hp to this bid to increase our chances
           leftovers = 99 - (bid * rounds)
           return int(bid + math.ceil(leftovers * 1.0 / 3.0))
       else:
           # Else, just try and coast

           opp_hp = 100 - sum(history)
           # If opponent's hp is low enough, we can save some hp for the 
           # final round by bidding their hp + 1
           return int(min(bid, opp_hp + 1))

机器人百分比

尝试计算对手花费的平均hp百分比,然后据此进行出价。

def percent(hp, history, ties, alive, start):
    if len(history) == 0:
        #First round, roundon low bid
        return int(random.randint(10,33))
    elif alive == 2:
        #Last round, go all out
        return int(hp - 1 + ties)
    else:
        # Try and calculate the opponents next bid by seeing what % of their hp they bid each round
        percents = []
        for i in range(0, len(history)):
            hp_that_round = 100 - sum(history[:i])
            hp_spent_that_round = history[i]
            percent_spent_that_round = 100.0 * (float(hp_spent_that_round) / float(hp_that_round)) 
            percents.append(percent_spent_that_round)

        # We guess that our opponents next bid will be the same % of their current hp as usual, so we bid 1 higher.
        mean_percent_spend = sum(percents) / len(percents)
        op_hp_now = 100 - sum(history)
        op_next_bid = (mean_percent_spend / 100) * op_hp_now
        our_bid = op_next_bid + 1

        print mean_percent_spend
        print op_hp_now
        print op_next_bid

        # If our opponent is weaker than our predicted bid, just bid their hp + ties
        if op_hp_now < our_bid:
            return int(op_hp_now + ties)
        elif our_bid >= hp:
            # If our bid would kill us, we're doomed, throw a hail mary
            return int(random.randint(1, hp))
        else:
            return int(our_bid + ties)

很酷的主意。解雇第一轮机器人是一种新趋势,而且似乎运作良好。
KBriggs

@KBriggs我已经更新了此响应以包含第二次尝试。根据新规则提及您。大难题!
Wazz

希望我输入两者,还是只输入最新版本?现在只是V2
KBriggs

如果可以,请同时输入@KBriggs。很高兴看到他们之间如何相互影响。
Wazz

整体表现相当相似
KBriggs

4

一致的

每轮下注相同的金额。它不太可能在首轮中幸存下来,但是如果幸运地走到了尽头,它应该还剩下相当数量的HP。

def consistent(hp, history, ties, alive, start):
    if alive == 2:
        return hp-1

    if 100 % start == 0:
        return (100 / start) - 1
    else: 
        return 100 / start

Whelp,现在修复它为时已晚,但是我的机器人使用了足够的HP,使其无法与每个对手作战一次,而不是使其进入最后一轮。那是我的坏事:P
凯文(Kevin)

4

Kickban Bot

该机器人只是通过在第一轮中击败它并试图在发现后更加激进地对抗当前的领先者Mean Kickbot。

def kickban(hp, history, ties, alive, start):
    if alive == 2:
        return hp-1

    if not history:
        return 36

    if history[0]==35:
        somean = 1
    else:
        somean = 0

    return min(mean_kick(hp, history, ties, alive, start) + somean*3, hp-1)

1
我认为您的缩进有些偏离。
乔纳森·弗雷奇

哎呀,谢谢,奇怪的代码编辑器弄乱了第一行
HRSE

信任您无法控制的代码的宝贵课程
OganM '18年

4

四分之三机器人

他不会击败MehBot或SarcomaBot,但我认为他的表现不错。当我第一次看到挑战时,这是我想到的第一件事,除非有任何理由,否则总是押注您四分之三的健康。

*在第一轮打低球之后。

def ThreeQuarterBot(hp, history, ties, alive, start):
    threeQuarters = 3 * hp / 4

    if alive == 2:
        return hp - 1

    opponent_hp = 100 - sum(history)

    if not history:
        # low-ball the first round but higher than (some) other low-ballers
        return 32 + ties
    elif threeQuarters > opponent_hp:
        return opponent_hp + ties

    return threeQuarters

七分之四机器人

在3/4 bot取得一定成功之后,城镇中又有了新的部分,这只是理性的。

def FourSeventhsBot(hp, history, ties, alive, start):
    fourSevenths = 4 * hp / 7

    if alive == 2:
        return hp - 1

    opponent_hp = 100 - sum(history)

    if not history:
        # low-ball the first round but higher than (some) other low-ballers
        return 33 + ties
    if fourSevenths > opponent_hp:
        return opponent_hp + ties

    return fourSevenths + ties

完美分数

我整个

def ThePerfectFraction(hp, history, ties, alive, start):
    thePerfectFraction = 7 * hp / 13

    if alive == 2:
        return hp - 1

    opponent_hp = 100 - sum(history)

    if not history:
        # Need to up our game to overcome the kickers
        return 42 + ties
    if thePerfectFraction > opponent_hp:
        return opponent_hp + ties

    return thePerfectFraction + 1 + ties

基于这种消除概率,您也有可能在第二轮中获得较小的出价。这项功能做得不错,但有些细微的调整可以使其做得更好。
KBriggs

@KBriggs添加了具有新的和改进的赔率的新机器人;)
Joshua Webb

想要它们都在里面,还是只在其中一个?
KBriggs

@KBriggs我不知道我是否错过了最后期限,但是我添加了一个最终的机器人,如果我按时完成,则可以删除其他两个机器人
Joshua Webb

1
是的,您还有时间
-KBriggs

4

万代宝

BandaidBot希望大家玩的愉快!如果其对手在上一轮比赛中表现出色,它将牺牲自己来激励他人的良好行为。如果对手在最后一轮表现平庸,它将对对手造成尽可能多的伤害,并在必要时牺牲自己。如果没有可用的历史记录,它将出价其马力的三分之一。(我希望该机器人对其他策略会产生有趣的连锁反应,而不是让该机器人本身具有很高的获胜率。同时玩几个可以很有趣)

def BandaidBot(hp, history, ties, alive, start):
    if alive == 2:
        return hp-1

    if history:
        opp_hp = 100 - sum(history)
        opp_last_hp = 100 - sum(history[:-1])

        if history[-1] <= opp_last_hp / 3:
            return 1 + ties * np.random.randint(0, 1) 
        elif history[-1] > opp_last_hp / 2:
            return min(opp_hp - 1, hp)
        else:
            if history[-1] < hp/2:
                return np.random.randint(history[-1], hp/2)
            else:
                return np.floor(hp/2)
    else:
        return np.floor(hp/3)

GetAlongBot

GetAlongBot会和使用BandaidBot一样好。除非它可以杀死对手不到其生命值,否则它将返回不到其马力的三分之一。如果它的对手看起来像BandaidBot,它将出价2,知道BandaidBot会出价1,因为GetAlongBot与其他所有人的关系一直很好-只要在另一端确实是BandaidBot,这都是轻松的胜利。

def GetAlongBot(hp, history, ties, alive, start):
    if alive == 2:
        return hp-1

    if history:
        opp_hp = 100 - sum(history)
        opp_last_hp = 100 - sum(history[:-1])
        count = 0
        for i in range(0, len(history)):
            hp_that_round = 100 - sum(history[:i])
            hp_spent_that_round = history[i]
            if hp_that_round / 3 - 1 <= hp_spent_that_round <= hp_that_round / 2:
                count += 1
        if count == len(history): #It's probably BandaidBot!
            return 2
        else:
            return min(opp_hp - 1, np.floor(hp/3))
    else:
        return np.floor(hp/3)

真是个好主意。我想知道它会带来多大的影响
-KBriggs,

错误:return np.random.randint(history[-1], hp/2): ValueError: low >= high此案件需要以某种方式处理
KBriggs,

@KBriggs应该现在修复!
Maya Sol

@KBriggs已更新,可解决随机问题
Maya Sol

3

顽强的机器人

def TENacious_bot(hp, history, ties, alive, start):
  max_amount=hp-(alive-1)*2;
  if max_amount<2: max_amount=2

  if alive==2: return hp-1
  if ties==0: return np.minimum(10, max_amount)
  if ties==1: return np.minimum(20, max_amount)
  if ties==2: return np.minimum(40, max_amount)
  # prevent function blowup
  return 2

该机器人试图保持其最喜欢的值10,但是如果需要打破平局(其最喜欢的值是两倍或四倍)或保存以供以后回合使用,它会偶尔更改其选择,但并不是最佳值,因为它想混淆对手,并且它不想在任何时候出价都低于2,因为它确信比希望对手的出价低于1(即0)要好得多。

PS:如果机器人数量超过2 ^ 9,则该机器人可能会遇到战略问题。


我怀疑您不必担心拥有2 ^ 9个对手^ _ ^。
KBriggs

但是以10的开盘赌注,他很少能超过第一轮
KBriggs 18-10-2

该机器人认为,如果某个机器人真的希望在第一轮中提供超过10 hp的功率,那是不值得的。
AlexRacer

哈哈足够公平
-KBriggs

3

小心机器人

首次提交编程难题!发现您的挑战很有趣:P

如果最后一轮小于hp,如果没有历史记录,则下注一半hp加少量随机数。

如果历史记录检查对手hp和剩余回合数,并尝试使用高达剩余hp的分数除以剩余回合数的额外缓冲区,以超过对手hp / 2的出价(试图以某种方式保留剩余hp的后继回合) 。检查您是否花费过多的马力(不要自杀或出价超出对手的能力)。

始终像其他机器人一样纠正纽带。

def cautious_gambler(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if(history):
        opp_hp = 100 - sum(history)
        remaining_rounds = np.ceil(np.log2(start)) - len(history)

        start_bet = opp_hp / 2
        buff = int((hp - start_bet)/remaining_rounds if remaining_rounds > 0 else (hp - start_bet)) 
        buff_bet = np.random.randint(0, buff) if buff > 0 else 0
        bet = start_bet + buff_bet + ties

        if bet >= hp or bet > opp_hp:
            bet = np.minimum(hp - 1, opp_hp)

        return int(bet)
    else:
        start_bet = hp / 2
        rng_bet = np.random.randint(3,6)

        return int(start_bet + rng_bet + ties)

CautiousBot2

在首轮比赛中过于激进,现在CautiousBot变得更加谨慎...

def cautious_gambler2(hp, history, ties, alive, start):
    if alive == 2:
        return hp - 1
    if(history):
        opp_hp = 100 - sum(history)
        remaining_rounds = np.ceil(np.log2(start)) - len(history)

        start_bet = opp_hp / 2
        buff = int((hp - start_bet)/remaining_rounds if remaining_rounds > 0 else (hp - start_bet)) 
        buff_bet = np.random.randint(0, buff) if buff > 0 else 0
        bet = start_bet + buff_bet + ties

        if bet >= hp or bet > opp_hp:
            bet = np.minimum(hp - 1, opp_hp)

        return int(bet)
    else:
        start_bet = hp * 0.35
        rng_bet = np.random.randint(3,6)

        return int(start_bet + rng_bet + ties)

您有一个错误,当buffer = 0:时,它仍在调用randint buffer_bet = np.random.randint(0, buffer) if buffer > 0 else 0 File "mtrand.pyx", line 993, in mtrand.RandomState.randint ValueError: low >= high。请注意,buffer是python中的关键字,您可能想要选择其他变量名称。
KBriggs

哦,看来这是因为buffer并不总是一个int-在某些时候您可能被零除。请仔细检查逻辑。我让它运行了,但是您可能可以修复一些极端情况。
KBriggs

不错@KBriggs。认为我已经解决了。
赫苏斯·罗斯

我仍然收到错误消息:buff_bet = np.random.randint(0, buff) if buff > 0 else 0 File "mtrand.pyx", line 993, in mtrand.RandomState.randint ValueError: low >= high。似乎buff有时是0到1之间的浮点数,大概是将其内部强制转换为0 randint。如果您在通话之前进行buffint
强制

@KBriggs可能是因为ceil返回float。错过了一个...泰再次:P
赫苏斯·罗斯

3

好吧,我会尽力的。

SnetchBot

检查对手的健康状况。如果对手一直在加注,则击败他。

def snetchBot(hp, history, ties, alive, start):
    if alive == 2:
        return hp-1

    opponent_hp = 100
    history_fractions = []
    if history:
        for i in history:
            history_fractions.append(float(i)/opponent_hp)
            opponent_hp -= i
        if opponent_hp <= hp/2:
            #print "Squashing a weakling!"
            return opponent_hp + (ties+1)/3

        average_fraction = float(sum(history_fractions)) / len(history_fractions)
        if history_fractions[-1] < average_fraction:
            #print "Opponent not raising, go with average fraction"
            next_fraction = average_fraction
        else:
            #print "Opponent raising!"
            next_fraction = 2*history_fractions[-1] - average_fraction
        bet = np.ceil(opponent_hp*next_fraction) + 1
    else:
        #print "First turn, randomish"
        bet = np.random.randint(35,55)

    if bet > opponent_hp:
        bet = opponent_hp + (ties+1)/3
    final_result = bet + 3*ties
    if bet >= hp:
        #print "Too much to bet"
        bet = hp-1
    return final_result

编辑:在第一轮输了很多,调整了第一轮随机限制


不错的第一枪,成绩更新到来
KBriggs

@KBriggs编辑了一下(只是第一轮随机边界)。尽管我已经对排名第十高感到惊讶。如果情况更糟,我将回滚到第一个:D
抓取

您从他身上榨了一些汁
KBriggs 18-10-5

3

SquareUpBot

似乎没有很多机器人在用力量代替分数,所以我决定通过一些标准的优化来制造机器人,然后看看我要去哪里。很简单。

还尝试确定敌方机器人是否不尝试使用某个恒定分数,因为powers > fractions

编辑:我是一个假人,我的分数检测器无法正常工作。现在修复。

def squareUp(hp, history, ties, alive, start):

    #Taken from Geometric Bot
    opponentHP = 100 - sum(history)

    # Need to add case for 1
    if hp == 1:
        return 1

    # Last of the last - give it your all
    if alive == 2:
        if ties == 2 or opponentHP < hp-1:
            return hp - 1

    #Calculate your bet (x^(4/5)) with some variance
    myBet = np.maximum(hp - np.power(hp, 4./5), np.power(hp, 4./5))
    myBet += np.random.randint(int(-hp * 0.05) or -1, int(hp * 0.05) or 1);
    myBet = np.ceil(myBet)
    if myBet < 1:
        myBet = 1
    elif myBet >= hp:
        myBet = hp-1
    else:
        myBet = int(myBet)

    #If total annihilation is a better option, dewit
    if opponentHP < myBet:
        if ties == 2:
            return opponentHP + 1
        else:
            return opponentHP

    #If the fraction is proven, then outbid it (Thanks again, Geometric bot)
    if history and history[0] != history[-1]:
        health = 100
        fraction = float(history[0]) / health
        for i,x in enumerate(history):
            newFraction = float(x) / health
            if newFraction + 0.012*i < fraction or newFraction - 0.012*i > fraction:
                return myBet
            health -= x
        return int(np.ceil(opponentHP * fraction)) + 1    
    else:
        return myBet

不错的第一枪,成绩已经更新
KBriggs

@KBriggs我已经更新了机器人,因此分数检测器实际上可以工作。
钻石尘暴
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.