A game of dice, but avoid number 6












54














Dice



I was invited to play a game of dice which I had never heard of. The rules were simple, yet I think it would be perfect for a KotH challenge.



The rules



The start of the game



The die goes around the table, and each time it is your turn, you get to throw the die as many times as you want. However, you have to throw it at least once. You keep track of the sum of all throws for your round. If you choose to stop, the score for the round is added to your total score.



So why would you ever stop throwing the die? Because if you get 6, your score for the entire round becomes zero, and the die is passed on. Thus, the initial goal is to increase your score as quickly as possible.



Who is the winner?



When the first player around the table reaches 40 points or more, the last round starts. Once the last round has started, everyone except the person who initiated the last round gets one more turn.



The rules for the last round is the same as for any other round. You choose to keep throwing or to stop. However, you know that you have no chance of winning if you don't get a higher score than those before you on the last round. But if you keep going too far, then you might get a 6.



However, there's one more rule to take into consideration. If your current total score (your previous score + your current score for the round) is 40 or more, and you hit a 6, your total score is set to 0. That means that you have to start all over. If you hit a 6 when your current total score is 40 or more, the game continues as normal, except that you're now in last place. The last round is not triggered when your total score is reset. You could still win the round, but it does become more challenging.



The winner is the player with the highest score once the last round is over. If two or more players share the same score, they will all be counted as victors.



An added rule is that the game continues for a maximum of 200 rounds. This is to prevent cases where multiple bots basically keep throwing until they hit 6 to stay at their current score. Once the 199th round is passed, last_round is set to true, and one more round is played. If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.



Recap




  • Each round you keep throwing the die until you choose to stop or you get a 6

  • You must throw the die once (if your first throw is a 6, your round is immediately over)

  • If you get a 6, your current score is set to 0 (not your total score)

  • You add your current score to your total score after each round

  • When a bot ends their turn resulting in a total score of at least 40, everyone else gets a last turn

  • If your current total score is $geq 40$ and you get a 6, your total score is set to 0 and your round is over

  • The last round is not triggered when the above occurs

  • The person with the highest total score after the last round is the winner

  • In case there are multiple winners, all will be counted as winners

  • The game lasts for a maximum of 200 rounds


Clarification of the scores




  • Total score: the score that you have saved from previous rounds

  • Current score: the score for the current round

  • Current total score: the sum of the two scores above


How do you participate



To participate in this KotH challenge, you should write a Python class which inherits from Bot. You should implement the function: make_throw(self, scores, last_round). That function will be called once it is your turn, and your first throw was not a 6. To keep throwing, you should yield True. To stop throwing, you should yield False. After each throw, the parent function update_state is called. Thus, you have access to your throws for the current round using the variable self.current_throws. You also have access to your own index using self.index. Thus, to see your own total score you would use scores[self.index]. You could also access the end_score for the game by using self.end_score, but you can safely assume that it will be 40 for this challenge.



You are allowed to create helper functions inside your class. You may also override functions existing in the Bot parent class, e.g. if you want to add more class properties. You are not allowed to modify the state of the game in any way except yielding True or False.



You're free to seek inspiration from this post, and copy any of the two bots that I've included here. However, I'm afraid that they're not particularly effective...



On allowing other languages



In both the sandbox and on The Nineteenth Byte, we have had discussions about allowing submissions in other languages. After reading about such implementations, and hearing arguments from both sides, I have decided to restrict this challenge to Python only. This is due to two factors: the time required to support multiple languages, and the randomness of this challenge requiring a high number of iterations to reach stability. I hope that you will still participate, and if you want to learn some Python for this challenge, I'll try to be available in the chat as often as possible.



For any questions that you might have, you can write in the chat room for this challenge. See you there!



Rules




  • Sabotage is allowed, and encouraged. That is, sabotage against other players

  • Any attempt to tinker with the controller, runtime or other submissions will be disqualified. All submissions should only work with the inputs and storage they are given.

  • Any bot which uses more than 500MB memory to make its decision will be disqualified (if you need that much memory you should rethink your choices)

  • A bot must not implement the exact same strategy as an existing one, intentionally or accidentally.

  • You are allowed to update your bot during the time of the challenge. However, you could also post another bot if your approach is different.


Example



class GoToTenBot(Bot):
def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


This bot will keep going until it has a score of at least 10 for the round, or it throws a 6. Note that you don't need any logic to handle throwing 6. Also note that if your first throw is a 6, make_throw is never called, since your round is immediately over.



For those who are new to Python (and new to the yield concept), but want to give this a go, the yield keyword is similar to a return in some ways, but different in other ways. You can read about the concept here. Basically, once you yield, your function will stop, and the value you yielded will be sent back to the controller. There, the controller handles its logic until it is time for your bot to make another decision. Then the controller sends you the dice throw, and your make_throw function will continue executing right where if stopped before, basically on the line after the previous yield statement.



This way, the game controller can update the state without requiring a separate bot function call for each dice throw.



Specification



You may use any Python library available in pip. To ensure that I'll be able to get a good average, you have a 100 millisecond time limit per round. I'd be really happy if your script was way faster than that, so that I can run more rounds.



Evaluation



To find the winner, I will take all bots and run them in random groups of 8. If there are fewer than 8 classes submitted, I will run them in random groups of 4 to avoid always having all bots in each round. I will run simulations for about 8 hours, and the winner will be the bot with the highest win percentage. I will run start the final simulations at the start of 2019, giving you all Christmas to code your bots! The preliminary final date is January 4th, but if that's too little time I can change it to a later date.



Until then, I'll try to make a daily simulation using 30-60 minutes of CPU time, and updating the score board. This will not be the official score, but it will serve as a guide to see which bots perform the best. However, with Christmas coming up, I hope you can understand that I won't be available at all times. I'll do my best to run simulations and answer any questions related to the challenge.



Test it yourself



If you want to run your own simulations, here's the full code to the controller running the simulation, including two example bots.



Controller



Here's the updated controller for this challenge. It supports ANSI outputs, multi-threading, and collects additional stats thanks to AKroell! When I make changes to the controller, I'll update the post once documentation is complete.



import random
import time
import math
import sys
from multiprocessing import Pool
from collections import defaultdict
# Importing all the bots
from forty_game_bots import *

# If you want to see what each bot decides, set this to true
# Should only be used with one thread and one game
DEBUG = False
# If your terminal supports ANSI, try setting this to true
ANSI = False

def print_str(x, y, string):
print("33["+str(y)+";"+str(x)+"H"+string, end = "", flush = True)

class bcolors:
WHITE = '33[0m'
GREEN = '33[92m'
BLUE = '33[94m'
YELLOW = '33[93m'
RED = '33[91m'
ENDC = '33[0m'

# Class for handling the game logic and relaying information to the bots
class Controller:

def __init__(self, bots_per_game, games, bots, thread_id):
"""Initiates all fields relevant to the simulation

Keyword arguments:
bots_per_game -- the number of bots that should be included in a game
games -- the number of games that should be simulated
bots -- a list of all available bot classes
"""
self.bots_per_game = bots_per_game
self.games = games
self.bots = bots
self.number_of_bots = len(self.bots)
self.wins = defaultdict(int)
self.played_games = defaultdict(int)
self.bot_timings = defaultdict(float)
# self.wins = {bot.__name__: 0 for bot in self.bots}
# self.played_games = {bot.__name__: 0 for bot in self.bots}
self.end_score = 40
self.thread_id = thread_id
self.max_rounds = 200
self.timed_out_games = 0
self.tied_games = 0
self.total_rounds = 0
self.highest_round = 0
#max, avg, avg_win, throws, success, rounds
self.highscore = defaultdict(lambda:[0, 0, 0, 0, 0, 0])
# self.highscore = {bot.__name__: [0, 0, 0] for bot in self.bots}

# Returns a fair dice throw
def throw_die(self):
return random.randint(1,6)
# Print the current game number without newline
def print_progress(self, progress):
length = 50
filled = int(progress*length)
fill = "="*filled
space = " "*(length-filled)
perc = int(100*progress)
if ANSI:
col = [
bcolors.RED,
bcolors.YELLOW,
bcolors.WHITE,
bcolors.BLUE,
bcolors.GREEN
][int(progress*4)]

end = bcolors.ENDC
print_str(5, 8 + self.thread_id,
"t%s[%s%s] %3d%%%s" % (col, fill, space, perc, end)
)
else:
print(
"rt[%s%s] %3d%%" % (fill, space, perc),
flush = True,
end = ""
)

# Handles selecting bots for each game, and counting how many times
# each bot has participated in a game
def simulate_games(self):
for game in range(self.games):
if self.games > 100:
if game % (self.games // 100) == 0 and not DEBUG:
if self.thread_id == 0 or ANSI:
progress = (game+1) / self.games
self.print_progress(progress)
game_bot_indices = random.sample(
range(self.number_of_bots),
self.bots_per_game
)

game_bots = [None for _ in range(self.bots_per_game)]
for i, bot_index in enumerate(game_bot_indices):
self.played_games[self.bots[bot_index].__name__] += 1
game_bots[i] = self.bots[bot_index](i, self.end_score)

self.play(game_bots)
if not DEBUG and (ANSI or self.thread_id == 0):
self.print_progress(1)

self.collect_results()

def play(self, game_bots):
"""Simulates a single game between the bots present in game_bots

Keyword arguments:
game_bots -- A list of instantiated bot objects for the game
"""
last_round = False
last_round_initiator = -1
round_number = 0
game_scores = [0 for _ in range(self.bots_per_game)]


# continue until one bot has reached end_score points
while not last_round:
for index, bot in enumerate(game_bots):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

if game_scores[index] >= self.end_score and not last_round:
last_round = True
last_round_initiator = index
round_number += 1

# maximum of 200 rounds per game
if round_number > self.max_rounds - 1:
last_round = True
self.timed_out_games += 1
# this ensures that everyone gets their last turn
last_round_initiator = self.bots_per_game

# make sure that all bots get their last round
for index, bot in enumerate(game_bots[:last_round_initiator]):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

# calculate which bots have the highest score
max_score = max(game_scores)
nr_of_winners = 0
for i in range(self.bots_per_game):
bot_name = game_bots[i].__class__.__name__
# average score per bot
self.highscore[bot_name][1] += game_scores[i]
if self.highscore[bot_name][0] < game_scores[i]:
# maximum score per bot
self.highscore[bot_name][0] = game_scores[i]
if game_scores[i] == max_score:
# average winning score per bot
self.highscore[bot_name][2] += game_scores[i]
nr_of_winners += 1
self.wins[bot_name] += 1
if nr_of_winners > 1:
self.tied_games += 1
self.total_rounds += round_number
self.highest_round = max(self.highest_round, round_number)

def single_bot(self, index, bot, game_scores, last_round):
"""Simulates a single round for one bot

Keyword arguments:
index -- The player index of the bot (e.g. 0 if the bot goes first)
bot -- The bot object about to be simulated
game_scores -- A list of ints containing the scores of all players
last_round -- Boolean describing whether it is currently the last round
"""

current_throws = [self.throw_die()]
if current_throws[-1] != 6:

bot.update_state(current_throws[:])
for throw in bot.make_throw(game_scores, last_round):
# send the last die cast to the bot
if not throw:
break
current_throws.append(self.throw_die())
if current_throws[-1] == 6:
break
bot.update_state(current_throws[:])

if current_throws[-1] == 6:
# reset total score if running total is above end_score
if game_scores[index] + sum(current_throws) - 6 >= self.end_score:
game_scores[index] = 0
else:
# add to total score if no 6 is cast
game_scores[index] += sum(current_throws)

if DEBUG:
desc = "%d: Bot %24s plays %40s with " +
"scores %30s and last round == %5s"
print(desc % (index, bot.__class__.__name__,
current_throws, game_scores, last_round))

bot_name = bot.__class__.__name__
# average throws per round
self.highscore[bot_name][3] += len(current_throws)
# average success rate per round
self.highscore[bot_name][4] += int(current_throws[-1] != 6)
# total number of rounds
self.highscore[bot_name][5] += 1


# Collects all stats for the thread, so they can be summed up later
def collect_results(self):
self.bot_stats = {
bot.__name__: [
self.wins[bot.__name__],
self.played_games[bot.__name__],
self.highscore[bot.__name__]
]
for bot in self.bots}


#
def print_results(total_bot_stats, total_game_stats, elapsed_time):
"""Print the high score after the simulation

Keyword arguments:
total_bot_stats -- A list containing the winning stats for each thread
total_game_stats -- A list containing controller stats for each thread
elapsed_time -- The number of seconds that it took to run the simulation
"""

# Find the name of each bot, the number of wins, the number
# of played games, and the win percentage
wins = defaultdict(int)
played_games = defaultdict(int)
highscores = defaultdict(lambda: [0, 0, 0, 0, 0, 0])
bots = set()
timed_out_games = sum(s[0] for s in total_game_stats)
tied_games = sum(s[1] for s in total_game_stats)
total_games = sum(s[2] for s in total_game_stats)
total_rounds = sum(s[4] for s in total_game_stats)
highest_round = max(s[5] for s in total_game_stats)
average_rounds = total_rounds / total_games
bot_timings = defaultdict(float)

for thread in total_bot_stats:
for bot, stats in thread.items():
wins[bot] += stats[0]
played_games[bot] += stats[1]

highscores[bot][0] = max(highscores[bot][0], stats[2][0])
for i in range(1, 6):
highscores[bot][i] += stats[2][i]
bots.add(bot)

for bot in bots:
bot_timings[bot] += sum(s[3][bot] for s in total_game_stats)

bot_stats = [[bot, wins[bot], played_games[bot], 0] for bot in bots]

for i, bot in enumerate(bot_stats):
bot[3] = 100 * bot[1] / bot[2] if bot[2] > 0 else 0
bot_stats[i] = tuple(bot)

# Sort the bots by their winning percentage
sorted_scores = sorted(bot_stats, key=lambda x: x[3], reverse=True)
# Find the longest class name for any bot
max_len = max([len(b[0]) for b in bot_stats])

# Print the highscore list
if ANSI:
print_str(0, 9 + threads, "")
else:
print("n")

sim_msg = "tSimulation or %d games between %d bots " +
"completed in %.1f seconds"
print(sim_msg % (total_games, len(bots), elapsed_time))
print("tEach game lasted for an average of %.2f rounds" % average_rounds)
print("t%d games were tied between two or more bots" % tied_games)
print("t%d games ran until the round limit, highest round was %dn"
% (timed_out_games, highest_round))

print_bot_stats(sorted_scores, max_len, highscores)
print_time_stats(bot_timings, max_len)


def print_bot_stats(sorted_scores, max_len, highscores):
"""Print the stats for the bots

Keyword arguments:
sorted_scores -- A list containing the bots in sorted order
max_len -- The maximum name length for all bots
highscores -- A dict with additional stats for each bot
"""
delimiter_format = "t+%s%s+%s+%s+%s+%s+%s+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "", "-"*4, "-"*8,
"-"*8, "-"*6, "-"*6, "-"*7, "-"*6, "-"*8)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)
print("t|%s%s|%4s|%8s|%8s|%6s|%6s|%7s|%6s|%8s|"
% ("Bot", " "*(max_len-3), "Win%", "Wins",
"Played", "Max", "Avg", "Avg win", "Throws", "Success%"))
print(delimiter_str)

for bot, wins, played, score in sorted_scores:
highscore = highscores[bot]
bot_max_score = highscore[0]
bot_avg_score = highscore[1] / played
bot_avg_win_score = highscore[2] / max(1, wins)
bot_avg_throws = highscore[3] / highscore[5]
bot_success_rate = 100 * highscore[4] / highscore[5]

space_fill = " "*(max_len-len(bot))
format_str = "t|%s%s|%4.1f|%8d|%8d|%6d|%6.2f|%7.2f|%6.2f|%8.2f|"
format_arguments = (bot, space_fill, score, wins,
played, bot_max_score, bot_avg_score,
bot_avg_win_score, bot_avg_throws, bot_success_rate)
print(format_str % format_arguments)

print(delimiter_str)
print()

def print_time_stats(bot_timings, max_len):
"""Print the execution time for all bots

Keyword arguments:
bot_timings -- A dict containing information about timings for each bot
max_len -- The maximum name length for all bots
"""
total_time = sum(bot_timings.values())
sorted_times = sorted(bot_timings.items(),
key=lambda x: x[1], reverse = True)

delimiter_format = "t+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "-"*5, "-"*5)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)

print("t|%s%s|%5s|%5s|" % ("Bot", " "*(max_len-3), "Time", "Time%"))
print(delimiter_str)
for bot, bot_time in sorted_times:
space_fill = " "*(max_len-len(bot))
perc = 100 * bot_time / total_time
print("t|%s%s|%5.2f|%5.1f|" % (bot, space_fill, bot_time, perc))
print(delimiter_str)
print()


def run_simulation(thread_id, bots_per_game, games_per_thread, bots):
"""Used by multithreading to run the simulation in parallel

Keyword arguments:
thread_id -- A unique identifier for each thread, starting at 0
bots_per_game -- How many bots should participate in each game
games_per_thread -- The number of games to be simulated
bots -- A list of all bot classes available
"""
try:
controller = Controller(bots_per_game,
games_per_thread, bots, thread_id)
controller.simulate_games()
controller_stats = (
controller.timed_out_games,
controller.tied_games,
controller.games,
controller.bot_timings,
controller.total_rounds,
controller.highest_round
)
return (controller.bot_stats, controller_stats)
except KeyboardInterrupt:
return {}


# Prints the help for the script
def print_help():
print("nThis is the controller for the PPCG KotH challenge " +
"'A game of dice, but avoid number 6'")
print("For any question, send a message to maxbn")
print("Usage: python %s [OPTIONS]" % sys.argv[0])
print("n -nttthe number of games to simluate")
print(" -bttthe number of bots per round")
print(" -tttthe number of threads")
print(" -At--ansitrun in ANSI mode, with prettier printing")
print(" -Dt--debugtrun in debug mode. Sets to 1 thread, 1 game")
print(" -ht--helptshow this helpn")

if __name__ == "__main__":

bots = get_all_bots()
games = 10000
bots_per_game = 8
threads = 4

for i, arg in enumerate(sys.argv):
if arg == "-n" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
games = int(sys.argv[i+1])
if arg == "-b" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
bots_per_game = int(sys.argv[i+1])
if arg == "-t" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
threads = int(sys.argv[i+1])
if arg == "-A" or arg == "--ansi":
ANSI = True
if arg == "-D" or arg == "--debug":
DEBUG = True
if arg == "-h" or arg == "--help":
print_help()
quit()
if ANSI:
print(chr(27) + "[2J", flush = True)
print_str(1,3,"")
else:
print()

if bots_per_game > len(bots):
bots_per_game = len(bots)
if bots_per_game < 2:
print("tAt least 2 bots per game is needed")
bots_per_game = 2
if games <= 0:
print("tAt least 1 game is needed")
games = 1
if threads <= 0:
print("tAt least 1 thread is needed")
threads = 1
if DEBUG:
print("tRunning in debug mode, with 1 thread and 1 game")
threads = 1
games = 1

games_per_thread = math.ceil(games / threads)

print("tStarting simulation with %d bots" % len(bots))
sim_str = "tSimulating %d games with %d bots per game"
print(sim_str % (games, bots_per_game))
print("tRunning simulation on %d threads" % threads)
if len(sys.argv) == 1:
print("tFor help running the script, use the -h flag")
print()
with Pool(threads) as pool:
t0 = time.time()
results = pool.starmap(
run_simulation,
[(i, bots_per_game, games_per_thread, bots) for i in range(threads)]
)
t1 = time.time()
if not DEBUG:
total_bot_stats = [r[0] for r in results]
total_game_stats = [r[1] for r in results]
print_results(total_bot_stats, total_game_stats, t1-t0)


If you want access to the original controller for this challenge, it is available in the edit history. The new controller has the exact same logic for running the game, the only difference is performance, stat collection and prettier printing.



Bots



On my machine, the bots are kept in the file forty_game_bots.py. If you use any other name for the file, you must update the import statement at the top of the controller.



import sys, inspect

# Returns a list of all bot classes which inherit from the Bot class
def get_all_bots():
bots =
current_module = sys.modules[__name__]
for name, obj in inspect.getmembers(current_module, inspect.isclass):
if name != "Bot":
bots.append(obj)
return bots


# The parent class for all bots
class Bot:

def __init__(self, index, end_score):
self.index = index
self.end_score = end_score

def update_state(self, current_throws):
self.current_throws = current_throws

def make_throw(self, scores, last_round):
yield False


class ThrowTwiceBot(Bot):

def make_throw(self, scores, last_round):
yield True
yield False

class GoToTenBot(Bot):

def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


Running the simulation



To run a simulation, save both code snippets posted above to two separate files. I have saved them as forty_game_controller.py and forty_game_bots.py. Then you simply use python forty_game_controller.py or python3 forty_game_controller.py depending on your Python configuration. Follow the instructions from there if you want to configure your simulation further, or try tinkering with the code if you want.



Game stats



If you're making a bot that aims for a certain score without taking other bots into consideration, these are the winning score percentiles:



+----------+-----+
|Percentile|Score|
+----------+-----+
| 50.00| 44|
| 75.00| 47|
| 90.00| 51|
| 95.00| 53|
| 99.00| 58|
| 99.90| 67|
| 99.99| 154|
+----------+-----+


Highscores



As more answers are posted, I'll try to keep this list updated. The contents of the list will always be from the latest simulation. The bots ThrowTwiceBot and GoToTenBot are the bots from the code above, and are used as reference. I did a simulation with 10^8 games, which took about 1 hour. Then I saw that the game reached stability compared to my runs with 10^7 games. However, with people still posting bots, I won't do any longer simulations until the frequency of responses has gone down.



I try to add all new bots and add any changes that you've made to existing bots. If it seems that I have missed your bot or any new changes you have, write in the chat and I'll make sure to have your very latest version in the next simulation.



We now have more stats for each bot thanks to AKroell! The three new columns contain the maximum score across all games, the average score per game, and the average score when winning for each bot.



As pointed out in the comments, there was an issue with the game logic which made bots that had a higher index within a game get an extra round in some cases. This has been fixed now, and the scores below reflect this.



The bot NeoBot does follow the rules, but uses a loophole by predicting the random generator. Since this bot takes a lot of resources to simulate, I have added its stats from a simulation with fewer games.



Simulation or 10000008 games between 44 bots completed in 526.5 seconds
Each game lasted for an average of 3.74 rounds
789768 games were tied between two or more bots
0 games ran until the round limit, highest round was 16

+-----------------------+----+--------+--------+------+------+-------+------+--------+
|Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
+-----------------------+----+--------+--------+------+------+-------+------+--------+
|NeoBot |51.7| 91960| 177998| 232| 45.75| 59.09| 5.10| 82.32|
|OptFor2 |22.6| 409924| 1817383| 85| 20.73| 44.12| 4.00| 33.31|
|EnsureLead |21.7| 395380| 1819194| 87| 20.58| 43.93| 4.49| 25.17|
|StepBot |21.5| 390379| 1815804| 96| 20.53| 43.34| 4.55| 24.18|
|Roll6Timesv2 |21.2| 386196| 1818792| 83| 20.93| 43.39| 4.37| 27.19|
|QuotaBot |21.2| 385746| 1817957| 84| 20.04| 44.84| 4.49| 25.06|
|BinaryBot |21.2| 385007| 1818590| 92| 21.11| 44.30| 3.84| 36.07|
|AggressiveStalker |21.1| 384644| 1819062| 89| 20.69| 44.63| 3.87| 35.46|
|AdaptiveRoller |21.1| 383113| 1817671| 83| 20.80| 43.13| 4.51| 24.87|
|GoTo20Bot |21.0| 381738| 1817765| 92| 21.26| 43.11| 4.44| 26.02|
|FooBot |21.0| 381595| 1817169| 96| 22.11| 43.62| 3.91| 34.87|
|Hesitate |20.9| 380648| 1818690| 84| 21.18| 44.73| 3.90| 34.93|
|GoTo20orBestBot |20.7| 376929| 1816632| 81| 21.08| 43.96| 4.45| 25.79|
|LastRound |20.6| 374936| 1817918| 79| 20.71| 43.34| 4.17| 30.41|
|BePrepared |20.6| 374313| 1816897| 89| 18.69| 47.64| 4.30| 28.34|
|Stalker |20.5| 372315| 1818032| 87| 20.42| 45.12| 3.78| 37.02|
|FortyTeen |19.9| 361996| 1819512| 88| 21.00| 46.63| 3.88| 35.40|
|Chaser |19.8| 359311| 1816875| 84| 19.79| 45.49| 4.02| 33.03|
|Crush |19.5| 354384| 1818530| 83| 14.72| 42.91| 5.18| 13.58|
|ClunkyChicken |19.1| 347610| 1817492| 84| 21.17| 45.40| 3.30| 45.07|
|RollForLuckBot |17.2| 312147| 1818033| 97| 17.44| 50.34| 4.72| 21.38|
|TakeFive |17.1| 310446| 1817875| 82| 19.45| 44.50| 3.36| 44.03|
|Alpha |16.3| 296175| 1818779| 92| 17.70| 46.64| 4.00| 33.41|
|LeadBy5Bot |16.0| 290738| 1817308| 98| 17.40| 46.91| 4.08| 32.06|
|GoHomeBot |15.9| 289799| 1819228| 44| 13.27| 41.41| 5.49| 8.53|
|NotTooFarBehindBot |15.7| 285797| 1819208| 90| 18.01| 44.86| 2.97| 50.49|
|GoToSeventeenRollTenBot|14.6| 265503| 1818265| 98| 10.28| 49.21| 5.68| 5.42|
|LizduadacBot |14.5| 263436| 1819146| 78| 9.70| 51.35| 5.72| 4.69|
|BringMyOwn_dice |12.9| 234752| 1817897| 44| 21.34| 41.47| 4.24| 29.33|
|ExpectationsBot | 9.7| 176728| 1819545| 44| 24.42| 41.55| 3.57| 40.40|
|OneStepAheadBot | 9.0| 162878| 1816973| 50| 18.25| 46.01| 3.20| 46.57|
|GoToTenBot | 7.6| 137751| 1820991| 53| 22.98| 45.47| 2.95| 50.92|
|GoBigEarly | 7.0| 127587| 1818227| 49| 20.79| 42.96| 3.90| 35.07|
|MatchLeaderBot | 6.6| 119331| 1818999| 85| 19.80| 41.95| 3.10| 48.31|
|OneInFiveBot | 6.1| 110361| 1820426| 154| 17.28| 49.57| 3.00| 50.04|
|ThrowThriceBot | 4.3| 78694| 1816318| 54| 21.71| 44.55| 2.53| 57.90|
|FutureBot | 4.3| 78383| 1817617| 50| 17.94| 45.16| 2.36| 60.68|
|SlowStart | 2.5| 44643| 1818002| 67| 16.43| 47.49| 1.81| 69.81|
|GamblersFallacy | 1.3| 24385| 1817723| 44| 22.54| 41.50| 2.81| 53.14|
|ThrowTwiceBot | 0.8| 14613| 1816817| 49| 18.08| 43.15| 1.83| 69.43|
|FlipCoinRollDice | 0.7| 13421| 1818027| 74| 15.31| 44.54| 1.61| 73.19|
|BlessRNG | 0.1| 2652| 1819312| 49| 14.55| 42.80| 1.42| 76.37|
|BrainBot | 0.0| 28| 1816964| 44| 10.93| 41.29| 1.00| 83.33|
|StopBot | 0.0| 20| 1819486| 44| 10.94| 41.65| 1.00| 83.34|
|PointsAreForNerdsBot | 0.0| 0| 1818933| 0| 0.00| 0.00| 6.00| 0.00|
+-----------------------+----+--------+--------+------+------+-------+------+--------+









share|improve this question




















  • 2




    So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
    – aschepler
    Dec 19 at 22:15






  • 1




    @aschepler that's a good formulation, I'll edit the post when I'm on my computer
    – maxb
    Dec 20 at 5:13






  • 2




    @maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
    – AKroell
    Dec 20 at 12:49






  • 1




    @AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
    – maxb
    Dec 20 at 12:58






  • 2




    This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
    – Caleb Jay
    Dec 20 at 19:02
















54














Dice



I was invited to play a game of dice which I had never heard of. The rules were simple, yet I think it would be perfect for a KotH challenge.



The rules



The start of the game



The die goes around the table, and each time it is your turn, you get to throw the die as many times as you want. However, you have to throw it at least once. You keep track of the sum of all throws for your round. If you choose to stop, the score for the round is added to your total score.



So why would you ever stop throwing the die? Because if you get 6, your score for the entire round becomes zero, and the die is passed on. Thus, the initial goal is to increase your score as quickly as possible.



Who is the winner?



When the first player around the table reaches 40 points or more, the last round starts. Once the last round has started, everyone except the person who initiated the last round gets one more turn.



The rules for the last round is the same as for any other round. You choose to keep throwing or to stop. However, you know that you have no chance of winning if you don't get a higher score than those before you on the last round. But if you keep going too far, then you might get a 6.



However, there's one more rule to take into consideration. If your current total score (your previous score + your current score for the round) is 40 or more, and you hit a 6, your total score is set to 0. That means that you have to start all over. If you hit a 6 when your current total score is 40 or more, the game continues as normal, except that you're now in last place. The last round is not triggered when your total score is reset. You could still win the round, but it does become more challenging.



The winner is the player with the highest score once the last round is over. If two or more players share the same score, they will all be counted as victors.



An added rule is that the game continues for a maximum of 200 rounds. This is to prevent cases where multiple bots basically keep throwing until they hit 6 to stay at their current score. Once the 199th round is passed, last_round is set to true, and one more round is played. If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.



Recap




  • Each round you keep throwing the die until you choose to stop or you get a 6

  • You must throw the die once (if your first throw is a 6, your round is immediately over)

  • If you get a 6, your current score is set to 0 (not your total score)

  • You add your current score to your total score after each round

  • When a bot ends their turn resulting in a total score of at least 40, everyone else gets a last turn

  • If your current total score is $geq 40$ and you get a 6, your total score is set to 0 and your round is over

  • The last round is not triggered when the above occurs

  • The person with the highest total score after the last round is the winner

  • In case there are multiple winners, all will be counted as winners

  • The game lasts for a maximum of 200 rounds


Clarification of the scores




  • Total score: the score that you have saved from previous rounds

  • Current score: the score for the current round

  • Current total score: the sum of the two scores above


How do you participate



To participate in this KotH challenge, you should write a Python class which inherits from Bot. You should implement the function: make_throw(self, scores, last_round). That function will be called once it is your turn, and your first throw was not a 6. To keep throwing, you should yield True. To stop throwing, you should yield False. After each throw, the parent function update_state is called. Thus, you have access to your throws for the current round using the variable self.current_throws. You also have access to your own index using self.index. Thus, to see your own total score you would use scores[self.index]. You could also access the end_score for the game by using self.end_score, but you can safely assume that it will be 40 for this challenge.



You are allowed to create helper functions inside your class. You may also override functions existing in the Bot parent class, e.g. if you want to add more class properties. You are not allowed to modify the state of the game in any way except yielding True or False.



You're free to seek inspiration from this post, and copy any of the two bots that I've included here. However, I'm afraid that they're not particularly effective...



On allowing other languages



In both the sandbox and on The Nineteenth Byte, we have had discussions about allowing submissions in other languages. After reading about such implementations, and hearing arguments from both sides, I have decided to restrict this challenge to Python only. This is due to two factors: the time required to support multiple languages, and the randomness of this challenge requiring a high number of iterations to reach stability. I hope that you will still participate, and if you want to learn some Python for this challenge, I'll try to be available in the chat as often as possible.



For any questions that you might have, you can write in the chat room for this challenge. See you there!



Rules




  • Sabotage is allowed, and encouraged. That is, sabotage against other players

  • Any attempt to tinker with the controller, runtime or other submissions will be disqualified. All submissions should only work with the inputs and storage they are given.

  • Any bot which uses more than 500MB memory to make its decision will be disqualified (if you need that much memory you should rethink your choices)

  • A bot must not implement the exact same strategy as an existing one, intentionally or accidentally.

  • You are allowed to update your bot during the time of the challenge. However, you could also post another bot if your approach is different.


Example



class GoToTenBot(Bot):
def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


This bot will keep going until it has a score of at least 10 for the round, or it throws a 6. Note that you don't need any logic to handle throwing 6. Also note that if your first throw is a 6, make_throw is never called, since your round is immediately over.



For those who are new to Python (and new to the yield concept), but want to give this a go, the yield keyword is similar to a return in some ways, but different in other ways. You can read about the concept here. Basically, once you yield, your function will stop, and the value you yielded will be sent back to the controller. There, the controller handles its logic until it is time for your bot to make another decision. Then the controller sends you the dice throw, and your make_throw function will continue executing right where if stopped before, basically on the line after the previous yield statement.



This way, the game controller can update the state without requiring a separate bot function call for each dice throw.



Specification



You may use any Python library available in pip. To ensure that I'll be able to get a good average, you have a 100 millisecond time limit per round. I'd be really happy if your script was way faster than that, so that I can run more rounds.



Evaluation



To find the winner, I will take all bots and run them in random groups of 8. If there are fewer than 8 classes submitted, I will run them in random groups of 4 to avoid always having all bots in each round. I will run simulations for about 8 hours, and the winner will be the bot with the highest win percentage. I will run start the final simulations at the start of 2019, giving you all Christmas to code your bots! The preliminary final date is January 4th, but if that's too little time I can change it to a later date.



Until then, I'll try to make a daily simulation using 30-60 minutes of CPU time, and updating the score board. This will not be the official score, but it will serve as a guide to see which bots perform the best. However, with Christmas coming up, I hope you can understand that I won't be available at all times. I'll do my best to run simulations and answer any questions related to the challenge.



Test it yourself



If you want to run your own simulations, here's the full code to the controller running the simulation, including two example bots.



Controller



Here's the updated controller for this challenge. It supports ANSI outputs, multi-threading, and collects additional stats thanks to AKroell! When I make changes to the controller, I'll update the post once documentation is complete.



import random
import time
import math
import sys
from multiprocessing import Pool
from collections import defaultdict
# Importing all the bots
from forty_game_bots import *

# If you want to see what each bot decides, set this to true
# Should only be used with one thread and one game
DEBUG = False
# If your terminal supports ANSI, try setting this to true
ANSI = False

def print_str(x, y, string):
print("33["+str(y)+";"+str(x)+"H"+string, end = "", flush = True)

class bcolors:
WHITE = '33[0m'
GREEN = '33[92m'
BLUE = '33[94m'
YELLOW = '33[93m'
RED = '33[91m'
ENDC = '33[0m'

# Class for handling the game logic and relaying information to the bots
class Controller:

def __init__(self, bots_per_game, games, bots, thread_id):
"""Initiates all fields relevant to the simulation

Keyword arguments:
bots_per_game -- the number of bots that should be included in a game
games -- the number of games that should be simulated
bots -- a list of all available bot classes
"""
self.bots_per_game = bots_per_game
self.games = games
self.bots = bots
self.number_of_bots = len(self.bots)
self.wins = defaultdict(int)
self.played_games = defaultdict(int)
self.bot_timings = defaultdict(float)
# self.wins = {bot.__name__: 0 for bot in self.bots}
# self.played_games = {bot.__name__: 0 for bot in self.bots}
self.end_score = 40
self.thread_id = thread_id
self.max_rounds = 200
self.timed_out_games = 0
self.tied_games = 0
self.total_rounds = 0
self.highest_round = 0
#max, avg, avg_win, throws, success, rounds
self.highscore = defaultdict(lambda:[0, 0, 0, 0, 0, 0])
# self.highscore = {bot.__name__: [0, 0, 0] for bot in self.bots}

# Returns a fair dice throw
def throw_die(self):
return random.randint(1,6)
# Print the current game number without newline
def print_progress(self, progress):
length = 50
filled = int(progress*length)
fill = "="*filled
space = " "*(length-filled)
perc = int(100*progress)
if ANSI:
col = [
bcolors.RED,
bcolors.YELLOW,
bcolors.WHITE,
bcolors.BLUE,
bcolors.GREEN
][int(progress*4)]

end = bcolors.ENDC
print_str(5, 8 + self.thread_id,
"t%s[%s%s] %3d%%%s" % (col, fill, space, perc, end)
)
else:
print(
"rt[%s%s] %3d%%" % (fill, space, perc),
flush = True,
end = ""
)

# Handles selecting bots for each game, and counting how many times
# each bot has participated in a game
def simulate_games(self):
for game in range(self.games):
if self.games > 100:
if game % (self.games // 100) == 0 and not DEBUG:
if self.thread_id == 0 or ANSI:
progress = (game+1) / self.games
self.print_progress(progress)
game_bot_indices = random.sample(
range(self.number_of_bots),
self.bots_per_game
)

game_bots = [None for _ in range(self.bots_per_game)]
for i, bot_index in enumerate(game_bot_indices):
self.played_games[self.bots[bot_index].__name__] += 1
game_bots[i] = self.bots[bot_index](i, self.end_score)

self.play(game_bots)
if not DEBUG and (ANSI or self.thread_id == 0):
self.print_progress(1)

self.collect_results()

def play(self, game_bots):
"""Simulates a single game between the bots present in game_bots

Keyword arguments:
game_bots -- A list of instantiated bot objects for the game
"""
last_round = False
last_round_initiator = -1
round_number = 0
game_scores = [0 for _ in range(self.bots_per_game)]


# continue until one bot has reached end_score points
while not last_round:
for index, bot in enumerate(game_bots):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

if game_scores[index] >= self.end_score and not last_round:
last_round = True
last_round_initiator = index
round_number += 1

# maximum of 200 rounds per game
if round_number > self.max_rounds - 1:
last_round = True
self.timed_out_games += 1
# this ensures that everyone gets their last turn
last_round_initiator = self.bots_per_game

# make sure that all bots get their last round
for index, bot in enumerate(game_bots[:last_round_initiator]):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

# calculate which bots have the highest score
max_score = max(game_scores)
nr_of_winners = 0
for i in range(self.bots_per_game):
bot_name = game_bots[i].__class__.__name__
# average score per bot
self.highscore[bot_name][1] += game_scores[i]
if self.highscore[bot_name][0] < game_scores[i]:
# maximum score per bot
self.highscore[bot_name][0] = game_scores[i]
if game_scores[i] == max_score:
# average winning score per bot
self.highscore[bot_name][2] += game_scores[i]
nr_of_winners += 1
self.wins[bot_name] += 1
if nr_of_winners > 1:
self.tied_games += 1
self.total_rounds += round_number
self.highest_round = max(self.highest_round, round_number)

def single_bot(self, index, bot, game_scores, last_round):
"""Simulates a single round for one bot

Keyword arguments:
index -- The player index of the bot (e.g. 0 if the bot goes first)
bot -- The bot object about to be simulated
game_scores -- A list of ints containing the scores of all players
last_round -- Boolean describing whether it is currently the last round
"""

current_throws = [self.throw_die()]
if current_throws[-1] != 6:

bot.update_state(current_throws[:])
for throw in bot.make_throw(game_scores, last_round):
# send the last die cast to the bot
if not throw:
break
current_throws.append(self.throw_die())
if current_throws[-1] == 6:
break
bot.update_state(current_throws[:])

if current_throws[-1] == 6:
# reset total score if running total is above end_score
if game_scores[index] + sum(current_throws) - 6 >= self.end_score:
game_scores[index] = 0
else:
# add to total score if no 6 is cast
game_scores[index] += sum(current_throws)

if DEBUG:
desc = "%d: Bot %24s plays %40s with " +
"scores %30s and last round == %5s"
print(desc % (index, bot.__class__.__name__,
current_throws, game_scores, last_round))

bot_name = bot.__class__.__name__
# average throws per round
self.highscore[bot_name][3] += len(current_throws)
# average success rate per round
self.highscore[bot_name][4] += int(current_throws[-1] != 6)
# total number of rounds
self.highscore[bot_name][5] += 1


# Collects all stats for the thread, so they can be summed up later
def collect_results(self):
self.bot_stats = {
bot.__name__: [
self.wins[bot.__name__],
self.played_games[bot.__name__],
self.highscore[bot.__name__]
]
for bot in self.bots}


#
def print_results(total_bot_stats, total_game_stats, elapsed_time):
"""Print the high score after the simulation

Keyword arguments:
total_bot_stats -- A list containing the winning stats for each thread
total_game_stats -- A list containing controller stats for each thread
elapsed_time -- The number of seconds that it took to run the simulation
"""

# Find the name of each bot, the number of wins, the number
# of played games, and the win percentage
wins = defaultdict(int)
played_games = defaultdict(int)
highscores = defaultdict(lambda: [0, 0, 0, 0, 0, 0])
bots = set()
timed_out_games = sum(s[0] for s in total_game_stats)
tied_games = sum(s[1] for s in total_game_stats)
total_games = sum(s[2] for s in total_game_stats)
total_rounds = sum(s[4] for s in total_game_stats)
highest_round = max(s[5] for s in total_game_stats)
average_rounds = total_rounds / total_games
bot_timings = defaultdict(float)

for thread in total_bot_stats:
for bot, stats in thread.items():
wins[bot] += stats[0]
played_games[bot] += stats[1]

highscores[bot][0] = max(highscores[bot][0], stats[2][0])
for i in range(1, 6):
highscores[bot][i] += stats[2][i]
bots.add(bot)

for bot in bots:
bot_timings[bot] += sum(s[3][bot] for s in total_game_stats)

bot_stats = [[bot, wins[bot], played_games[bot], 0] for bot in bots]

for i, bot in enumerate(bot_stats):
bot[3] = 100 * bot[1] / bot[2] if bot[2] > 0 else 0
bot_stats[i] = tuple(bot)

# Sort the bots by their winning percentage
sorted_scores = sorted(bot_stats, key=lambda x: x[3], reverse=True)
# Find the longest class name for any bot
max_len = max([len(b[0]) for b in bot_stats])

# Print the highscore list
if ANSI:
print_str(0, 9 + threads, "")
else:
print("n")

sim_msg = "tSimulation or %d games between %d bots " +
"completed in %.1f seconds"
print(sim_msg % (total_games, len(bots), elapsed_time))
print("tEach game lasted for an average of %.2f rounds" % average_rounds)
print("t%d games were tied between two or more bots" % tied_games)
print("t%d games ran until the round limit, highest round was %dn"
% (timed_out_games, highest_round))

print_bot_stats(sorted_scores, max_len, highscores)
print_time_stats(bot_timings, max_len)


def print_bot_stats(sorted_scores, max_len, highscores):
"""Print the stats for the bots

Keyword arguments:
sorted_scores -- A list containing the bots in sorted order
max_len -- The maximum name length for all bots
highscores -- A dict with additional stats for each bot
"""
delimiter_format = "t+%s%s+%s+%s+%s+%s+%s+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "", "-"*4, "-"*8,
"-"*8, "-"*6, "-"*6, "-"*7, "-"*6, "-"*8)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)
print("t|%s%s|%4s|%8s|%8s|%6s|%6s|%7s|%6s|%8s|"
% ("Bot", " "*(max_len-3), "Win%", "Wins",
"Played", "Max", "Avg", "Avg win", "Throws", "Success%"))
print(delimiter_str)

for bot, wins, played, score in sorted_scores:
highscore = highscores[bot]
bot_max_score = highscore[0]
bot_avg_score = highscore[1] / played
bot_avg_win_score = highscore[2] / max(1, wins)
bot_avg_throws = highscore[3] / highscore[5]
bot_success_rate = 100 * highscore[4] / highscore[5]

space_fill = " "*(max_len-len(bot))
format_str = "t|%s%s|%4.1f|%8d|%8d|%6d|%6.2f|%7.2f|%6.2f|%8.2f|"
format_arguments = (bot, space_fill, score, wins,
played, bot_max_score, bot_avg_score,
bot_avg_win_score, bot_avg_throws, bot_success_rate)
print(format_str % format_arguments)

print(delimiter_str)
print()

def print_time_stats(bot_timings, max_len):
"""Print the execution time for all bots

Keyword arguments:
bot_timings -- A dict containing information about timings for each bot
max_len -- The maximum name length for all bots
"""
total_time = sum(bot_timings.values())
sorted_times = sorted(bot_timings.items(),
key=lambda x: x[1], reverse = True)

delimiter_format = "t+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "-"*5, "-"*5)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)

print("t|%s%s|%5s|%5s|" % ("Bot", " "*(max_len-3), "Time", "Time%"))
print(delimiter_str)
for bot, bot_time in sorted_times:
space_fill = " "*(max_len-len(bot))
perc = 100 * bot_time / total_time
print("t|%s%s|%5.2f|%5.1f|" % (bot, space_fill, bot_time, perc))
print(delimiter_str)
print()


def run_simulation(thread_id, bots_per_game, games_per_thread, bots):
"""Used by multithreading to run the simulation in parallel

Keyword arguments:
thread_id -- A unique identifier for each thread, starting at 0
bots_per_game -- How many bots should participate in each game
games_per_thread -- The number of games to be simulated
bots -- A list of all bot classes available
"""
try:
controller = Controller(bots_per_game,
games_per_thread, bots, thread_id)
controller.simulate_games()
controller_stats = (
controller.timed_out_games,
controller.tied_games,
controller.games,
controller.bot_timings,
controller.total_rounds,
controller.highest_round
)
return (controller.bot_stats, controller_stats)
except KeyboardInterrupt:
return {}


# Prints the help for the script
def print_help():
print("nThis is the controller for the PPCG KotH challenge " +
"'A game of dice, but avoid number 6'")
print("For any question, send a message to maxbn")
print("Usage: python %s [OPTIONS]" % sys.argv[0])
print("n -nttthe number of games to simluate")
print(" -bttthe number of bots per round")
print(" -tttthe number of threads")
print(" -At--ansitrun in ANSI mode, with prettier printing")
print(" -Dt--debugtrun in debug mode. Sets to 1 thread, 1 game")
print(" -ht--helptshow this helpn")

if __name__ == "__main__":

bots = get_all_bots()
games = 10000
bots_per_game = 8
threads = 4

for i, arg in enumerate(sys.argv):
if arg == "-n" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
games = int(sys.argv[i+1])
if arg == "-b" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
bots_per_game = int(sys.argv[i+1])
if arg == "-t" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
threads = int(sys.argv[i+1])
if arg == "-A" or arg == "--ansi":
ANSI = True
if arg == "-D" or arg == "--debug":
DEBUG = True
if arg == "-h" or arg == "--help":
print_help()
quit()
if ANSI:
print(chr(27) + "[2J", flush = True)
print_str(1,3,"")
else:
print()

if bots_per_game > len(bots):
bots_per_game = len(bots)
if bots_per_game < 2:
print("tAt least 2 bots per game is needed")
bots_per_game = 2
if games <= 0:
print("tAt least 1 game is needed")
games = 1
if threads <= 0:
print("tAt least 1 thread is needed")
threads = 1
if DEBUG:
print("tRunning in debug mode, with 1 thread and 1 game")
threads = 1
games = 1

games_per_thread = math.ceil(games / threads)

print("tStarting simulation with %d bots" % len(bots))
sim_str = "tSimulating %d games with %d bots per game"
print(sim_str % (games, bots_per_game))
print("tRunning simulation on %d threads" % threads)
if len(sys.argv) == 1:
print("tFor help running the script, use the -h flag")
print()
with Pool(threads) as pool:
t0 = time.time()
results = pool.starmap(
run_simulation,
[(i, bots_per_game, games_per_thread, bots) for i in range(threads)]
)
t1 = time.time()
if not DEBUG:
total_bot_stats = [r[0] for r in results]
total_game_stats = [r[1] for r in results]
print_results(total_bot_stats, total_game_stats, t1-t0)


If you want access to the original controller for this challenge, it is available in the edit history. The new controller has the exact same logic for running the game, the only difference is performance, stat collection and prettier printing.



Bots



On my machine, the bots are kept in the file forty_game_bots.py. If you use any other name for the file, you must update the import statement at the top of the controller.



import sys, inspect

# Returns a list of all bot classes which inherit from the Bot class
def get_all_bots():
bots =
current_module = sys.modules[__name__]
for name, obj in inspect.getmembers(current_module, inspect.isclass):
if name != "Bot":
bots.append(obj)
return bots


# The parent class for all bots
class Bot:

def __init__(self, index, end_score):
self.index = index
self.end_score = end_score

def update_state(self, current_throws):
self.current_throws = current_throws

def make_throw(self, scores, last_round):
yield False


class ThrowTwiceBot(Bot):

def make_throw(self, scores, last_round):
yield True
yield False

class GoToTenBot(Bot):

def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


Running the simulation



To run a simulation, save both code snippets posted above to two separate files. I have saved them as forty_game_controller.py and forty_game_bots.py. Then you simply use python forty_game_controller.py or python3 forty_game_controller.py depending on your Python configuration. Follow the instructions from there if you want to configure your simulation further, or try tinkering with the code if you want.



Game stats



If you're making a bot that aims for a certain score without taking other bots into consideration, these are the winning score percentiles:



+----------+-----+
|Percentile|Score|
+----------+-----+
| 50.00| 44|
| 75.00| 47|
| 90.00| 51|
| 95.00| 53|
| 99.00| 58|
| 99.90| 67|
| 99.99| 154|
+----------+-----+


Highscores



As more answers are posted, I'll try to keep this list updated. The contents of the list will always be from the latest simulation. The bots ThrowTwiceBot and GoToTenBot are the bots from the code above, and are used as reference. I did a simulation with 10^8 games, which took about 1 hour. Then I saw that the game reached stability compared to my runs with 10^7 games. However, with people still posting bots, I won't do any longer simulations until the frequency of responses has gone down.



I try to add all new bots and add any changes that you've made to existing bots. If it seems that I have missed your bot or any new changes you have, write in the chat and I'll make sure to have your very latest version in the next simulation.



We now have more stats for each bot thanks to AKroell! The three new columns contain the maximum score across all games, the average score per game, and the average score when winning for each bot.



As pointed out in the comments, there was an issue with the game logic which made bots that had a higher index within a game get an extra round in some cases. This has been fixed now, and the scores below reflect this.



The bot NeoBot does follow the rules, but uses a loophole by predicting the random generator. Since this bot takes a lot of resources to simulate, I have added its stats from a simulation with fewer games.



Simulation or 10000008 games between 44 bots completed in 526.5 seconds
Each game lasted for an average of 3.74 rounds
789768 games were tied between two or more bots
0 games ran until the round limit, highest round was 16

+-----------------------+----+--------+--------+------+------+-------+------+--------+
|Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
+-----------------------+----+--------+--------+------+------+-------+------+--------+
|NeoBot |51.7| 91960| 177998| 232| 45.75| 59.09| 5.10| 82.32|
|OptFor2 |22.6| 409924| 1817383| 85| 20.73| 44.12| 4.00| 33.31|
|EnsureLead |21.7| 395380| 1819194| 87| 20.58| 43.93| 4.49| 25.17|
|StepBot |21.5| 390379| 1815804| 96| 20.53| 43.34| 4.55| 24.18|
|Roll6Timesv2 |21.2| 386196| 1818792| 83| 20.93| 43.39| 4.37| 27.19|
|QuotaBot |21.2| 385746| 1817957| 84| 20.04| 44.84| 4.49| 25.06|
|BinaryBot |21.2| 385007| 1818590| 92| 21.11| 44.30| 3.84| 36.07|
|AggressiveStalker |21.1| 384644| 1819062| 89| 20.69| 44.63| 3.87| 35.46|
|AdaptiveRoller |21.1| 383113| 1817671| 83| 20.80| 43.13| 4.51| 24.87|
|GoTo20Bot |21.0| 381738| 1817765| 92| 21.26| 43.11| 4.44| 26.02|
|FooBot |21.0| 381595| 1817169| 96| 22.11| 43.62| 3.91| 34.87|
|Hesitate |20.9| 380648| 1818690| 84| 21.18| 44.73| 3.90| 34.93|
|GoTo20orBestBot |20.7| 376929| 1816632| 81| 21.08| 43.96| 4.45| 25.79|
|LastRound |20.6| 374936| 1817918| 79| 20.71| 43.34| 4.17| 30.41|
|BePrepared |20.6| 374313| 1816897| 89| 18.69| 47.64| 4.30| 28.34|
|Stalker |20.5| 372315| 1818032| 87| 20.42| 45.12| 3.78| 37.02|
|FortyTeen |19.9| 361996| 1819512| 88| 21.00| 46.63| 3.88| 35.40|
|Chaser |19.8| 359311| 1816875| 84| 19.79| 45.49| 4.02| 33.03|
|Crush |19.5| 354384| 1818530| 83| 14.72| 42.91| 5.18| 13.58|
|ClunkyChicken |19.1| 347610| 1817492| 84| 21.17| 45.40| 3.30| 45.07|
|RollForLuckBot |17.2| 312147| 1818033| 97| 17.44| 50.34| 4.72| 21.38|
|TakeFive |17.1| 310446| 1817875| 82| 19.45| 44.50| 3.36| 44.03|
|Alpha |16.3| 296175| 1818779| 92| 17.70| 46.64| 4.00| 33.41|
|LeadBy5Bot |16.0| 290738| 1817308| 98| 17.40| 46.91| 4.08| 32.06|
|GoHomeBot |15.9| 289799| 1819228| 44| 13.27| 41.41| 5.49| 8.53|
|NotTooFarBehindBot |15.7| 285797| 1819208| 90| 18.01| 44.86| 2.97| 50.49|
|GoToSeventeenRollTenBot|14.6| 265503| 1818265| 98| 10.28| 49.21| 5.68| 5.42|
|LizduadacBot |14.5| 263436| 1819146| 78| 9.70| 51.35| 5.72| 4.69|
|BringMyOwn_dice |12.9| 234752| 1817897| 44| 21.34| 41.47| 4.24| 29.33|
|ExpectationsBot | 9.7| 176728| 1819545| 44| 24.42| 41.55| 3.57| 40.40|
|OneStepAheadBot | 9.0| 162878| 1816973| 50| 18.25| 46.01| 3.20| 46.57|
|GoToTenBot | 7.6| 137751| 1820991| 53| 22.98| 45.47| 2.95| 50.92|
|GoBigEarly | 7.0| 127587| 1818227| 49| 20.79| 42.96| 3.90| 35.07|
|MatchLeaderBot | 6.6| 119331| 1818999| 85| 19.80| 41.95| 3.10| 48.31|
|OneInFiveBot | 6.1| 110361| 1820426| 154| 17.28| 49.57| 3.00| 50.04|
|ThrowThriceBot | 4.3| 78694| 1816318| 54| 21.71| 44.55| 2.53| 57.90|
|FutureBot | 4.3| 78383| 1817617| 50| 17.94| 45.16| 2.36| 60.68|
|SlowStart | 2.5| 44643| 1818002| 67| 16.43| 47.49| 1.81| 69.81|
|GamblersFallacy | 1.3| 24385| 1817723| 44| 22.54| 41.50| 2.81| 53.14|
|ThrowTwiceBot | 0.8| 14613| 1816817| 49| 18.08| 43.15| 1.83| 69.43|
|FlipCoinRollDice | 0.7| 13421| 1818027| 74| 15.31| 44.54| 1.61| 73.19|
|BlessRNG | 0.1| 2652| 1819312| 49| 14.55| 42.80| 1.42| 76.37|
|BrainBot | 0.0| 28| 1816964| 44| 10.93| 41.29| 1.00| 83.33|
|StopBot | 0.0| 20| 1819486| 44| 10.94| 41.65| 1.00| 83.34|
|PointsAreForNerdsBot | 0.0| 0| 1818933| 0| 0.00| 0.00| 6.00| 0.00|
+-----------------------+----+--------+--------+------+------+-------+------+--------+









share|improve this question




















  • 2




    So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
    – aschepler
    Dec 19 at 22:15






  • 1




    @aschepler that's a good formulation, I'll edit the post when I'm on my computer
    – maxb
    Dec 20 at 5:13






  • 2




    @maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
    – AKroell
    Dec 20 at 12:49






  • 1




    @AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
    – maxb
    Dec 20 at 12:58






  • 2




    This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
    – Caleb Jay
    Dec 20 at 19:02














54












54








54


14





Dice



I was invited to play a game of dice which I had never heard of. The rules were simple, yet I think it would be perfect for a KotH challenge.



The rules



The start of the game



The die goes around the table, and each time it is your turn, you get to throw the die as many times as you want. However, you have to throw it at least once. You keep track of the sum of all throws for your round. If you choose to stop, the score for the round is added to your total score.



So why would you ever stop throwing the die? Because if you get 6, your score for the entire round becomes zero, and the die is passed on. Thus, the initial goal is to increase your score as quickly as possible.



Who is the winner?



When the first player around the table reaches 40 points or more, the last round starts. Once the last round has started, everyone except the person who initiated the last round gets one more turn.



The rules for the last round is the same as for any other round. You choose to keep throwing or to stop. However, you know that you have no chance of winning if you don't get a higher score than those before you on the last round. But if you keep going too far, then you might get a 6.



However, there's one more rule to take into consideration. If your current total score (your previous score + your current score for the round) is 40 or more, and you hit a 6, your total score is set to 0. That means that you have to start all over. If you hit a 6 when your current total score is 40 or more, the game continues as normal, except that you're now in last place. The last round is not triggered when your total score is reset. You could still win the round, but it does become more challenging.



The winner is the player with the highest score once the last round is over. If two or more players share the same score, they will all be counted as victors.



An added rule is that the game continues for a maximum of 200 rounds. This is to prevent cases where multiple bots basically keep throwing until they hit 6 to stay at their current score. Once the 199th round is passed, last_round is set to true, and one more round is played. If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.



Recap




  • Each round you keep throwing the die until you choose to stop or you get a 6

  • You must throw the die once (if your first throw is a 6, your round is immediately over)

  • If you get a 6, your current score is set to 0 (not your total score)

  • You add your current score to your total score after each round

  • When a bot ends their turn resulting in a total score of at least 40, everyone else gets a last turn

  • If your current total score is $geq 40$ and you get a 6, your total score is set to 0 and your round is over

  • The last round is not triggered when the above occurs

  • The person with the highest total score after the last round is the winner

  • In case there are multiple winners, all will be counted as winners

  • The game lasts for a maximum of 200 rounds


Clarification of the scores




  • Total score: the score that you have saved from previous rounds

  • Current score: the score for the current round

  • Current total score: the sum of the two scores above


How do you participate



To participate in this KotH challenge, you should write a Python class which inherits from Bot. You should implement the function: make_throw(self, scores, last_round). That function will be called once it is your turn, and your first throw was not a 6. To keep throwing, you should yield True. To stop throwing, you should yield False. After each throw, the parent function update_state is called. Thus, you have access to your throws for the current round using the variable self.current_throws. You also have access to your own index using self.index. Thus, to see your own total score you would use scores[self.index]. You could also access the end_score for the game by using self.end_score, but you can safely assume that it will be 40 for this challenge.



You are allowed to create helper functions inside your class. You may also override functions existing in the Bot parent class, e.g. if you want to add more class properties. You are not allowed to modify the state of the game in any way except yielding True or False.



You're free to seek inspiration from this post, and copy any of the two bots that I've included here. However, I'm afraid that they're not particularly effective...



On allowing other languages



In both the sandbox and on The Nineteenth Byte, we have had discussions about allowing submissions in other languages. After reading about such implementations, and hearing arguments from both sides, I have decided to restrict this challenge to Python only. This is due to two factors: the time required to support multiple languages, and the randomness of this challenge requiring a high number of iterations to reach stability. I hope that you will still participate, and if you want to learn some Python for this challenge, I'll try to be available in the chat as often as possible.



For any questions that you might have, you can write in the chat room for this challenge. See you there!



Rules




  • Sabotage is allowed, and encouraged. That is, sabotage against other players

  • Any attempt to tinker with the controller, runtime or other submissions will be disqualified. All submissions should only work with the inputs and storage they are given.

  • Any bot which uses more than 500MB memory to make its decision will be disqualified (if you need that much memory you should rethink your choices)

  • A bot must not implement the exact same strategy as an existing one, intentionally or accidentally.

  • You are allowed to update your bot during the time of the challenge. However, you could also post another bot if your approach is different.


Example



class GoToTenBot(Bot):
def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


This bot will keep going until it has a score of at least 10 for the round, or it throws a 6. Note that you don't need any logic to handle throwing 6. Also note that if your first throw is a 6, make_throw is never called, since your round is immediately over.



For those who are new to Python (and new to the yield concept), but want to give this a go, the yield keyword is similar to a return in some ways, but different in other ways. You can read about the concept here. Basically, once you yield, your function will stop, and the value you yielded will be sent back to the controller. There, the controller handles its logic until it is time for your bot to make another decision. Then the controller sends you the dice throw, and your make_throw function will continue executing right where if stopped before, basically on the line after the previous yield statement.



This way, the game controller can update the state without requiring a separate bot function call for each dice throw.



Specification



You may use any Python library available in pip. To ensure that I'll be able to get a good average, you have a 100 millisecond time limit per round. I'd be really happy if your script was way faster than that, so that I can run more rounds.



Evaluation



To find the winner, I will take all bots and run them in random groups of 8. If there are fewer than 8 classes submitted, I will run them in random groups of 4 to avoid always having all bots in each round. I will run simulations for about 8 hours, and the winner will be the bot with the highest win percentage. I will run start the final simulations at the start of 2019, giving you all Christmas to code your bots! The preliminary final date is January 4th, but if that's too little time I can change it to a later date.



Until then, I'll try to make a daily simulation using 30-60 minutes of CPU time, and updating the score board. This will not be the official score, but it will serve as a guide to see which bots perform the best. However, with Christmas coming up, I hope you can understand that I won't be available at all times. I'll do my best to run simulations and answer any questions related to the challenge.



Test it yourself



If you want to run your own simulations, here's the full code to the controller running the simulation, including two example bots.



Controller



Here's the updated controller for this challenge. It supports ANSI outputs, multi-threading, and collects additional stats thanks to AKroell! When I make changes to the controller, I'll update the post once documentation is complete.



import random
import time
import math
import sys
from multiprocessing import Pool
from collections import defaultdict
# Importing all the bots
from forty_game_bots import *

# If you want to see what each bot decides, set this to true
# Should only be used with one thread and one game
DEBUG = False
# If your terminal supports ANSI, try setting this to true
ANSI = False

def print_str(x, y, string):
print("33["+str(y)+";"+str(x)+"H"+string, end = "", flush = True)

class bcolors:
WHITE = '33[0m'
GREEN = '33[92m'
BLUE = '33[94m'
YELLOW = '33[93m'
RED = '33[91m'
ENDC = '33[0m'

# Class for handling the game logic and relaying information to the bots
class Controller:

def __init__(self, bots_per_game, games, bots, thread_id):
"""Initiates all fields relevant to the simulation

Keyword arguments:
bots_per_game -- the number of bots that should be included in a game
games -- the number of games that should be simulated
bots -- a list of all available bot classes
"""
self.bots_per_game = bots_per_game
self.games = games
self.bots = bots
self.number_of_bots = len(self.bots)
self.wins = defaultdict(int)
self.played_games = defaultdict(int)
self.bot_timings = defaultdict(float)
# self.wins = {bot.__name__: 0 for bot in self.bots}
# self.played_games = {bot.__name__: 0 for bot in self.bots}
self.end_score = 40
self.thread_id = thread_id
self.max_rounds = 200
self.timed_out_games = 0
self.tied_games = 0
self.total_rounds = 0
self.highest_round = 0
#max, avg, avg_win, throws, success, rounds
self.highscore = defaultdict(lambda:[0, 0, 0, 0, 0, 0])
# self.highscore = {bot.__name__: [0, 0, 0] for bot in self.bots}

# Returns a fair dice throw
def throw_die(self):
return random.randint(1,6)
# Print the current game number without newline
def print_progress(self, progress):
length = 50
filled = int(progress*length)
fill = "="*filled
space = " "*(length-filled)
perc = int(100*progress)
if ANSI:
col = [
bcolors.RED,
bcolors.YELLOW,
bcolors.WHITE,
bcolors.BLUE,
bcolors.GREEN
][int(progress*4)]

end = bcolors.ENDC
print_str(5, 8 + self.thread_id,
"t%s[%s%s] %3d%%%s" % (col, fill, space, perc, end)
)
else:
print(
"rt[%s%s] %3d%%" % (fill, space, perc),
flush = True,
end = ""
)

# Handles selecting bots for each game, and counting how many times
# each bot has participated in a game
def simulate_games(self):
for game in range(self.games):
if self.games > 100:
if game % (self.games // 100) == 0 and not DEBUG:
if self.thread_id == 0 or ANSI:
progress = (game+1) / self.games
self.print_progress(progress)
game_bot_indices = random.sample(
range(self.number_of_bots),
self.bots_per_game
)

game_bots = [None for _ in range(self.bots_per_game)]
for i, bot_index in enumerate(game_bot_indices):
self.played_games[self.bots[bot_index].__name__] += 1
game_bots[i] = self.bots[bot_index](i, self.end_score)

self.play(game_bots)
if not DEBUG and (ANSI or self.thread_id == 0):
self.print_progress(1)

self.collect_results()

def play(self, game_bots):
"""Simulates a single game between the bots present in game_bots

Keyword arguments:
game_bots -- A list of instantiated bot objects for the game
"""
last_round = False
last_round_initiator = -1
round_number = 0
game_scores = [0 for _ in range(self.bots_per_game)]


# continue until one bot has reached end_score points
while not last_round:
for index, bot in enumerate(game_bots):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

if game_scores[index] >= self.end_score and not last_round:
last_round = True
last_round_initiator = index
round_number += 1

# maximum of 200 rounds per game
if round_number > self.max_rounds - 1:
last_round = True
self.timed_out_games += 1
# this ensures that everyone gets their last turn
last_round_initiator = self.bots_per_game

# make sure that all bots get their last round
for index, bot in enumerate(game_bots[:last_round_initiator]):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

# calculate which bots have the highest score
max_score = max(game_scores)
nr_of_winners = 0
for i in range(self.bots_per_game):
bot_name = game_bots[i].__class__.__name__
# average score per bot
self.highscore[bot_name][1] += game_scores[i]
if self.highscore[bot_name][0] < game_scores[i]:
# maximum score per bot
self.highscore[bot_name][0] = game_scores[i]
if game_scores[i] == max_score:
# average winning score per bot
self.highscore[bot_name][2] += game_scores[i]
nr_of_winners += 1
self.wins[bot_name] += 1
if nr_of_winners > 1:
self.tied_games += 1
self.total_rounds += round_number
self.highest_round = max(self.highest_round, round_number)

def single_bot(self, index, bot, game_scores, last_round):
"""Simulates a single round for one bot

Keyword arguments:
index -- The player index of the bot (e.g. 0 if the bot goes first)
bot -- The bot object about to be simulated
game_scores -- A list of ints containing the scores of all players
last_round -- Boolean describing whether it is currently the last round
"""

current_throws = [self.throw_die()]
if current_throws[-1] != 6:

bot.update_state(current_throws[:])
for throw in bot.make_throw(game_scores, last_round):
# send the last die cast to the bot
if not throw:
break
current_throws.append(self.throw_die())
if current_throws[-1] == 6:
break
bot.update_state(current_throws[:])

if current_throws[-1] == 6:
# reset total score if running total is above end_score
if game_scores[index] + sum(current_throws) - 6 >= self.end_score:
game_scores[index] = 0
else:
# add to total score if no 6 is cast
game_scores[index] += sum(current_throws)

if DEBUG:
desc = "%d: Bot %24s plays %40s with " +
"scores %30s and last round == %5s"
print(desc % (index, bot.__class__.__name__,
current_throws, game_scores, last_round))

bot_name = bot.__class__.__name__
# average throws per round
self.highscore[bot_name][3] += len(current_throws)
# average success rate per round
self.highscore[bot_name][4] += int(current_throws[-1] != 6)
# total number of rounds
self.highscore[bot_name][5] += 1


# Collects all stats for the thread, so they can be summed up later
def collect_results(self):
self.bot_stats = {
bot.__name__: [
self.wins[bot.__name__],
self.played_games[bot.__name__],
self.highscore[bot.__name__]
]
for bot in self.bots}


#
def print_results(total_bot_stats, total_game_stats, elapsed_time):
"""Print the high score after the simulation

Keyword arguments:
total_bot_stats -- A list containing the winning stats for each thread
total_game_stats -- A list containing controller stats for each thread
elapsed_time -- The number of seconds that it took to run the simulation
"""

# Find the name of each bot, the number of wins, the number
# of played games, and the win percentage
wins = defaultdict(int)
played_games = defaultdict(int)
highscores = defaultdict(lambda: [0, 0, 0, 0, 0, 0])
bots = set()
timed_out_games = sum(s[0] for s in total_game_stats)
tied_games = sum(s[1] for s in total_game_stats)
total_games = sum(s[2] for s in total_game_stats)
total_rounds = sum(s[4] for s in total_game_stats)
highest_round = max(s[5] for s in total_game_stats)
average_rounds = total_rounds / total_games
bot_timings = defaultdict(float)

for thread in total_bot_stats:
for bot, stats in thread.items():
wins[bot] += stats[0]
played_games[bot] += stats[1]

highscores[bot][0] = max(highscores[bot][0], stats[2][0])
for i in range(1, 6):
highscores[bot][i] += stats[2][i]
bots.add(bot)

for bot in bots:
bot_timings[bot] += sum(s[3][bot] for s in total_game_stats)

bot_stats = [[bot, wins[bot], played_games[bot], 0] for bot in bots]

for i, bot in enumerate(bot_stats):
bot[3] = 100 * bot[1] / bot[2] if bot[2] > 0 else 0
bot_stats[i] = tuple(bot)

# Sort the bots by their winning percentage
sorted_scores = sorted(bot_stats, key=lambda x: x[3], reverse=True)
# Find the longest class name for any bot
max_len = max([len(b[0]) for b in bot_stats])

# Print the highscore list
if ANSI:
print_str(0, 9 + threads, "")
else:
print("n")

sim_msg = "tSimulation or %d games between %d bots " +
"completed in %.1f seconds"
print(sim_msg % (total_games, len(bots), elapsed_time))
print("tEach game lasted for an average of %.2f rounds" % average_rounds)
print("t%d games were tied between two or more bots" % tied_games)
print("t%d games ran until the round limit, highest round was %dn"
% (timed_out_games, highest_round))

print_bot_stats(sorted_scores, max_len, highscores)
print_time_stats(bot_timings, max_len)


def print_bot_stats(sorted_scores, max_len, highscores):
"""Print the stats for the bots

Keyword arguments:
sorted_scores -- A list containing the bots in sorted order
max_len -- The maximum name length for all bots
highscores -- A dict with additional stats for each bot
"""
delimiter_format = "t+%s%s+%s+%s+%s+%s+%s+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "", "-"*4, "-"*8,
"-"*8, "-"*6, "-"*6, "-"*7, "-"*6, "-"*8)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)
print("t|%s%s|%4s|%8s|%8s|%6s|%6s|%7s|%6s|%8s|"
% ("Bot", " "*(max_len-3), "Win%", "Wins",
"Played", "Max", "Avg", "Avg win", "Throws", "Success%"))
print(delimiter_str)

for bot, wins, played, score in sorted_scores:
highscore = highscores[bot]
bot_max_score = highscore[0]
bot_avg_score = highscore[1] / played
bot_avg_win_score = highscore[2] / max(1, wins)
bot_avg_throws = highscore[3] / highscore[5]
bot_success_rate = 100 * highscore[4] / highscore[5]

space_fill = " "*(max_len-len(bot))
format_str = "t|%s%s|%4.1f|%8d|%8d|%6d|%6.2f|%7.2f|%6.2f|%8.2f|"
format_arguments = (bot, space_fill, score, wins,
played, bot_max_score, bot_avg_score,
bot_avg_win_score, bot_avg_throws, bot_success_rate)
print(format_str % format_arguments)

print(delimiter_str)
print()

def print_time_stats(bot_timings, max_len):
"""Print the execution time for all bots

Keyword arguments:
bot_timings -- A dict containing information about timings for each bot
max_len -- The maximum name length for all bots
"""
total_time = sum(bot_timings.values())
sorted_times = sorted(bot_timings.items(),
key=lambda x: x[1], reverse = True)

delimiter_format = "t+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "-"*5, "-"*5)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)

print("t|%s%s|%5s|%5s|" % ("Bot", " "*(max_len-3), "Time", "Time%"))
print(delimiter_str)
for bot, bot_time in sorted_times:
space_fill = " "*(max_len-len(bot))
perc = 100 * bot_time / total_time
print("t|%s%s|%5.2f|%5.1f|" % (bot, space_fill, bot_time, perc))
print(delimiter_str)
print()


def run_simulation(thread_id, bots_per_game, games_per_thread, bots):
"""Used by multithreading to run the simulation in parallel

Keyword arguments:
thread_id -- A unique identifier for each thread, starting at 0
bots_per_game -- How many bots should participate in each game
games_per_thread -- The number of games to be simulated
bots -- A list of all bot classes available
"""
try:
controller = Controller(bots_per_game,
games_per_thread, bots, thread_id)
controller.simulate_games()
controller_stats = (
controller.timed_out_games,
controller.tied_games,
controller.games,
controller.bot_timings,
controller.total_rounds,
controller.highest_round
)
return (controller.bot_stats, controller_stats)
except KeyboardInterrupt:
return {}


# Prints the help for the script
def print_help():
print("nThis is the controller for the PPCG KotH challenge " +
"'A game of dice, but avoid number 6'")
print("For any question, send a message to maxbn")
print("Usage: python %s [OPTIONS]" % sys.argv[0])
print("n -nttthe number of games to simluate")
print(" -bttthe number of bots per round")
print(" -tttthe number of threads")
print(" -At--ansitrun in ANSI mode, with prettier printing")
print(" -Dt--debugtrun in debug mode. Sets to 1 thread, 1 game")
print(" -ht--helptshow this helpn")

if __name__ == "__main__":

bots = get_all_bots()
games = 10000
bots_per_game = 8
threads = 4

for i, arg in enumerate(sys.argv):
if arg == "-n" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
games = int(sys.argv[i+1])
if arg == "-b" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
bots_per_game = int(sys.argv[i+1])
if arg == "-t" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
threads = int(sys.argv[i+1])
if arg == "-A" or arg == "--ansi":
ANSI = True
if arg == "-D" or arg == "--debug":
DEBUG = True
if arg == "-h" or arg == "--help":
print_help()
quit()
if ANSI:
print(chr(27) + "[2J", flush = True)
print_str(1,3,"")
else:
print()

if bots_per_game > len(bots):
bots_per_game = len(bots)
if bots_per_game < 2:
print("tAt least 2 bots per game is needed")
bots_per_game = 2
if games <= 0:
print("tAt least 1 game is needed")
games = 1
if threads <= 0:
print("tAt least 1 thread is needed")
threads = 1
if DEBUG:
print("tRunning in debug mode, with 1 thread and 1 game")
threads = 1
games = 1

games_per_thread = math.ceil(games / threads)

print("tStarting simulation with %d bots" % len(bots))
sim_str = "tSimulating %d games with %d bots per game"
print(sim_str % (games, bots_per_game))
print("tRunning simulation on %d threads" % threads)
if len(sys.argv) == 1:
print("tFor help running the script, use the -h flag")
print()
with Pool(threads) as pool:
t0 = time.time()
results = pool.starmap(
run_simulation,
[(i, bots_per_game, games_per_thread, bots) for i in range(threads)]
)
t1 = time.time()
if not DEBUG:
total_bot_stats = [r[0] for r in results]
total_game_stats = [r[1] for r in results]
print_results(total_bot_stats, total_game_stats, t1-t0)


If you want access to the original controller for this challenge, it is available in the edit history. The new controller has the exact same logic for running the game, the only difference is performance, stat collection and prettier printing.



Bots



On my machine, the bots are kept in the file forty_game_bots.py. If you use any other name for the file, you must update the import statement at the top of the controller.



import sys, inspect

# Returns a list of all bot classes which inherit from the Bot class
def get_all_bots():
bots =
current_module = sys.modules[__name__]
for name, obj in inspect.getmembers(current_module, inspect.isclass):
if name != "Bot":
bots.append(obj)
return bots


# The parent class for all bots
class Bot:

def __init__(self, index, end_score):
self.index = index
self.end_score = end_score

def update_state(self, current_throws):
self.current_throws = current_throws

def make_throw(self, scores, last_round):
yield False


class ThrowTwiceBot(Bot):

def make_throw(self, scores, last_round):
yield True
yield False

class GoToTenBot(Bot):

def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


Running the simulation



To run a simulation, save both code snippets posted above to two separate files. I have saved them as forty_game_controller.py and forty_game_bots.py. Then you simply use python forty_game_controller.py or python3 forty_game_controller.py depending on your Python configuration. Follow the instructions from there if you want to configure your simulation further, or try tinkering with the code if you want.



Game stats



If you're making a bot that aims for a certain score without taking other bots into consideration, these are the winning score percentiles:



+----------+-----+
|Percentile|Score|
+----------+-----+
| 50.00| 44|
| 75.00| 47|
| 90.00| 51|
| 95.00| 53|
| 99.00| 58|
| 99.90| 67|
| 99.99| 154|
+----------+-----+


Highscores



As more answers are posted, I'll try to keep this list updated. The contents of the list will always be from the latest simulation. The bots ThrowTwiceBot and GoToTenBot are the bots from the code above, and are used as reference. I did a simulation with 10^8 games, which took about 1 hour. Then I saw that the game reached stability compared to my runs with 10^7 games. However, with people still posting bots, I won't do any longer simulations until the frequency of responses has gone down.



I try to add all new bots and add any changes that you've made to existing bots. If it seems that I have missed your bot or any new changes you have, write in the chat and I'll make sure to have your very latest version in the next simulation.



We now have more stats for each bot thanks to AKroell! The three new columns contain the maximum score across all games, the average score per game, and the average score when winning for each bot.



As pointed out in the comments, there was an issue with the game logic which made bots that had a higher index within a game get an extra round in some cases. This has been fixed now, and the scores below reflect this.



The bot NeoBot does follow the rules, but uses a loophole by predicting the random generator. Since this bot takes a lot of resources to simulate, I have added its stats from a simulation with fewer games.



Simulation or 10000008 games between 44 bots completed in 526.5 seconds
Each game lasted for an average of 3.74 rounds
789768 games were tied between two or more bots
0 games ran until the round limit, highest round was 16

+-----------------------+----+--------+--------+------+------+-------+------+--------+
|Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
+-----------------------+----+--------+--------+------+------+-------+------+--------+
|NeoBot |51.7| 91960| 177998| 232| 45.75| 59.09| 5.10| 82.32|
|OptFor2 |22.6| 409924| 1817383| 85| 20.73| 44.12| 4.00| 33.31|
|EnsureLead |21.7| 395380| 1819194| 87| 20.58| 43.93| 4.49| 25.17|
|StepBot |21.5| 390379| 1815804| 96| 20.53| 43.34| 4.55| 24.18|
|Roll6Timesv2 |21.2| 386196| 1818792| 83| 20.93| 43.39| 4.37| 27.19|
|QuotaBot |21.2| 385746| 1817957| 84| 20.04| 44.84| 4.49| 25.06|
|BinaryBot |21.2| 385007| 1818590| 92| 21.11| 44.30| 3.84| 36.07|
|AggressiveStalker |21.1| 384644| 1819062| 89| 20.69| 44.63| 3.87| 35.46|
|AdaptiveRoller |21.1| 383113| 1817671| 83| 20.80| 43.13| 4.51| 24.87|
|GoTo20Bot |21.0| 381738| 1817765| 92| 21.26| 43.11| 4.44| 26.02|
|FooBot |21.0| 381595| 1817169| 96| 22.11| 43.62| 3.91| 34.87|
|Hesitate |20.9| 380648| 1818690| 84| 21.18| 44.73| 3.90| 34.93|
|GoTo20orBestBot |20.7| 376929| 1816632| 81| 21.08| 43.96| 4.45| 25.79|
|LastRound |20.6| 374936| 1817918| 79| 20.71| 43.34| 4.17| 30.41|
|BePrepared |20.6| 374313| 1816897| 89| 18.69| 47.64| 4.30| 28.34|
|Stalker |20.5| 372315| 1818032| 87| 20.42| 45.12| 3.78| 37.02|
|FortyTeen |19.9| 361996| 1819512| 88| 21.00| 46.63| 3.88| 35.40|
|Chaser |19.8| 359311| 1816875| 84| 19.79| 45.49| 4.02| 33.03|
|Crush |19.5| 354384| 1818530| 83| 14.72| 42.91| 5.18| 13.58|
|ClunkyChicken |19.1| 347610| 1817492| 84| 21.17| 45.40| 3.30| 45.07|
|RollForLuckBot |17.2| 312147| 1818033| 97| 17.44| 50.34| 4.72| 21.38|
|TakeFive |17.1| 310446| 1817875| 82| 19.45| 44.50| 3.36| 44.03|
|Alpha |16.3| 296175| 1818779| 92| 17.70| 46.64| 4.00| 33.41|
|LeadBy5Bot |16.0| 290738| 1817308| 98| 17.40| 46.91| 4.08| 32.06|
|GoHomeBot |15.9| 289799| 1819228| 44| 13.27| 41.41| 5.49| 8.53|
|NotTooFarBehindBot |15.7| 285797| 1819208| 90| 18.01| 44.86| 2.97| 50.49|
|GoToSeventeenRollTenBot|14.6| 265503| 1818265| 98| 10.28| 49.21| 5.68| 5.42|
|LizduadacBot |14.5| 263436| 1819146| 78| 9.70| 51.35| 5.72| 4.69|
|BringMyOwn_dice |12.9| 234752| 1817897| 44| 21.34| 41.47| 4.24| 29.33|
|ExpectationsBot | 9.7| 176728| 1819545| 44| 24.42| 41.55| 3.57| 40.40|
|OneStepAheadBot | 9.0| 162878| 1816973| 50| 18.25| 46.01| 3.20| 46.57|
|GoToTenBot | 7.6| 137751| 1820991| 53| 22.98| 45.47| 2.95| 50.92|
|GoBigEarly | 7.0| 127587| 1818227| 49| 20.79| 42.96| 3.90| 35.07|
|MatchLeaderBot | 6.6| 119331| 1818999| 85| 19.80| 41.95| 3.10| 48.31|
|OneInFiveBot | 6.1| 110361| 1820426| 154| 17.28| 49.57| 3.00| 50.04|
|ThrowThriceBot | 4.3| 78694| 1816318| 54| 21.71| 44.55| 2.53| 57.90|
|FutureBot | 4.3| 78383| 1817617| 50| 17.94| 45.16| 2.36| 60.68|
|SlowStart | 2.5| 44643| 1818002| 67| 16.43| 47.49| 1.81| 69.81|
|GamblersFallacy | 1.3| 24385| 1817723| 44| 22.54| 41.50| 2.81| 53.14|
|ThrowTwiceBot | 0.8| 14613| 1816817| 49| 18.08| 43.15| 1.83| 69.43|
|FlipCoinRollDice | 0.7| 13421| 1818027| 74| 15.31| 44.54| 1.61| 73.19|
|BlessRNG | 0.1| 2652| 1819312| 49| 14.55| 42.80| 1.42| 76.37|
|BrainBot | 0.0| 28| 1816964| 44| 10.93| 41.29| 1.00| 83.33|
|StopBot | 0.0| 20| 1819486| 44| 10.94| 41.65| 1.00| 83.34|
|PointsAreForNerdsBot | 0.0| 0| 1818933| 0| 0.00| 0.00| 6.00| 0.00|
+-----------------------+----+--------+--------+------+------+-------+------+--------+









share|improve this question















Dice



I was invited to play a game of dice which I had never heard of. The rules were simple, yet I think it would be perfect for a KotH challenge.



The rules



The start of the game



The die goes around the table, and each time it is your turn, you get to throw the die as many times as you want. However, you have to throw it at least once. You keep track of the sum of all throws for your round. If you choose to stop, the score for the round is added to your total score.



So why would you ever stop throwing the die? Because if you get 6, your score for the entire round becomes zero, and the die is passed on. Thus, the initial goal is to increase your score as quickly as possible.



Who is the winner?



When the first player around the table reaches 40 points or more, the last round starts. Once the last round has started, everyone except the person who initiated the last round gets one more turn.



The rules for the last round is the same as for any other round. You choose to keep throwing or to stop. However, you know that you have no chance of winning if you don't get a higher score than those before you on the last round. But if you keep going too far, then you might get a 6.



However, there's one more rule to take into consideration. If your current total score (your previous score + your current score for the round) is 40 or more, and you hit a 6, your total score is set to 0. That means that you have to start all over. If you hit a 6 when your current total score is 40 or more, the game continues as normal, except that you're now in last place. The last round is not triggered when your total score is reset. You could still win the round, but it does become more challenging.



The winner is the player with the highest score once the last round is over. If two or more players share the same score, they will all be counted as victors.



An added rule is that the game continues for a maximum of 200 rounds. This is to prevent cases where multiple bots basically keep throwing until they hit 6 to stay at their current score. Once the 199th round is passed, last_round is set to true, and one more round is played. If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.



Recap




  • Each round you keep throwing the die until you choose to stop or you get a 6

  • You must throw the die once (if your first throw is a 6, your round is immediately over)

  • If you get a 6, your current score is set to 0 (not your total score)

  • You add your current score to your total score after each round

  • When a bot ends their turn resulting in a total score of at least 40, everyone else gets a last turn

  • If your current total score is $geq 40$ and you get a 6, your total score is set to 0 and your round is over

  • The last round is not triggered when the above occurs

  • The person with the highest total score after the last round is the winner

  • In case there are multiple winners, all will be counted as winners

  • The game lasts for a maximum of 200 rounds


Clarification of the scores




  • Total score: the score that you have saved from previous rounds

  • Current score: the score for the current round

  • Current total score: the sum of the two scores above


How do you participate



To participate in this KotH challenge, you should write a Python class which inherits from Bot. You should implement the function: make_throw(self, scores, last_round). That function will be called once it is your turn, and your first throw was not a 6. To keep throwing, you should yield True. To stop throwing, you should yield False. After each throw, the parent function update_state is called. Thus, you have access to your throws for the current round using the variable self.current_throws. You also have access to your own index using self.index. Thus, to see your own total score you would use scores[self.index]. You could also access the end_score for the game by using self.end_score, but you can safely assume that it will be 40 for this challenge.



You are allowed to create helper functions inside your class. You may also override functions existing in the Bot parent class, e.g. if you want to add more class properties. You are not allowed to modify the state of the game in any way except yielding True or False.



You're free to seek inspiration from this post, and copy any of the two bots that I've included here. However, I'm afraid that they're not particularly effective...



On allowing other languages



In both the sandbox and on The Nineteenth Byte, we have had discussions about allowing submissions in other languages. After reading about such implementations, and hearing arguments from both sides, I have decided to restrict this challenge to Python only. This is due to two factors: the time required to support multiple languages, and the randomness of this challenge requiring a high number of iterations to reach stability. I hope that you will still participate, and if you want to learn some Python for this challenge, I'll try to be available in the chat as often as possible.



For any questions that you might have, you can write in the chat room for this challenge. See you there!



Rules




  • Sabotage is allowed, and encouraged. That is, sabotage against other players

  • Any attempt to tinker with the controller, runtime or other submissions will be disqualified. All submissions should only work with the inputs and storage they are given.

  • Any bot which uses more than 500MB memory to make its decision will be disqualified (if you need that much memory you should rethink your choices)

  • A bot must not implement the exact same strategy as an existing one, intentionally or accidentally.

  • You are allowed to update your bot during the time of the challenge. However, you could also post another bot if your approach is different.


Example



class GoToTenBot(Bot):
def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


This bot will keep going until it has a score of at least 10 for the round, or it throws a 6. Note that you don't need any logic to handle throwing 6. Also note that if your first throw is a 6, make_throw is never called, since your round is immediately over.



For those who are new to Python (and new to the yield concept), but want to give this a go, the yield keyword is similar to a return in some ways, but different in other ways. You can read about the concept here. Basically, once you yield, your function will stop, and the value you yielded will be sent back to the controller. There, the controller handles its logic until it is time for your bot to make another decision. Then the controller sends you the dice throw, and your make_throw function will continue executing right where if stopped before, basically on the line after the previous yield statement.



This way, the game controller can update the state without requiring a separate bot function call for each dice throw.



Specification



You may use any Python library available in pip. To ensure that I'll be able to get a good average, you have a 100 millisecond time limit per round. I'd be really happy if your script was way faster than that, so that I can run more rounds.



Evaluation



To find the winner, I will take all bots and run them in random groups of 8. If there are fewer than 8 classes submitted, I will run them in random groups of 4 to avoid always having all bots in each round. I will run simulations for about 8 hours, and the winner will be the bot with the highest win percentage. I will run start the final simulations at the start of 2019, giving you all Christmas to code your bots! The preliminary final date is January 4th, but if that's too little time I can change it to a later date.



Until then, I'll try to make a daily simulation using 30-60 minutes of CPU time, and updating the score board. This will not be the official score, but it will serve as a guide to see which bots perform the best. However, with Christmas coming up, I hope you can understand that I won't be available at all times. I'll do my best to run simulations and answer any questions related to the challenge.



Test it yourself



If you want to run your own simulations, here's the full code to the controller running the simulation, including two example bots.



Controller



Here's the updated controller for this challenge. It supports ANSI outputs, multi-threading, and collects additional stats thanks to AKroell! When I make changes to the controller, I'll update the post once documentation is complete.



import random
import time
import math
import sys
from multiprocessing import Pool
from collections import defaultdict
# Importing all the bots
from forty_game_bots import *

# If you want to see what each bot decides, set this to true
# Should only be used with one thread and one game
DEBUG = False
# If your terminal supports ANSI, try setting this to true
ANSI = False

def print_str(x, y, string):
print("33["+str(y)+";"+str(x)+"H"+string, end = "", flush = True)

class bcolors:
WHITE = '33[0m'
GREEN = '33[92m'
BLUE = '33[94m'
YELLOW = '33[93m'
RED = '33[91m'
ENDC = '33[0m'

# Class for handling the game logic and relaying information to the bots
class Controller:

def __init__(self, bots_per_game, games, bots, thread_id):
"""Initiates all fields relevant to the simulation

Keyword arguments:
bots_per_game -- the number of bots that should be included in a game
games -- the number of games that should be simulated
bots -- a list of all available bot classes
"""
self.bots_per_game = bots_per_game
self.games = games
self.bots = bots
self.number_of_bots = len(self.bots)
self.wins = defaultdict(int)
self.played_games = defaultdict(int)
self.bot_timings = defaultdict(float)
# self.wins = {bot.__name__: 0 for bot in self.bots}
# self.played_games = {bot.__name__: 0 for bot in self.bots}
self.end_score = 40
self.thread_id = thread_id
self.max_rounds = 200
self.timed_out_games = 0
self.tied_games = 0
self.total_rounds = 0
self.highest_round = 0
#max, avg, avg_win, throws, success, rounds
self.highscore = defaultdict(lambda:[0, 0, 0, 0, 0, 0])
# self.highscore = {bot.__name__: [0, 0, 0] for bot in self.bots}

# Returns a fair dice throw
def throw_die(self):
return random.randint(1,6)
# Print the current game number without newline
def print_progress(self, progress):
length = 50
filled = int(progress*length)
fill = "="*filled
space = " "*(length-filled)
perc = int(100*progress)
if ANSI:
col = [
bcolors.RED,
bcolors.YELLOW,
bcolors.WHITE,
bcolors.BLUE,
bcolors.GREEN
][int(progress*4)]

end = bcolors.ENDC
print_str(5, 8 + self.thread_id,
"t%s[%s%s] %3d%%%s" % (col, fill, space, perc, end)
)
else:
print(
"rt[%s%s] %3d%%" % (fill, space, perc),
flush = True,
end = ""
)

# Handles selecting bots for each game, and counting how many times
# each bot has participated in a game
def simulate_games(self):
for game in range(self.games):
if self.games > 100:
if game % (self.games // 100) == 0 and not DEBUG:
if self.thread_id == 0 or ANSI:
progress = (game+1) / self.games
self.print_progress(progress)
game_bot_indices = random.sample(
range(self.number_of_bots),
self.bots_per_game
)

game_bots = [None for _ in range(self.bots_per_game)]
for i, bot_index in enumerate(game_bot_indices):
self.played_games[self.bots[bot_index].__name__] += 1
game_bots[i] = self.bots[bot_index](i, self.end_score)

self.play(game_bots)
if not DEBUG and (ANSI or self.thread_id == 0):
self.print_progress(1)

self.collect_results()

def play(self, game_bots):
"""Simulates a single game between the bots present in game_bots

Keyword arguments:
game_bots -- A list of instantiated bot objects for the game
"""
last_round = False
last_round_initiator = -1
round_number = 0
game_scores = [0 for _ in range(self.bots_per_game)]


# continue until one bot has reached end_score points
while not last_round:
for index, bot in enumerate(game_bots):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

if game_scores[index] >= self.end_score and not last_round:
last_round = True
last_round_initiator = index
round_number += 1

# maximum of 200 rounds per game
if round_number > self.max_rounds - 1:
last_round = True
self.timed_out_games += 1
# this ensures that everyone gets their last turn
last_round_initiator = self.bots_per_game

# make sure that all bots get their last round
for index, bot in enumerate(game_bots[:last_round_initiator]):
t0 = time.clock()
self.single_bot(index, bot, game_scores, last_round)
t1 = time.clock()
self.bot_timings[bot.__class__.__name__] += t1-t0

# calculate which bots have the highest score
max_score = max(game_scores)
nr_of_winners = 0
for i in range(self.bots_per_game):
bot_name = game_bots[i].__class__.__name__
# average score per bot
self.highscore[bot_name][1] += game_scores[i]
if self.highscore[bot_name][0] < game_scores[i]:
# maximum score per bot
self.highscore[bot_name][0] = game_scores[i]
if game_scores[i] == max_score:
# average winning score per bot
self.highscore[bot_name][2] += game_scores[i]
nr_of_winners += 1
self.wins[bot_name] += 1
if nr_of_winners > 1:
self.tied_games += 1
self.total_rounds += round_number
self.highest_round = max(self.highest_round, round_number)

def single_bot(self, index, bot, game_scores, last_round):
"""Simulates a single round for one bot

Keyword arguments:
index -- The player index of the bot (e.g. 0 if the bot goes first)
bot -- The bot object about to be simulated
game_scores -- A list of ints containing the scores of all players
last_round -- Boolean describing whether it is currently the last round
"""

current_throws = [self.throw_die()]
if current_throws[-1] != 6:

bot.update_state(current_throws[:])
for throw in bot.make_throw(game_scores, last_round):
# send the last die cast to the bot
if not throw:
break
current_throws.append(self.throw_die())
if current_throws[-1] == 6:
break
bot.update_state(current_throws[:])

if current_throws[-1] == 6:
# reset total score if running total is above end_score
if game_scores[index] + sum(current_throws) - 6 >= self.end_score:
game_scores[index] = 0
else:
# add to total score if no 6 is cast
game_scores[index] += sum(current_throws)

if DEBUG:
desc = "%d: Bot %24s plays %40s with " +
"scores %30s and last round == %5s"
print(desc % (index, bot.__class__.__name__,
current_throws, game_scores, last_round))

bot_name = bot.__class__.__name__
# average throws per round
self.highscore[bot_name][3] += len(current_throws)
# average success rate per round
self.highscore[bot_name][4] += int(current_throws[-1] != 6)
# total number of rounds
self.highscore[bot_name][5] += 1


# Collects all stats for the thread, so they can be summed up later
def collect_results(self):
self.bot_stats = {
bot.__name__: [
self.wins[bot.__name__],
self.played_games[bot.__name__],
self.highscore[bot.__name__]
]
for bot in self.bots}


#
def print_results(total_bot_stats, total_game_stats, elapsed_time):
"""Print the high score after the simulation

Keyword arguments:
total_bot_stats -- A list containing the winning stats for each thread
total_game_stats -- A list containing controller stats for each thread
elapsed_time -- The number of seconds that it took to run the simulation
"""

# Find the name of each bot, the number of wins, the number
# of played games, and the win percentage
wins = defaultdict(int)
played_games = defaultdict(int)
highscores = defaultdict(lambda: [0, 0, 0, 0, 0, 0])
bots = set()
timed_out_games = sum(s[0] for s in total_game_stats)
tied_games = sum(s[1] for s in total_game_stats)
total_games = sum(s[2] for s in total_game_stats)
total_rounds = sum(s[4] for s in total_game_stats)
highest_round = max(s[5] for s in total_game_stats)
average_rounds = total_rounds / total_games
bot_timings = defaultdict(float)

for thread in total_bot_stats:
for bot, stats in thread.items():
wins[bot] += stats[0]
played_games[bot] += stats[1]

highscores[bot][0] = max(highscores[bot][0], stats[2][0])
for i in range(1, 6):
highscores[bot][i] += stats[2][i]
bots.add(bot)

for bot in bots:
bot_timings[bot] += sum(s[3][bot] for s in total_game_stats)

bot_stats = [[bot, wins[bot], played_games[bot], 0] for bot in bots]

for i, bot in enumerate(bot_stats):
bot[3] = 100 * bot[1] / bot[2] if bot[2] > 0 else 0
bot_stats[i] = tuple(bot)

# Sort the bots by their winning percentage
sorted_scores = sorted(bot_stats, key=lambda x: x[3], reverse=True)
# Find the longest class name for any bot
max_len = max([len(b[0]) for b in bot_stats])

# Print the highscore list
if ANSI:
print_str(0, 9 + threads, "")
else:
print("n")

sim_msg = "tSimulation or %d games between %d bots " +
"completed in %.1f seconds"
print(sim_msg % (total_games, len(bots), elapsed_time))
print("tEach game lasted for an average of %.2f rounds" % average_rounds)
print("t%d games were tied between two or more bots" % tied_games)
print("t%d games ran until the round limit, highest round was %dn"
% (timed_out_games, highest_round))

print_bot_stats(sorted_scores, max_len, highscores)
print_time_stats(bot_timings, max_len)


def print_bot_stats(sorted_scores, max_len, highscores):
"""Print the stats for the bots

Keyword arguments:
sorted_scores -- A list containing the bots in sorted order
max_len -- The maximum name length for all bots
highscores -- A dict with additional stats for each bot
"""
delimiter_format = "t+%s%s+%s+%s+%s+%s+%s+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "", "-"*4, "-"*8,
"-"*8, "-"*6, "-"*6, "-"*7, "-"*6, "-"*8)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)
print("t|%s%s|%4s|%8s|%8s|%6s|%6s|%7s|%6s|%8s|"
% ("Bot", " "*(max_len-3), "Win%", "Wins",
"Played", "Max", "Avg", "Avg win", "Throws", "Success%"))
print(delimiter_str)

for bot, wins, played, score in sorted_scores:
highscore = highscores[bot]
bot_max_score = highscore[0]
bot_avg_score = highscore[1] / played
bot_avg_win_score = highscore[2] / max(1, wins)
bot_avg_throws = highscore[3] / highscore[5]
bot_success_rate = 100 * highscore[4] / highscore[5]

space_fill = " "*(max_len-len(bot))
format_str = "t|%s%s|%4.1f|%8d|%8d|%6d|%6.2f|%7.2f|%6.2f|%8.2f|"
format_arguments = (bot, space_fill, score, wins,
played, bot_max_score, bot_avg_score,
bot_avg_win_score, bot_avg_throws, bot_success_rate)
print(format_str % format_arguments)

print(delimiter_str)
print()

def print_time_stats(bot_timings, max_len):
"""Print the execution time for all bots

Keyword arguments:
bot_timings -- A dict containing information about timings for each bot
max_len -- The maximum name length for all bots
"""
total_time = sum(bot_timings.values())
sorted_times = sorted(bot_timings.items(),
key=lambda x: x[1], reverse = True)

delimiter_format = "t+%s+%s+%s+"
delimiter_args = ("-"*(max_len), "-"*5, "-"*5)
delimiter_str = delimiter_format % delimiter_args
print(delimiter_str)

print("t|%s%s|%5s|%5s|" % ("Bot", " "*(max_len-3), "Time", "Time%"))
print(delimiter_str)
for bot, bot_time in sorted_times:
space_fill = " "*(max_len-len(bot))
perc = 100 * bot_time / total_time
print("t|%s%s|%5.2f|%5.1f|" % (bot, space_fill, bot_time, perc))
print(delimiter_str)
print()


def run_simulation(thread_id, bots_per_game, games_per_thread, bots):
"""Used by multithreading to run the simulation in parallel

Keyword arguments:
thread_id -- A unique identifier for each thread, starting at 0
bots_per_game -- How many bots should participate in each game
games_per_thread -- The number of games to be simulated
bots -- A list of all bot classes available
"""
try:
controller = Controller(bots_per_game,
games_per_thread, bots, thread_id)
controller.simulate_games()
controller_stats = (
controller.timed_out_games,
controller.tied_games,
controller.games,
controller.bot_timings,
controller.total_rounds,
controller.highest_round
)
return (controller.bot_stats, controller_stats)
except KeyboardInterrupt:
return {}


# Prints the help for the script
def print_help():
print("nThis is the controller for the PPCG KotH challenge " +
"'A game of dice, but avoid number 6'")
print("For any question, send a message to maxbn")
print("Usage: python %s [OPTIONS]" % sys.argv[0])
print("n -nttthe number of games to simluate")
print(" -bttthe number of bots per round")
print(" -tttthe number of threads")
print(" -At--ansitrun in ANSI mode, with prettier printing")
print(" -Dt--debugtrun in debug mode. Sets to 1 thread, 1 game")
print(" -ht--helptshow this helpn")

if __name__ == "__main__":

bots = get_all_bots()
games = 10000
bots_per_game = 8
threads = 4

for i, arg in enumerate(sys.argv):
if arg == "-n" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
games = int(sys.argv[i+1])
if arg == "-b" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
bots_per_game = int(sys.argv[i+1])
if arg == "-t" and len(sys.argv) > i+1 and sys.argv[i+1].isdigit():
threads = int(sys.argv[i+1])
if arg == "-A" or arg == "--ansi":
ANSI = True
if arg == "-D" or arg == "--debug":
DEBUG = True
if arg == "-h" or arg == "--help":
print_help()
quit()
if ANSI:
print(chr(27) + "[2J", flush = True)
print_str(1,3,"")
else:
print()

if bots_per_game > len(bots):
bots_per_game = len(bots)
if bots_per_game < 2:
print("tAt least 2 bots per game is needed")
bots_per_game = 2
if games <= 0:
print("tAt least 1 game is needed")
games = 1
if threads <= 0:
print("tAt least 1 thread is needed")
threads = 1
if DEBUG:
print("tRunning in debug mode, with 1 thread and 1 game")
threads = 1
games = 1

games_per_thread = math.ceil(games / threads)

print("tStarting simulation with %d bots" % len(bots))
sim_str = "tSimulating %d games with %d bots per game"
print(sim_str % (games, bots_per_game))
print("tRunning simulation on %d threads" % threads)
if len(sys.argv) == 1:
print("tFor help running the script, use the -h flag")
print()
with Pool(threads) as pool:
t0 = time.time()
results = pool.starmap(
run_simulation,
[(i, bots_per_game, games_per_thread, bots) for i in range(threads)]
)
t1 = time.time()
if not DEBUG:
total_bot_stats = [r[0] for r in results]
total_game_stats = [r[1] for r in results]
print_results(total_bot_stats, total_game_stats, t1-t0)


If you want access to the original controller for this challenge, it is available in the edit history. The new controller has the exact same logic for running the game, the only difference is performance, stat collection and prettier printing.



Bots



On my machine, the bots are kept in the file forty_game_bots.py. If you use any other name for the file, you must update the import statement at the top of the controller.



import sys, inspect

# Returns a list of all bot classes which inherit from the Bot class
def get_all_bots():
bots =
current_module = sys.modules[__name__]
for name, obj in inspect.getmembers(current_module, inspect.isclass):
if name != "Bot":
bots.append(obj)
return bots


# The parent class for all bots
class Bot:

def __init__(self, index, end_score):
self.index = index
self.end_score = end_score

def update_state(self, current_throws):
self.current_throws = current_throws

def make_throw(self, scores, last_round):
yield False


class ThrowTwiceBot(Bot):

def make_throw(self, scores, last_round):
yield True
yield False

class GoToTenBot(Bot):

def make_throw(self, scores, last_round):
while sum(self.current_throws) < 10:
yield True
yield False


Running the simulation



To run a simulation, save both code snippets posted above to two separate files. I have saved them as forty_game_controller.py and forty_game_bots.py. Then you simply use python forty_game_controller.py or python3 forty_game_controller.py depending on your Python configuration. Follow the instructions from there if you want to configure your simulation further, or try tinkering with the code if you want.



Game stats



If you're making a bot that aims for a certain score without taking other bots into consideration, these are the winning score percentiles:



+----------+-----+
|Percentile|Score|
+----------+-----+
| 50.00| 44|
| 75.00| 47|
| 90.00| 51|
| 95.00| 53|
| 99.00| 58|
| 99.90| 67|
| 99.99| 154|
+----------+-----+


Highscores



As more answers are posted, I'll try to keep this list updated. The contents of the list will always be from the latest simulation. The bots ThrowTwiceBot and GoToTenBot are the bots from the code above, and are used as reference. I did a simulation with 10^8 games, which took about 1 hour. Then I saw that the game reached stability compared to my runs with 10^7 games. However, with people still posting bots, I won't do any longer simulations until the frequency of responses has gone down.



I try to add all new bots and add any changes that you've made to existing bots. If it seems that I have missed your bot or any new changes you have, write in the chat and I'll make sure to have your very latest version in the next simulation.



We now have more stats for each bot thanks to AKroell! The three new columns contain the maximum score across all games, the average score per game, and the average score when winning for each bot.



As pointed out in the comments, there was an issue with the game logic which made bots that had a higher index within a game get an extra round in some cases. This has been fixed now, and the scores below reflect this.



The bot NeoBot does follow the rules, but uses a loophole by predicting the random generator. Since this bot takes a lot of resources to simulate, I have added its stats from a simulation with fewer games.



Simulation or 10000008 games between 44 bots completed in 526.5 seconds
Each game lasted for an average of 3.74 rounds
789768 games were tied between two or more bots
0 games ran until the round limit, highest round was 16

+-----------------------+----+--------+--------+------+------+-------+------+--------+
|Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
+-----------------------+----+--------+--------+------+------+-------+------+--------+
|NeoBot |51.7| 91960| 177998| 232| 45.75| 59.09| 5.10| 82.32|
|OptFor2 |22.6| 409924| 1817383| 85| 20.73| 44.12| 4.00| 33.31|
|EnsureLead |21.7| 395380| 1819194| 87| 20.58| 43.93| 4.49| 25.17|
|StepBot |21.5| 390379| 1815804| 96| 20.53| 43.34| 4.55| 24.18|
|Roll6Timesv2 |21.2| 386196| 1818792| 83| 20.93| 43.39| 4.37| 27.19|
|QuotaBot |21.2| 385746| 1817957| 84| 20.04| 44.84| 4.49| 25.06|
|BinaryBot |21.2| 385007| 1818590| 92| 21.11| 44.30| 3.84| 36.07|
|AggressiveStalker |21.1| 384644| 1819062| 89| 20.69| 44.63| 3.87| 35.46|
|AdaptiveRoller |21.1| 383113| 1817671| 83| 20.80| 43.13| 4.51| 24.87|
|GoTo20Bot |21.0| 381738| 1817765| 92| 21.26| 43.11| 4.44| 26.02|
|FooBot |21.0| 381595| 1817169| 96| 22.11| 43.62| 3.91| 34.87|
|Hesitate |20.9| 380648| 1818690| 84| 21.18| 44.73| 3.90| 34.93|
|GoTo20orBestBot |20.7| 376929| 1816632| 81| 21.08| 43.96| 4.45| 25.79|
|LastRound |20.6| 374936| 1817918| 79| 20.71| 43.34| 4.17| 30.41|
|BePrepared |20.6| 374313| 1816897| 89| 18.69| 47.64| 4.30| 28.34|
|Stalker |20.5| 372315| 1818032| 87| 20.42| 45.12| 3.78| 37.02|
|FortyTeen |19.9| 361996| 1819512| 88| 21.00| 46.63| 3.88| 35.40|
|Chaser |19.8| 359311| 1816875| 84| 19.79| 45.49| 4.02| 33.03|
|Crush |19.5| 354384| 1818530| 83| 14.72| 42.91| 5.18| 13.58|
|ClunkyChicken |19.1| 347610| 1817492| 84| 21.17| 45.40| 3.30| 45.07|
|RollForLuckBot |17.2| 312147| 1818033| 97| 17.44| 50.34| 4.72| 21.38|
|TakeFive |17.1| 310446| 1817875| 82| 19.45| 44.50| 3.36| 44.03|
|Alpha |16.3| 296175| 1818779| 92| 17.70| 46.64| 4.00| 33.41|
|LeadBy5Bot |16.0| 290738| 1817308| 98| 17.40| 46.91| 4.08| 32.06|
|GoHomeBot |15.9| 289799| 1819228| 44| 13.27| 41.41| 5.49| 8.53|
|NotTooFarBehindBot |15.7| 285797| 1819208| 90| 18.01| 44.86| 2.97| 50.49|
|GoToSeventeenRollTenBot|14.6| 265503| 1818265| 98| 10.28| 49.21| 5.68| 5.42|
|LizduadacBot |14.5| 263436| 1819146| 78| 9.70| 51.35| 5.72| 4.69|
|BringMyOwn_dice |12.9| 234752| 1817897| 44| 21.34| 41.47| 4.24| 29.33|
|ExpectationsBot | 9.7| 176728| 1819545| 44| 24.42| 41.55| 3.57| 40.40|
|OneStepAheadBot | 9.0| 162878| 1816973| 50| 18.25| 46.01| 3.20| 46.57|
|GoToTenBot | 7.6| 137751| 1820991| 53| 22.98| 45.47| 2.95| 50.92|
|GoBigEarly | 7.0| 127587| 1818227| 49| 20.79| 42.96| 3.90| 35.07|
|MatchLeaderBot | 6.6| 119331| 1818999| 85| 19.80| 41.95| 3.10| 48.31|
|OneInFiveBot | 6.1| 110361| 1820426| 154| 17.28| 49.57| 3.00| 50.04|
|ThrowThriceBot | 4.3| 78694| 1816318| 54| 21.71| 44.55| 2.53| 57.90|
|FutureBot | 4.3| 78383| 1817617| 50| 17.94| 45.16| 2.36| 60.68|
|SlowStart | 2.5| 44643| 1818002| 67| 16.43| 47.49| 1.81| 69.81|
|GamblersFallacy | 1.3| 24385| 1817723| 44| 22.54| 41.50| 2.81| 53.14|
|ThrowTwiceBot | 0.8| 14613| 1816817| 49| 18.08| 43.15| 1.83| 69.43|
|FlipCoinRollDice | 0.7| 13421| 1818027| 74| 15.31| 44.54| 1.61| 73.19|
|BlessRNG | 0.1| 2652| 1819312| 49| 14.55| 42.80| 1.42| 76.37|
|BrainBot | 0.0| 28| 1816964| 44| 10.93| 41.29| 1.00| 83.33|
|StopBot | 0.0| 20| 1819486| 44| 10.94| 41.65| 1.00| 83.34|
|PointsAreForNerdsBot | 0.0| 0| 1818933| 0| 0.00| 0.00| 6.00| 0.00|
+-----------------------+----+--------+--------+------+------+-------+------+--------+






random game king-of-the-hill python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked Dec 19 at 8:16









maxb

2,90611131




2,90611131








  • 2




    So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
    – aschepler
    Dec 19 at 22:15






  • 1




    @aschepler that's a good formulation, I'll edit the post when I'm on my computer
    – maxb
    Dec 20 at 5:13






  • 2




    @maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
    – AKroell
    Dec 20 at 12:49






  • 1




    @AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
    – maxb
    Dec 20 at 12:58






  • 2




    This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
    – Caleb Jay
    Dec 20 at 19:02














  • 2




    So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
    – aschepler
    Dec 19 at 22:15






  • 1




    @aschepler that's a good formulation, I'll edit the post when I'm on my computer
    – maxb
    Dec 20 at 5:13






  • 2




    @maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
    – AKroell
    Dec 20 at 12:49






  • 1




    @AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
    – maxb
    Dec 20 at 12:58






  • 2




    This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
    – Caleb Jay
    Dec 20 at 19:02








2




2




So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
– aschepler
Dec 19 at 22:15




So maybe the rules would be slightly clearer if they said "when a player ends their turn with a score of at least 40, everyone else gets a last turn". This avoids the apparent conflict by pointing out it's not reaching 40 that really triggers the last round, it's stopping with at least 40.
– aschepler
Dec 19 at 22:15




1




1




@aschepler that's a good formulation, I'll edit the post when I'm on my computer
– maxb
Dec 20 at 5:13




@aschepler that's a good formulation, I'll edit the post when I'm on my computer
– maxb
Dec 20 at 5:13




2




2




@maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
– AKroell
Dec 20 at 12:49




@maxb I've extended the controller to add more stats that were relevant to my development process: highest score reached, average score reached and average winning score gist.github.com/A-w-K/91446718a46f3e001c19533298b5756c
– AKroell
Dec 20 at 12:49




1




1




@AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
– maxb
Dec 20 at 12:58




@AKroell Thanks for the addition! I have also made some ongoing changes to get more stats, but mostly related to bot runtimes and checking for ties. I'll try to look through your additions later today and update it.
– maxb
Dec 20 at 12:58




2




2




This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
– Caleb Jay
Dec 20 at 19:02




This sounds very similar to a very fun dice game called Farkled en.wikipedia.org/wiki/Farkle
– Caleb Jay
Dec 20 at 19:02










39 Answers
39






active

oldest

votes













1 2
next












13














NeoBot



Instead, only try to realize the truth - there is no spoon



NeoBot peeks into the matrix (aka random) and predicts if the next roll will be a 6 or not - it can't do anything about being handed a 6 to start with but is more than happy to dodge a streak ender.



NeoBot doesn't actually modify the controller or runtime, just politely asks the library for more information.



class NeoBot(Bot):
def __init__(self, index, end_score):
self.random = None
self.last_scores = None
self.last_state = None
super().__init__(index,end_score)

def make_throw(self, scores, last_round):
while True:
if self.random is None:
self.random = inspect.stack()[1][0].f_globals['random']
tscores = scores[:self.index] + scores[self.index+1:]
if self.last_scores != tscores:
self.last_state = None
self.last_scores = tscores
future = self.predictnext_randint(self.random)
if future == 6:
yield False
else:
yield True

def genrand_int32(self,base):
base ^= (base >> 11)
base ^= (base << 7) & 0x9d2c5680
base ^= (base << 15) & 0xefc60000
return base ^ (base >> 18)

def predictnext_randint(self,cls):
if self.last_state is None:
self.last_state = list(cls.getstate()[1])
ind = self.last_state[-1]
width = 6
res = width + 1
while res >= width:
y = self.last_state[ind]
r = self.genrand_int32(y)
res = r >> 29
ind += 1
self.last_state[-1] = (self.last_state[-1] + 1) % (len(self.last_state))
return 1 + res





share|improve this answer










New contributor




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














  • 1




    Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
    – maxb
    yesterday






  • 1




    Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
    – maxb
    yesterday






  • 1




    Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
    – Mostly Harmless
    yesterday






  • 1




    thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
    – maxb
    yesterday





















9














GoTo20Bot



class GoTo20Bot(Bot):

def make_throw(self, scores, last_round):
target = min(20, 40 - scores[self.index])
if last_round:
target = max(scores) - scores[self.index] + 1
while sum(self.current_throws) < target:
yield True
yield False


Just have a try with all GoToNBot's, And 20, 22, 24 plays best. I don't know why.





Update: always stop throw if get score 40 or more.






share|improve this answer























  • I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
    – maxb
    Dec 19 at 8:57










  • @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
    – tsh
    Dec 19 at 9:00










  • I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
    – maxb
    Dec 19 at 9:04






  • 2




    I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
    – maxb
    Dec 19 at 11:23






  • 1




    @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
    – tsh
    Dec 21 at 1:39





















9














Adaptive Roller



Starts out more aggressive and calms down towards the end of the round.

If it believes it's winning, roll an extra time for safety.



class AdaptiveRoller(Bot):

def make_throw(self, scores, last_round):
lim = min(self.end_score - scores[self.index], 22)
while sum(self.current_throws) < lim:
yield True
if max(scores) == scores[self.index] and max(scores) >= self.end_score:
yield True
while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
yield True
yield False





share|improve this answer























  • Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
    – maxb
    Dec 19 at 8:51










  • I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
    – AKroell
    Dec 20 at 16:25










  • @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
    – Emigna
    Dec 20 at 17:50



















9














Cooperative Swarm



Strategy



I don't think anyone else has yet noticed the significance of this rule:




If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.




If every bot always rolled until they busted, then everyone would have a score of zero at the end of round 200 and everybody would win! Thus, the Cooperative Swarm's strategy is to cooperate as long as all players have a score of zero, but to play normally if anybody scores any points.



In this post, I am submitting two bots: the first is CooperativeSwarmBot, and the second is CooperativeThrowTwice. CooperativeSwarmBot serves as a base class for all bots that are formally part of the cooperative swarm, and has placeholder behavior of simply accepting its first successful roll when cooperation fails. CooperativeSwarmBot has CooperativeSwarmBot as its parent and is identical to it in every way except that its non-cooperative behavior is to make two rolls instead of one. In the next few days I will be revising this post to add new bots that use much more intelligent behavior playing against non-cooperative bots.



Code



class CooperativeSwarmBot(Bot):
def defection_strategy(self, scores, last_round):
yield False

def make_throw(self, scores, last_round):
cooperate = max(scores) == 0
if (cooperate):
while True:
yield True
else:
yield from self.defection_strategy(scores, last_round)

class CooperativeThrowTwice(CooperativeSwarmBot):
def defection_strategy(self, scores, last_round):
yield True
yield False


Analysis



Viability



It is very hard to cooperate in this game because we need the support of all eight players for it to work. Since each bot class is limited to one instance per game, this is a hard goal to achieve. For example, the odds of choosing eight cooperative bots from a pool of 100 cooperative bots and 30 non-cooperative bots is:



$$frac{100}{130} * frac{99}{129} * frac{98}{128} * frac{97}{127} * frac{96}{126} * frac{95}{125} * frac{94}{124} * frac{93}{123} approx 0.115$$



More generally, the odds of choosing $i$ cooperative bots from a pool of $c$ cooperative bots and $n$ noncooperative bots is:



$$frac{c! div (c - i)!}{(c+n)! div (c + n - i)!}$$



From this equation we can easily show that we would need about 430 cooperative bots in order for 50% of games to end cooperatively, or about 2900 bots for 90% (using $i = 8$ as per the rules, and $n = 38$).



Case Study



For a number of reasons (see footnotes 1 and 2), a proper cooperative swarm will never compete in the official games. As such, I'll be summarizing the results of one of my own simulations in this section.



This simulation ran 10000 games using the 38 other bots that had been posted here the last time I checked and 2900 bots that had CooperativeSwarmBot as their parent class. The controller reported that 9051 of the 10000 games (90.51%) ended at 200 rounds, which is quite close to the prediction that 90% of games would be cooperative. The implementation of these bots was trivial; other than CooperativeSwarmBot they all took this form:



class CooperativeSwarm_1234(CooperativeSwarmBot):
pass


Less that 3% of the bots had a win percentage that was below 80%, and just over 11% of the bots won every single game they played. The median win percentage of the 2900 bots in the swarm is about 86%, which is outrageously good. For comparison, the top performers on the current official leaderboard win less than 22% of their games. I can't fit the full listing of the cooperative swarm within the maximum allowed length for an answer, so if you want to view that you'll have to go here instead: https://pastebin.com/3Zc8m1Ex



Since each bot played in an average of about 27 games, luck plays a relatively large roll when you look at the results for individual bots. As I have not yet implemented an advanced strategy for non-cooperative games, most other bots benefited drastically from playing against the cooperative swarm, performing even the cooperative swarm's median win rate of 86%.



The full results for bots that aren't in the swarm are listed below; there are two bots whose results I think deserve particular attention. First, StopBot failed to win any games at all. This is particularly tragic because the cooperative swarm was actually using the exact same strategy as StopBot was; you would have expected StopBot to win an eight of its games by chance, and a little bit more because the cooperative swarm is forced to give its opponents the first move. The second interesting result, however, is that PointsAreForNerdsBot's hard work finally paid off: it cooperated with the swarm and managed to win every single game it played!



+---------------------+----+--------+--------+------+------+-------+------+--------+
|Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
+---------------------+----+--------+--------+------+------+-------+------+--------+
|AggressiveStalker |100.0| 21| 21| 42| 40.71| 40.71| 3.48| 46.32|
|PointsAreForNerdsBot |100.0| 31| 31| 0| 0.00| 0.00| 6.02| 0.00|
|TakeFive |100.0| 18| 18| 44| 41.94| 41.94| 2.61| 50.93|
|Hesitate |100.0| 26| 26| 44| 41.27| 41.27| 3.32| 41.89|
|Crush |100.0| 34| 34| 44| 41.15| 41.15| 5.38| 6.73|
|StepBot |97.0| 32| 33| 46| 41.15| 42.44| 4.51| 24.54|
|LastRound |96.8| 30| 31| 44| 40.32| 41.17| 3.54| 45.05|
|Chaser |96.8| 30| 31| 47| 42.90| 44.33| 3.04| 52.16|
|GoHomeBot |96.8| 30| 31| 44| 40.32| 41.67| 5.60| 9.71|
|Stalker |96.4| 27| 28| 44| 41.18| 41.44| 2.88| 57.53|
|ClunkyChicken |96.2| 25| 26| 44| 40.96| 41.88| 2.32| 61.23|
|AdaptiveRoller |96.0| 24| 25| 44| 39.32| 40.96| 4.49| 27.43|
|GoTo20Bot |95.5| 21| 22| 44| 40.36| 41.33| 4.60| 30.50|
|FortyTeen |95.0| 19| 20| 48| 44.15| 45.68| 3.71| 43.97|
|BinaryBot |94.3| 33| 35| 44| 41.29| 41.42| 2.87| 53.07|
|EnsureLead |93.8| 15| 16| 55| 42.56| 42.60| 4.04| 26.61|
|Roll6Timesv2 |92.9| 26| 28| 45| 40.71| 42.27| 4.07| 29.63|
|BringMyOwn_dice |92.1| 35| 38| 44| 40.32| 41.17| 4.09| 28.40|
|LizduadacBot |92.0| 23| 25| 54| 47.32| 51.43| 5.70| 5.18|
|FooBot |91.7| 22| 24| 44| 39.67| 41.45| 3.68| 51.80|
|Alpha |91.7| 33| 36| 48| 38.89| 42.42| 2.16| 65.34|
|QuotaBot |90.5| 19| 21| 53| 38.38| 42.42| 3.88| 24.65|
|GoBigEarly |88.5| 23| 26| 47| 41.35| 42.87| 3.33| 46.38|
|ExpectationsBot |88.0| 22| 25| 44| 39.08| 41.55| 3.57| 45.34|
|LeadBy5Bot |87.5| 21| 24| 50| 37.46| 42.81| 2.20| 63.88|
|GamblersFallacy |86.4| 19| 22| 44| 41.32| 41.58| 2.05| 63.11|
|BePrepared |86.4| 19| 22| 59| 39.59| 44.79| 3.81| 35.96|
|RollForLuckBot |85.7| 18| 21| 54| 41.95| 47.67| 4.68| 25.29|
|OneStepAheadBot |84.6| 22| 26| 50| 41.35| 46.00| 3.34| 42.97|
|FlipCoinRollDice |78.3| 18| 23| 51| 37.61| 44.72| 1.67| 75.42|
|BlessRNG |77.8| 28| 36| 47| 40.69| 41.89| 1.43| 83.66|
|FutureBot |77.4| 24| 31| 49| 40.16| 44.38| 2.41| 63.99|
|SlowStart |68.4| 26| 38| 57| 38.53| 45.31| 1.99| 66.15|
|NotTooFarBehindBot |66.7| 20| 30| 50| 37.27| 42.00| 1.29| 77.61|
|ThrowThriceBot |63.0| 17| 27| 51| 39.63| 44.76| 2.50| 55.67|
|OneInFiveBot |58.3| 14| 24| 54| 33.54| 44.86| 2.91| 50.19|
|MatchLeaderBot |48.1| 13| 27| 49| 40.15| 44.15| 1.22| 82.26|
|StopBot | 0.0| 0| 27| 43| 30.26| 0.00| 1.00| 82.77|
+---------------------+----+--------+--------+------+------+-------+------+--------+


Flaws



There are a couple of drawbacks to this cooperative approach. First, when playing against non-cooperative bots cooperative bots never get the first-turn advantage because when they do play first, they don't yet know whether or not their opponents are willing to cooperate, and thus have no choice but to get a score of zero. Similarly, this cooperative strategy is extremely vulnerable to exploitation by malicious bots; for instance, during cooperative play the bot who plays last in the last round can choose to stop rolling immediately to make everybody else lose (assuming, of course, that their first roll wasn't a six).



By cooperating, all bots can achieve the optimal solution of a 100% win rate. As such, if the win rate was the only thing that mattered then cooperation would be a stable equilibrium and there would be nothing to worry about. However, some bots might prioritize other goals, such as reaching the top of the leaderboard. This means that there is a risk that another bot might defect after your last turn, which creates an incentive for you to defect first. Because the setup of this competition doesn't allow us to see what our opponents did in their prior games, we can't penalize individuals that defected. Thus, cooperation is ultimately an unstable equilibrium doomed for failure.



Footnotes



[1]: The primary reasons why I don't want to submit thousands of bots instead of just two are that doing so would slow the simulation by a factor on the order of 1000 [2], and that doing so would significantly mess with win percentages as other bots would almost exclusively be playing against the swarm rather than each other. More important, however, is the fact that even if I wanted to I wouldn't be able to make that many bots in a reasonable time frame without breaking the spirit of the rule that "A bot must not implement the exact same strategy as an existing one, intentionally or accidentally".



[2]: I think there are two main reasons that the simulation slows down when running a cooperative swarm. First, more bots means more games if you want each bot to play in the same number of games (in the case study, the number of games would differ by a factor of about 77). Second, cooperative games just take longer because they last for a full 200 rounds, and within a round players have to keep rolling indefinitely. For my setup, games took about 40 times longer to simulate: the case study took a little over three minutes to run 10000 games, but after removing the cooperative swarm it would finish 10000 games in just 4.5 seconds. Between these two reasons, I estimate it would take about 3100 times longer to accurately measure the performance of bots when there is a swarm competing compared to when there isn't.






share|improve this answer










New contributor




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














  • 3




    Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
    – maxb
    Dec 22 at 16:37






  • 2




    I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
    – Einhaender
    Dec 22 at 17:09










  • Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
    – maxb
    Dec 22 at 17:10






  • 1




    I think your post is clear after reading it more thoroughly.
    – maxb
    Dec 22 at 17:11



















5














NotTooFarBehindBot



class NotTooFarBehindBot(Bot):
def make_throw(self, scores, last_round):
while True:
current_score = scores[self.index] + sum(self.current_throws)
number_of_bots_ahead = sum(1 for x in scores if x > current_score)
if number_of_bots_ahead > 1:
yield True
continue
if number_of_bots_ahead != 0 and last_round:
yield True
continue
break
yield False


The idea is that other bots may lose points, so being 2nd isn't bad - but if you're very behind, you might as well go for broke.






share|improve this answer










New contributor




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














  • 1




    Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
    – maxb
    Dec 19 at 13:31






  • 6




    I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
    – maxb
    Dec 19 at 13:49










  • Thanks - will make that change!
    – Stuart Moore
    Dec 19 at 13:52



















5














EnsureLead



class EnsureLead(Bot):

def make_throw(self, scores, last_round):
otherScores = scores[self.index+1:] + scores[:self.index]
maxOtherScore = max(otherScores)
maxOthersToCome = 0
for i in otherScores:
if (i >= 40): break
else: maxOthersToCome = max(maxOthersToCome, i)
while True:
currentScore = sum(self.current_throws)
totalScore = scores[self.index] + currentScore
if not last_round:
if totalScore >= 40:
if totalScore < maxOtherScore + 10:
yield True
else:
yield False
elif currentScore < 20:
yield True
else:
yield False
else:
if totalScore < maxOtherScore + 1:
yield True
elif totalScore < maxOthersToCome + 10:
yield True
else:
yield False


EnsureLead borrows ideas from GoTo20Bot. It adds the concept that it always considers (when in last_round or reaching 40) that there are others which will have at least one more roll. Thus, the bot tries to get a bit ahead of them, such that they have to catch up.






share|improve this answer










New contributor




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


























    4














    Alpha



    class Alpha(Bot):
    def make_throw(self, scores, last_round):
    # Throw until we're the best.
    while scores[self.index] + sum(self.current_throws) <= max(scores):
    yield True

    # Throw once more to assert dominance.
    yield True
    yield False


    Alpha refuses ever to be second to anyone. So long as there is a bot with a higher score, it will keep rolling.






    share|improve this answer























    • Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
      – Spitemaster
      Dec 19 at 17:14










    • @Spitemaster Fixed, thanks.
      – Mnemonic
      Dec 19 at 17:24



















    3














    FooBot



    class FooBot(Bot):
    def make_throw(self, scores, last_round):
    max_score = max(scores)

    while True:
    round_score = sum(self.current_throws)
    my_score = scores[self.index] + round_score

    if last_round:
    if my_score >= max_score:
    break
    else:
    if my_score >= self.end_score or round_score >= 16:
    break

    yield True

    yield False





    share|improve this answer























    • # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
      – Spitemaster
      Dec 19 at 15:50










    • Thanks. I was misled by the name of the method.
      – Peter Taylor
      Dec 19 at 16:00










    • @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
      – maxb
      Dec 20 at 9:02



















    3














    Go Big Early



    class GoBigEarly(Bot):
    def make_throw(self, scores, last_round):
    yield True # always do a 2nd roll
    while scores[self.index] + sum(self.current_throws) < 25:
    yield True
    yield False


    Concept: Try to win big on an early roll (getting to 25) then creep up from there 2 rolls at a time.






    share|improve this answer








    New contributor




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


























      3














      Roll6TimesV2



      Doesn't beat the current best, but I think it will fair better with more bots in play.



      class Roll6Timesv2(Bot):
      def make_throw(self, scores, last_round):

      if not last_round:
      i = 0
      maximum=6
      while ((i<maximum) and sum(self.current_throws)+scores[self.index]<=40 ):
      yield True
      i=i+1

      if last_round:
      while scores[self.index] + sum(self.current_throws) < max(scores):
      yield True
      yield False


      Really awesome game by the way.






      share|improve this answer










      New contributor




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


















      • Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
        – maxb
        Dec 19 at 20:05



















      3














      GoHomeBot



      class GoHomeBot(Bot):
      def make_throw(self, scores, last_round):
      while scores[self.index] + sum(self.current_throws) < 40:
      yield True
      yield False


      We want to go big or go home, right? GoHomeBot mostly just goes home. (But does surprisingly well!)






      share|improve this answer





















      • Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
        – maxb
        Dec 20 at 5:57










      • It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
        – Belhenix
        Dec 20 at 19:48



















      3














      PointsAreForNerdsBot



      class PointsAreForNerdsBot(Bot):
      def make_throw(self, scores, last_round):
      while True:
      yield True


      This one needs no explanation.



      OneInFiveBot



      class OneInFiveBot(Bot):
      def make_throw(self, scores, last_round):
      while random.randint(1,5) < 5:
      yield True
      yield False


      Keeps rolling until it rolls a five on it's own 5-sided die. Five is less than six, so it HAS TO WIN!






      share|improve this answer








      New contributor




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














      • 1




        Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
        – maxb
        Dec 20 at 8:34






      • 2




        the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
        – AKroell
        Dec 20 at 14:37










      • Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
        – Zacharý
        Dec 20 at 21:25












      • @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
        – The_Bob
        Dec 21 at 5:55






      • 2




        I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
        – Peter Taylor
        Dec 21 at 21:54



















      3














      StopBot



      class StopBot(Bot):
      def make_throw(self, scores, last_round):
      yield False


      Literally only one throw.



      This is equivalent to the base Bot class.






      share|improve this answer























      • Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
        – maxb
        Dec 19 at 19:42










      • I know, somebody had to post that bot though. Degenerate bots for the loss.
        – Zacharý
        Dec 19 at 21:04






      • 5




        I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
        – maxb
        Dec 20 at 8:28






      • 1




        IT WON A GAME?! That is surprising.
        – Zacharý
        Dec 20 at 21:17



















      3














      LizduadacBot



      Tries to win in 1 step. End condition is somewhat arbritrary.



      This is also my first post (and I'm new to Python), so if I beat "PointsAreForNerdsBot", I'd be happy!





      class LizduadacBot(Bot):

      def make_throw(self, scores, last_round):
      while scores[self.index] + sum(self.current_throws) < 50 or scores[self.index] + sum(self.current_throws) < max(scores):
      yield True
      yield False





      share|improve this answer










      New contributor




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


















      • Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
        – maxb
        Dec 21 at 23:30










      • By "hard time", they mean it's impossible (unless I misunderstood greatly)
        – Zacharý
        Dec 22 at 1:37










      • @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
        – lizduadac
        Dec 22 at 23:39



















      3














      SlowStart



      This bot implements the TCP Slow Start algorithm. It adjusts its number of rolls (nor) according to its previous turn: if it didn't roll a 6 in the previous turn, increases the nor for this turn; whereas it reduces nor if it did.



      class SlowStart(Bot):
      def __init__(self, *args):
      super().__init__(*args)
      self.completeLastRound = False
      self.nor = 1
      self.threshold = 8

      def updateValues(self):
      if self.completeLastRound:
      if self.nor < self.threshold:
      self.nor *= 2
      else:
      self.nor += 1
      else:
      self.threshold = self.nor // 2
      self.nor = 1


      def make_throw(self, scores, last_round):

      self.updateValues()
      self.completeLastRound = False

      i = 1
      while i < self.nor:
      yield True

      self.completeLastRound = True
      yield False





      share|improve this answer










      New contributor




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


















      • Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
        – maxb
        Dec 20 at 11:27






      • 2




        Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
        – maxb
        Dec 20 at 11:32










      • In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
        – maxb
        Dec 20 at 12:25



















      2














      BringMyOwn_dice (BMO_d)





      This bot loves dice, it brings 2 (seems to perform the best) dice of its own. Before throwing dice in a round, it throws its own 2 dice and computes their sum, this is the number of throws it is going to perform, it only throws if it doesn't already have 40 points.



      class BringMyOwn_dice(Bot):

      def __init__(self, *args):
      import random as rnd
      self.die = lambda: rnd.randint(1,6)
      super().__init__(*args)

      def make_throw(self, scores, last_round):

      nfaces = self.die() + self.die()

      s = scores[self.index]
      max_scores = max(scores)

      for _ in range(nfaces):
      if s + sum(self.current_throws) > 39:
      break
      yield True

      yield False





      share|improve this answer



















      • 2




        I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
        – maxb
        Dec 19 at 15:08



















      2














      QuotaBot



      A naive "quota" system I implemeneted, which actually seemed to score fairly highly overall.





      class QuotaBot(Bot):
      def __init__(self, *args):
      super().__init__(*args)
      self.quota = 20
      self.minquota = 15
      self.maxquota = 35

      def make_throw(self, scores, last_round):
      # Reduce quota if ahead, increase if behind
      mean = sum(scores) / len(scores)
      own_score = scores[self.index]

      if own_score < mean - 5:
      self.quota += 1.5
      if own_score > mean + 5:
      self.quota -= 1.5

      self.quota = max(min(self.quota, self.maxquota), self.minquota)

      if last_round:
      self.quota = max(scores) - own_score + 1

      while sum(self.current_throws) < self.quota:
      yield True

      yield False







      share|improve this answer























      • if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
        – Spitemaster
        Dec 19 at 17:05












      • @Spitemaster was an error pasting into stack exchange, should work now.
        – FlipTack
        Dec 19 at 17:09










      • @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
        – FlipTack
        Dec 19 at 17:09



















      2














      BinaryBot



      Tries to get close to the end score, so that as soon as somebody else triggers the last round it can beat their score for the win. Target is always halfway between current score and end score.





      class BinaryBot(Bot):

      def make_throw(self, scores, last_round):
      target = (self.end_score + scores[self.index]) / 2
      if last_round:
      target = max(scores)

      while scores[self.index] + sum(self.current_throws) < target:
      yield True

      yield False





      share|improve this answer























      • Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
        – Christian Sievers
        Dec 19 at 22:15



















      2














      BlessRNG



      class BlessRNG(Bot):
      def make_throw(self, scores, last_round):
      if random.randint(1,2) == 1 :
      yield True
      yield False


      BlessRNG FrankerZ GabeN BlessRNG






      share|improve this answer










      New contributor




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


























        1














        class ThrowThriceBot(Bot):

        def make_throw(self, scores, last_round):
        yield True
        yield True
        yield False


        Well, that one is obvious






        share|improve this answer





















        • I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
          – maxb
          Dec 19 at 13:21










        • Also, congratulations on your first KotH answer!
          – maxb
          Dec 19 at 13:34



















        1














        Hesitate



        class Hesitate(Bot):
        def make_throw(self, scores, last_round):
        myscore = scores[self.index]
        if last_round:
        target = max(scores)+1
        elif myscore==0:
        target = 17
        else:
        target = 35
        while myscore+sum(self.current_throws) < target:
        yield True
        yield False





        share|improve this answer





























          1














          class LastRound(Bot):
          def make_throw(self, scores, last_round):
          while sum(self.current_throws) < 15 and not last_round and scores[self.index] + sum(self.current_throws) < 40:
          yield True
          while max(scores) > scores[self.index] + sum(self.current_throws):
          yield True
          yield False


          LastRound acts like it's always the last round and it's the last bot: it keeps rolling until it's in the lead. It also doesn't want to settle for less than 15 points unless it actually is the last round or it reaches 40 points.






          share|improve this answer























          • Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
            – maxb
            Dec 19 at 12:44






          • 1




            I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
            – Stuart Moore
            Dec 19 at 14:09










          • @StuartMoore Haha, yes, I think you're right. Thanks!
            – Spitemaster
            Dec 19 at 15:07










          • I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
            – Stuart Moore
            Dec 19 at 15:15






          • 2




            That's intentional. It always tries to be in the lead when ending its turn.
            – Spitemaster
            Dec 19 at 15:48



















          1














          Take Five



          class TakeFive(Bot):
          def make_throw(self, scores, last_round):
          # Throw until we hit a 5.
          while self.current_throws[-1] != 5:
          # Don't get greedy.
          if scores[self.index] + sum(self.current_throws) >= self.end_score:
          break
          yield True

          # Go for the win on the last round.
          if last_round:
          while scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True

          yield False


          Half the time, we'll roll a 5 before a 6. When we do, cash out.






          share|improve this answer





















          • If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
            – Mnemonic
            Dec 19 at 21:08












          • In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
            – Spitemaster
            Dec 19 at 21:16



















          1














          ExpectationsBot



          Just plays it straight, calculates the expected value for the dice throw and only makes it if it's positive.





          class ExpectationsBot(Bot):

          def make_throw(self, scores, last_round):
          #Positive average gain is 2.5, is the chance of loss greater than that?
          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
          while 2.5 > (costOf6 / 6.0):
          yield True
          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
          yield False


          I was having trouble running the controller, got a "NameError: name 'bots_per_game' is not defined" on the multithreaded one, so really no idea how this performs.






          share|improve this answer



















          • 1




            I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
            – Stuart Moore
            Dec 19 at 17:47










          • @StuartMoore That...is a very true point, yes
            – Cain
            Dec 19 at 18:39










          • I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
            – maxb
            Dec 19 at 19:47










          • @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
            – Cain
            Dec 19 at 21:23



















          1














          FortyTeen



          class FortyTeen(Bot):
          def make_throw(self, scores, last_round):
          if last_round:
          max_projected_score = max([score+14 if score<self.end_score else score for score in scores])
          target = max_projected_score - scores[self.index]
          else:
          target = 14

          while sum(self.current_throws) < target:
          yield True
          yield False


          Try for 14 points until the last round, then assume everyone else is going to try for 14 points and try to tie that score.






          share|improve this answer























          • I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
            – tsh
            Dec 20 at 3:01










          • I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
            – maxb
            Dec 20 at 8:23










          • Oops, edited to fix.
            – histocrat
            Dec 20 at 13:08



















          1














          Chaser



          class Chaser(Bot):
          def make_throw(self, scores, last_round):
          while max(scores) > (scores[self.index] + sum(self.current_throws)):
          yield True
          while last_round and (scores[self.index] + sum(self.current_throws)) < 44:
          yield True
          while self.not_thrown_firce() and sum(self.current_throws, scores[self.index]) < 44:
          yield True
          yield False

          def not_thrown_firce(self):
          return len(self.current_throws) < 4


          Chaser tries to catch up to position one
          If it's the last round he desperately tries to reach at least 50 points
          Just for good measure he throws at least four times no matter what



          [edit 1: added go-for-gold strategy in the last round]



          [edit 2: updated logic because I mistakenly thought a bot would score at 40 rather than only the highest bot scoring]



          [edit 3: made chaser a little more defensive in the end game]






          share|improve this answer










          New contributor




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


















          • Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
            – maxb
            Dec 20 at 9:50










          • Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
            – AKroell
            Dec 20 at 10:02










          • @JonathanFrech thanks, fixed
            – AKroell
            Dec 20 at 12:38



















          1














          FutureBot



          class FutureBot(Bot):
          def make_throw(self, scores, last_round):
          while (random.randint(1,6) != 6) and (random.randint(1,6) != 6):
          current_score = scores[self.index] + sum(self.current_throws)
          if current_score > (self.end_score+5):
          break
          yield True
          yield False


          OneStepAheadBot



          class OneStepAheadBot(Bot):
          def make_throw(self, scores, last_round):
          while random.randint(1,6) != 6:
          current_score = scores[self.index] + sum(self.current_throws)
          if current_score > (self.end_score+5):
          break
          yield True
          yield False


          A pair of bots, they bring their own sets of dice and rolls them to predict the future. If one is a 6 they stop, FutureBot can't remember which of it's 2 dice was for the next roll so it gives up.



          I wonder which will do better.



          OneStepAhead is a little too similar to OneInFive for my taste, but I also want to see how it compares to FutureBot and OneInFive.



          Edit: Now they stop after hitting 45






          share|improve this answer










          New contributor




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


















          • Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
            – maxb
            Dec 20 at 16:31










          • Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
            – william porter
            Dec 20 at 16:34





















          1














          FlipCoinRollDice



          class FlipCoinRollDice(Bot):
          def make_throw(self, scores, last_round):
          while random.randint(1,2) == 2:
          throws = random.randint(1,6) != 6
          x = 0
          while x < throws:
          x = x + 1
          yield True
          yield False


          This is a weird (untested) one. It flips a coin and if it's heads it rolls a dice and throws the amount the dice shows.



          I can't test it now so if there are syntax errors, let me know :)






          share|improve this answer





















          • When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
            – maxb
            Dec 21 at 14:37










          • Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
            – Martijn Vissers
            Dec 21 at 14:57






          • 1




            Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
            – maxb
            Dec 21 at 15:02










          • Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
            – Belhenix
            Dec 21 at 16:53



















          1














          LeadBy5Bot



          class LeadBy5Bot(Bot):
          def make_throw(self, scores, last_round):
          while True:
          current_score = scores[self.index] + sum(self.current_throws)
          score_to_beat = max(scores) + 5
          if current_score >= score_to_beat:
          break
          yield True
          yield False


          Always wants to be in the lead by 5.



          Edit: New Bot



          RollForLuckBot



          class RollForLuckBot(Bot):

          def make_throw(self, scores, last_round):
          while sum(self.current_throws) < 21:
          yield True
          score_to_beat = max([x for i,x in enumerate(scores) if i!=self.index]) + 10
          score_to_beat = max(score_to_beat, 44)
          current_score = scores[self.index] + sum(self.current_throws)
          while (last_round or (current_score >= 40)):
          current_score = scores[self.index] + sum(self.current_throws)
          if current_score > score_to_beat:
          break
          yield True
          # roll more if we're feeling lucky
          while (random.randint(1,6) == self.current_throws[-1]):
          yield True
          yield False


          A bot that borrows from EnsureLead, I prefer using 21 as it's the average of 6d6 (6x3.5), with 6 dice rolls leaving > 70% chance of the next roll being a 6. Also, we continue to roll if we roll a separate die and match our last throw after hitting 21.






          share|improve this answer










          New contributor




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


















          • Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
            – william porter
            Dec 19 at 21:51










          • as a note, yield true should have upper T (python error)
            – Belhenix
            Dec 20 at 0:09










          • @Belhenix Edited, guess I missed that when I was typing it out.
            – william porter
            Dec 20 at 0:11










          • Woo, it made it into the top 50% (14 out of 28)
            – william porter
            Dec 20 at 17:35



















          1














          Stalker



          This bot tries to be within 4 points from the leader by the last round. Otherwise gets moderate gains



          class Stalker(Bot):

          def make_throw(self, scores, last_round):

          # on last round pray to rng gods to beat the highest score
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True

          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
          yield False

          # on the earlier rounds try to aim a moderate gain
          if max(scores) < 26:
          while sum(self.current_throws) < 16:
          yield True
          yield False

          # throw until 1 dice throw behind the leader
          target = max(scores) - 5

          while scores[self.index] + sum(self.current_throws) <= target:
          yield True
          yield False


          AgressiveStalker



          This one goes aggressive if he is leading late towards the end game, otherwise stalks



          class AggressiveStalker(Bot):

          def make_throw(self, scores, last_round):

          # on last round pray to rng gods to beat the highest score
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True

          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
          yield False

          # on the earlier rounds try to aim a moderate gain
          if max(scores) < 26:
          while sum(self.current_throws) < 16:
          yield True
          yield False


          # if we are leading go for the win
          if max(scores) > 25 and max(scores) == scores[self.index]:
          while scores[self.index] + sum(self.current_throws) < 40:
          yield True
          yield False

          # if we are behind throw until 1 dice throw behind the leader
          target = max(scores) - 5

          while scores[self.index] + sum(self.current_throws) <= target:
          yield True
          yield False





          share|improve this answer

















          • 1




            Very impressive securing the fifth place with AggressiveStalker!
            – maxb
            Dec 22 at 11:07















          1 2
          next



          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177765%2fa-game-of-dice-but-avoid-number-6%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          39 Answers
          39






          active

          oldest

          votes








          39 Answers
          39






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          1 2
          next










          13














          NeoBot



          Instead, only try to realize the truth - there is no spoon



          NeoBot peeks into the matrix (aka random) and predicts if the next roll will be a 6 or not - it can't do anything about being handed a 6 to start with but is more than happy to dodge a streak ender.



          NeoBot doesn't actually modify the controller or runtime, just politely asks the library for more information.



          class NeoBot(Bot):
          def __init__(self, index, end_score):
          self.random = None
          self.last_scores = None
          self.last_state = None
          super().__init__(index,end_score)

          def make_throw(self, scores, last_round):
          while True:
          if self.random is None:
          self.random = inspect.stack()[1][0].f_globals['random']
          tscores = scores[:self.index] + scores[self.index+1:]
          if self.last_scores != tscores:
          self.last_state = None
          self.last_scores = tscores
          future = self.predictnext_randint(self.random)
          if future == 6:
          yield False
          else:
          yield True

          def genrand_int32(self,base):
          base ^= (base >> 11)
          base ^= (base << 7) & 0x9d2c5680
          base ^= (base << 15) & 0xefc60000
          return base ^ (base >> 18)

          def predictnext_randint(self,cls):
          if self.last_state is None:
          self.last_state = list(cls.getstate()[1])
          ind = self.last_state[-1]
          width = 6
          res = width + 1
          while res >= width:
          y = self.last_state[ind]
          r = self.genrand_int32(y)
          res = r >> 29
          ind += 1
          self.last_state[-1] = (self.last_state[-1] + 1) % (len(self.last_state))
          return 1 + res





          share|improve this answer










          New contributor




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














          • 1




            Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
            – maxb
            yesterday






          • 1




            Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
            – maxb
            yesterday






          • 1




            Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
            – Mostly Harmless
            yesterday






          • 1




            thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
            – maxb
            yesterday


















          13














          NeoBot



          Instead, only try to realize the truth - there is no spoon



          NeoBot peeks into the matrix (aka random) and predicts if the next roll will be a 6 or not - it can't do anything about being handed a 6 to start with but is more than happy to dodge a streak ender.



          NeoBot doesn't actually modify the controller or runtime, just politely asks the library for more information.



          class NeoBot(Bot):
          def __init__(self, index, end_score):
          self.random = None
          self.last_scores = None
          self.last_state = None
          super().__init__(index,end_score)

          def make_throw(self, scores, last_round):
          while True:
          if self.random is None:
          self.random = inspect.stack()[1][0].f_globals['random']
          tscores = scores[:self.index] + scores[self.index+1:]
          if self.last_scores != tscores:
          self.last_state = None
          self.last_scores = tscores
          future = self.predictnext_randint(self.random)
          if future == 6:
          yield False
          else:
          yield True

          def genrand_int32(self,base):
          base ^= (base >> 11)
          base ^= (base << 7) & 0x9d2c5680
          base ^= (base << 15) & 0xefc60000
          return base ^ (base >> 18)

          def predictnext_randint(self,cls):
          if self.last_state is None:
          self.last_state = list(cls.getstate()[1])
          ind = self.last_state[-1]
          width = 6
          res = width + 1
          while res >= width:
          y = self.last_state[ind]
          r = self.genrand_int32(y)
          res = r >> 29
          ind += 1
          self.last_state[-1] = (self.last_state[-1] + 1) % (len(self.last_state))
          return 1 + res





          share|improve this answer










          New contributor




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














          • 1




            Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
            – maxb
            yesterday






          • 1




            Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
            – maxb
            yesterday






          • 1




            Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
            – Mostly Harmless
            yesterday






          • 1




            thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
            – maxb
            yesterday
















          13












          13








          13






          NeoBot



          Instead, only try to realize the truth - there is no spoon



          NeoBot peeks into the matrix (aka random) and predicts if the next roll will be a 6 or not - it can't do anything about being handed a 6 to start with but is more than happy to dodge a streak ender.



          NeoBot doesn't actually modify the controller or runtime, just politely asks the library for more information.



          class NeoBot(Bot):
          def __init__(self, index, end_score):
          self.random = None
          self.last_scores = None
          self.last_state = None
          super().__init__(index,end_score)

          def make_throw(self, scores, last_round):
          while True:
          if self.random is None:
          self.random = inspect.stack()[1][0].f_globals['random']
          tscores = scores[:self.index] + scores[self.index+1:]
          if self.last_scores != tscores:
          self.last_state = None
          self.last_scores = tscores
          future = self.predictnext_randint(self.random)
          if future == 6:
          yield False
          else:
          yield True

          def genrand_int32(self,base):
          base ^= (base >> 11)
          base ^= (base << 7) & 0x9d2c5680
          base ^= (base << 15) & 0xefc60000
          return base ^ (base >> 18)

          def predictnext_randint(self,cls):
          if self.last_state is None:
          self.last_state = list(cls.getstate()[1])
          ind = self.last_state[-1]
          width = 6
          res = width + 1
          while res >= width:
          y = self.last_state[ind]
          r = self.genrand_int32(y)
          res = r >> 29
          ind += 1
          self.last_state[-1] = (self.last_state[-1] + 1) % (len(self.last_state))
          return 1 + res





          share|improve this answer










          New contributor




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









          NeoBot



          Instead, only try to realize the truth - there is no spoon



          NeoBot peeks into the matrix (aka random) and predicts if the next roll will be a 6 or not - it can't do anything about being handed a 6 to start with but is more than happy to dodge a streak ender.



          NeoBot doesn't actually modify the controller or runtime, just politely asks the library for more information.



          class NeoBot(Bot):
          def __init__(self, index, end_score):
          self.random = None
          self.last_scores = None
          self.last_state = None
          super().__init__(index,end_score)

          def make_throw(self, scores, last_round):
          while True:
          if self.random is None:
          self.random = inspect.stack()[1][0].f_globals['random']
          tscores = scores[:self.index] + scores[self.index+1:]
          if self.last_scores != tscores:
          self.last_state = None
          self.last_scores = tscores
          future = self.predictnext_randint(self.random)
          if future == 6:
          yield False
          else:
          yield True

          def genrand_int32(self,base):
          base ^= (base >> 11)
          base ^= (base << 7) & 0x9d2c5680
          base ^= (base << 15) & 0xefc60000
          return base ^ (base >> 18)

          def predictnext_randint(self,cls):
          if self.last_state is None:
          self.last_state = list(cls.getstate()[1])
          ind = self.last_state[-1]
          width = 6
          res = width + 1
          while res >= width:
          y = self.last_state[ind]
          r = self.genrand_int32(y)
          res = r >> 29
          ind += 1
          self.last_state[-1] = (self.last_state[-1] + 1) % (len(self.last_state))
          return 1 + res






          share|improve this answer










          New contributor




          Mostly Harmless 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 2 days ago





















          New contributor




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









          answered 2 days ago









          Mostly Harmless

          2314




          2314




          New contributor




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





          New contributor





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






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








          • 1




            Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
            – maxb
            yesterday






          • 1




            Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
            – maxb
            yesterday






          • 1




            Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
            – Mostly Harmless
            yesterday






          • 1




            thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
            – maxb
            yesterday
















          • 1




            Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
            – maxb
            yesterday






          • 1




            Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
            – maxb
            yesterday






          • 1




            Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
            – Mostly Harmless
            yesterday






          • 1




            thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
            – maxb
            yesterday










          1




          1




          Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
          – maxb
          yesterday




          Welcome to PPCG! This is a really impressive answer. When I first ran it, I was bothered by the fact that it used the same amount of runtime as all other bots combined. Then I looked at the win percentage. Really clever way of skirting the rules. I will allow your bot to participate in the tournament, but I hope that others refrain from using the same tactic as this, as it violates the spirit of the game.
          – maxb
          yesterday




          1




          1




          Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
          – maxb
          yesterday




          Since there is such a huge gap between this bot and the second place, combined with the fact that your bot requires a lot of computing, would you accept that I run a simulation with fewer iterations to find your win rate, and then run the official simulation without your bot?
          – maxb
          yesterday




          1




          1




          Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
          – Mostly Harmless
          yesterday




          Fine by me, I figured going in that this was likely disqualifiable and definitely not quite in the spirit of the game. That being said, it was a blast to get working and a fun excuse to poke around in the python source code.
          – Mostly Harmless
          yesterday




          1




          1




          thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
          – maxb
          yesterday






          thanks! I don't think any other bot will get close to your score. And for anyone else thinking about implementing this strategy, don't. From now on this strategy is against the rules, and NeoBot is the only one allowed to use it for the sake of keeping the tournament fair.
          – maxb
          yesterday













          9














          GoTo20Bot



          class GoTo20Bot(Bot):

          def make_throw(self, scores, last_round):
          target = min(20, 40 - scores[self.index])
          if last_round:
          target = max(scores) - scores[self.index] + 1
          while sum(self.current_throws) < target:
          yield True
          yield False


          Just have a try with all GoToNBot's, And 20, 22, 24 plays best. I don't know why.





          Update: always stop throw if get score 40 or more.






          share|improve this answer























          • I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
            – maxb
            Dec 19 at 8:57










          • @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
            – tsh
            Dec 19 at 9:00










          • I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
            – maxb
            Dec 19 at 9:04






          • 2




            I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
            – maxb
            Dec 19 at 11:23






          • 1




            @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
            – tsh
            Dec 21 at 1:39


















          9














          GoTo20Bot



          class GoTo20Bot(Bot):

          def make_throw(self, scores, last_round):
          target = min(20, 40 - scores[self.index])
          if last_round:
          target = max(scores) - scores[self.index] + 1
          while sum(self.current_throws) < target:
          yield True
          yield False


          Just have a try with all GoToNBot's, And 20, 22, 24 plays best. I don't know why.





          Update: always stop throw if get score 40 or more.






          share|improve this answer























          • I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
            – maxb
            Dec 19 at 8:57










          • @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
            – tsh
            Dec 19 at 9:00










          • I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
            – maxb
            Dec 19 at 9:04






          • 2




            I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
            – maxb
            Dec 19 at 11:23






          • 1




            @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
            – tsh
            Dec 21 at 1:39
















          9












          9








          9






          GoTo20Bot



          class GoTo20Bot(Bot):

          def make_throw(self, scores, last_round):
          target = min(20, 40 - scores[self.index])
          if last_round:
          target = max(scores) - scores[self.index] + 1
          while sum(self.current_throws) < target:
          yield True
          yield False


          Just have a try with all GoToNBot's, And 20, 22, 24 plays best. I don't know why.





          Update: always stop throw if get score 40 or more.






          share|improve this answer














          GoTo20Bot



          class GoTo20Bot(Bot):

          def make_throw(self, scores, last_round):
          target = min(20, 40 - scores[self.index])
          if last_round:
          target = max(scores) - scores[self.index] + 1
          while sum(self.current_throws) < target:
          yield True
          yield False


          Just have a try with all GoToNBot's, And 20, 22, 24 plays best. I don't know why.





          Update: always stop throw if get score 40 or more.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 19 at 9:58

























          answered Dec 19 at 8:53









          tsh

          8,40511546




          8,40511546












          • I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
            – maxb
            Dec 19 at 8:57










          • @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
            – tsh
            Dec 19 at 9:00










          • I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
            – maxb
            Dec 19 at 9:04






          • 2




            I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
            – maxb
            Dec 19 at 11:23






          • 1




            @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
            – tsh
            Dec 21 at 1:39




















          • I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
            – maxb
            Dec 19 at 8:57










          • @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
            – tsh
            Dec 19 at 9:00










          • I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
            – maxb
            Dec 19 at 9:04






          • 2




            I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
            – maxb
            Dec 19 at 11:23






          • 1




            @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
            – tsh
            Dec 21 at 1:39


















          I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
          – maxb
          Dec 19 at 8:57




          I have also experimented with those kinds of bots. The highest average score per round is found when the bot goes to 16, but I'm assuming that the "end game" makes the 20-bot win more often.
          – maxb
          Dec 19 at 8:57












          @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
          – tsh
          Dec 19 at 9:00




          @maxb Not so, 20 still be the best one without the "end game" in my test. Maybe you had tested it on the old version of controller.
          – tsh
          Dec 19 at 9:00












          I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
          – maxb
          Dec 19 at 9:04




          I ran a separate test before designing this challenge, where I calculated the average score per round for the two tactics in my post ("throw x times" and "throw until x score"), and the maximum I found was for 15-16. Though my sample size could have been too small, I did notice instability.
          – maxb
          Dec 19 at 9:04




          2




          2




          I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
          – maxb
          Dec 19 at 11:23




          I have done some testing with this, and my conclusion is simply that 20 works well because it is 40/2. Though I'm not completely sure. When I set end_score to 4000 (and changed your bot to use this in the target calculation), the 15-16 bots were quite a lot better. But if the game was only about increasing your score it would be trivial.
          – maxb
          Dec 19 at 11:23




          1




          1




          @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
          – tsh
          Dec 21 at 1:39






          @maxb If end_score is 4000, it is almost impossible to get 4000 before 200 turns. And the game is simply who got the highest score in 200 turns. And stop at 15 should works will since this time the strategy for highest score in one turn is as same as highest score in 200 turns.
          – tsh
          Dec 21 at 1:39













          9














          Adaptive Roller



          Starts out more aggressive and calms down towards the end of the round.

          If it believes it's winning, roll an extra time for safety.



          class AdaptiveRoller(Bot):

          def make_throw(self, scores, last_round):
          lim = min(self.end_score - scores[self.index], 22)
          while sum(self.current_throws) < lim:
          yield True
          if max(scores) == scores[self.index] and max(scores) >= self.end_score:
          yield True
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True
          yield False





          share|improve this answer























          • Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
            – maxb
            Dec 19 at 8:51










          • I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
            – AKroell
            Dec 20 at 16:25










          • @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
            – Emigna
            Dec 20 at 17:50
















          9














          Adaptive Roller



          Starts out more aggressive and calms down towards the end of the round.

          If it believes it's winning, roll an extra time for safety.



          class AdaptiveRoller(Bot):

          def make_throw(self, scores, last_round):
          lim = min(self.end_score - scores[self.index], 22)
          while sum(self.current_throws) < lim:
          yield True
          if max(scores) == scores[self.index] and max(scores) >= self.end_score:
          yield True
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True
          yield False





          share|improve this answer























          • Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
            – maxb
            Dec 19 at 8:51










          • I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
            – AKroell
            Dec 20 at 16:25










          • @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
            – Emigna
            Dec 20 at 17:50














          9












          9








          9






          Adaptive Roller



          Starts out more aggressive and calms down towards the end of the round.

          If it believes it's winning, roll an extra time for safety.



          class AdaptiveRoller(Bot):

          def make_throw(self, scores, last_round):
          lim = min(self.end_score - scores[self.index], 22)
          while sum(self.current_throws) < lim:
          yield True
          if max(scores) == scores[self.index] and max(scores) >= self.end_score:
          yield True
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True
          yield False





          share|improve this answer














          Adaptive Roller



          Starts out more aggressive and calms down towards the end of the round.

          If it believes it's winning, roll an extra time for safety.



          class AdaptiveRoller(Bot):

          def make_throw(self, scores, last_round):
          lim = min(self.end_score - scores[self.index], 22)
          while sum(self.current_throws) < lim:
          yield True
          if max(scores) == scores[self.index] and max(scores) >= self.end_score:
          yield True
          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
          yield True
          yield False






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 19 at 14:51

























          answered Dec 19 at 8:44









          Emigna

          45.3k432138




          45.3k432138












          • Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
            – maxb
            Dec 19 at 8:51










          • I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
            – AKroell
            Dec 20 at 16:25










          • @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
            – Emigna
            Dec 20 at 17:50


















          • Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
            – maxb
            Dec 19 at 8:51










          • I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
            – AKroell
            Dec 20 at 16:25










          • @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
            – Emigna
            Dec 20 at 17:50
















          Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
          – maxb
          Dec 19 at 8:51




          Great first submission! I'll run it against my bots I wrote for testing, but I'll update the highscore when more bots have been posted.
          – maxb
          Dec 19 at 8:51












          I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
          – AKroell
          Dec 20 at 16:25




          I ran some tests with slight modifications to your bot. lim = max(min(self.end_score - scores[self.index], 24), 6) raising the maximum to 24 and adding a minimum of 6 both increase the winning percentage on their own and even more so combined.
          – AKroell
          Dec 20 at 16:25












          @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
          – Emigna
          Dec 20 at 17:50




          @AKroell: Cool! I have intended to do something similar to make sure that it rolls a few times at the end, but I haven't taken myself the time to do it yet. Weirdly though, it seems to perform worse with those values when I do 100k runs. I've only tested with 18 bots though. Maybe I should do some tests with all bots.
          – Emigna
          Dec 20 at 17:50











          9














          Cooperative Swarm



          Strategy



          I don't think anyone else has yet noticed the significance of this rule:




          If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.




          If every bot always rolled until they busted, then everyone would have a score of zero at the end of round 200 and everybody would win! Thus, the Cooperative Swarm's strategy is to cooperate as long as all players have a score of zero, but to play normally if anybody scores any points.



          In this post, I am submitting two bots: the first is CooperativeSwarmBot, and the second is CooperativeThrowTwice. CooperativeSwarmBot serves as a base class for all bots that are formally part of the cooperative swarm, and has placeholder behavior of simply accepting its first successful roll when cooperation fails. CooperativeSwarmBot has CooperativeSwarmBot as its parent and is identical to it in every way except that its non-cooperative behavior is to make two rolls instead of one. In the next few days I will be revising this post to add new bots that use much more intelligent behavior playing against non-cooperative bots.



          Code



          class CooperativeSwarmBot(Bot):
          def defection_strategy(self, scores, last_round):
          yield False

          def make_throw(self, scores, last_round):
          cooperate = max(scores) == 0
          if (cooperate):
          while True:
          yield True
          else:
          yield from self.defection_strategy(scores, last_round)

          class CooperativeThrowTwice(CooperativeSwarmBot):
          def defection_strategy(self, scores, last_round):
          yield True
          yield False


          Analysis



          Viability



          It is very hard to cooperate in this game because we need the support of all eight players for it to work. Since each bot class is limited to one instance per game, this is a hard goal to achieve. For example, the odds of choosing eight cooperative bots from a pool of 100 cooperative bots and 30 non-cooperative bots is:



          $$frac{100}{130} * frac{99}{129} * frac{98}{128} * frac{97}{127} * frac{96}{126} * frac{95}{125} * frac{94}{124} * frac{93}{123} approx 0.115$$



          More generally, the odds of choosing $i$ cooperative bots from a pool of $c$ cooperative bots and $n$ noncooperative bots is:



          $$frac{c! div (c - i)!}{(c+n)! div (c + n - i)!}$$



          From this equation we can easily show that we would need about 430 cooperative bots in order for 50% of games to end cooperatively, or about 2900 bots for 90% (using $i = 8$ as per the rules, and $n = 38$).



          Case Study



          For a number of reasons (see footnotes 1 and 2), a proper cooperative swarm will never compete in the official games. As such, I'll be summarizing the results of one of my own simulations in this section.



          This simulation ran 10000 games using the 38 other bots that had been posted here the last time I checked and 2900 bots that had CooperativeSwarmBot as their parent class. The controller reported that 9051 of the 10000 games (90.51%) ended at 200 rounds, which is quite close to the prediction that 90% of games would be cooperative. The implementation of these bots was trivial; other than CooperativeSwarmBot they all took this form:



          class CooperativeSwarm_1234(CooperativeSwarmBot):
          pass


          Less that 3% of the bots had a win percentage that was below 80%, and just over 11% of the bots won every single game they played. The median win percentage of the 2900 bots in the swarm is about 86%, which is outrageously good. For comparison, the top performers on the current official leaderboard win less than 22% of their games. I can't fit the full listing of the cooperative swarm within the maximum allowed length for an answer, so if you want to view that you'll have to go here instead: https://pastebin.com/3Zc8m1Ex



          Since each bot played in an average of about 27 games, luck plays a relatively large roll when you look at the results for individual bots. As I have not yet implemented an advanced strategy for non-cooperative games, most other bots benefited drastically from playing against the cooperative swarm, performing even the cooperative swarm's median win rate of 86%.



          The full results for bots that aren't in the swarm are listed below; there are two bots whose results I think deserve particular attention. First, StopBot failed to win any games at all. This is particularly tragic because the cooperative swarm was actually using the exact same strategy as StopBot was; you would have expected StopBot to win an eight of its games by chance, and a little bit more because the cooperative swarm is forced to give its opponents the first move. The second interesting result, however, is that PointsAreForNerdsBot's hard work finally paid off: it cooperated with the swarm and managed to win every single game it played!



          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |AggressiveStalker |100.0| 21| 21| 42| 40.71| 40.71| 3.48| 46.32|
          |PointsAreForNerdsBot |100.0| 31| 31| 0| 0.00| 0.00| 6.02| 0.00|
          |TakeFive |100.0| 18| 18| 44| 41.94| 41.94| 2.61| 50.93|
          |Hesitate |100.0| 26| 26| 44| 41.27| 41.27| 3.32| 41.89|
          |Crush |100.0| 34| 34| 44| 41.15| 41.15| 5.38| 6.73|
          |StepBot |97.0| 32| 33| 46| 41.15| 42.44| 4.51| 24.54|
          |LastRound |96.8| 30| 31| 44| 40.32| 41.17| 3.54| 45.05|
          |Chaser |96.8| 30| 31| 47| 42.90| 44.33| 3.04| 52.16|
          |GoHomeBot |96.8| 30| 31| 44| 40.32| 41.67| 5.60| 9.71|
          |Stalker |96.4| 27| 28| 44| 41.18| 41.44| 2.88| 57.53|
          |ClunkyChicken |96.2| 25| 26| 44| 40.96| 41.88| 2.32| 61.23|
          |AdaptiveRoller |96.0| 24| 25| 44| 39.32| 40.96| 4.49| 27.43|
          |GoTo20Bot |95.5| 21| 22| 44| 40.36| 41.33| 4.60| 30.50|
          |FortyTeen |95.0| 19| 20| 48| 44.15| 45.68| 3.71| 43.97|
          |BinaryBot |94.3| 33| 35| 44| 41.29| 41.42| 2.87| 53.07|
          |EnsureLead |93.8| 15| 16| 55| 42.56| 42.60| 4.04| 26.61|
          |Roll6Timesv2 |92.9| 26| 28| 45| 40.71| 42.27| 4.07| 29.63|
          |BringMyOwn_dice |92.1| 35| 38| 44| 40.32| 41.17| 4.09| 28.40|
          |LizduadacBot |92.0| 23| 25| 54| 47.32| 51.43| 5.70| 5.18|
          |FooBot |91.7| 22| 24| 44| 39.67| 41.45| 3.68| 51.80|
          |Alpha |91.7| 33| 36| 48| 38.89| 42.42| 2.16| 65.34|
          |QuotaBot |90.5| 19| 21| 53| 38.38| 42.42| 3.88| 24.65|
          |GoBigEarly |88.5| 23| 26| 47| 41.35| 42.87| 3.33| 46.38|
          |ExpectationsBot |88.0| 22| 25| 44| 39.08| 41.55| 3.57| 45.34|
          |LeadBy5Bot |87.5| 21| 24| 50| 37.46| 42.81| 2.20| 63.88|
          |GamblersFallacy |86.4| 19| 22| 44| 41.32| 41.58| 2.05| 63.11|
          |BePrepared |86.4| 19| 22| 59| 39.59| 44.79| 3.81| 35.96|
          |RollForLuckBot |85.7| 18| 21| 54| 41.95| 47.67| 4.68| 25.29|
          |OneStepAheadBot |84.6| 22| 26| 50| 41.35| 46.00| 3.34| 42.97|
          |FlipCoinRollDice |78.3| 18| 23| 51| 37.61| 44.72| 1.67| 75.42|
          |BlessRNG |77.8| 28| 36| 47| 40.69| 41.89| 1.43| 83.66|
          |FutureBot |77.4| 24| 31| 49| 40.16| 44.38| 2.41| 63.99|
          |SlowStart |68.4| 26| 38| 57| 38.53| 45.31| 1.99| 66.15|
          |NotTooFarBehindBot |66.7| 20| 30| 50| 37.27| 42.00| 1.29| 77.61|
          |ThrowThriceBot |63.0| 17| 27| 51| 39.63| 44.76| 2.50| 55.67|
          |OneInFiveBot |58.3| 14| 24| 54| 33.54| 44.86| 2.91| 50.19|
          |MatchLeaderBot |48.1| 13| 27| 49| 40.15| 44.15| 1.22| 82.26|
          |StopBot | 0.0| 0| 27| 43| 30.26| 0.00| 1.00| 82.77|
          +---------------------+----+--------+--------+------+------+-------+------+--------+


          Flaws



          There are a couple of drawbacks to this cooperative approach. First, when playing against non-cooperative bots cooperative bots never get the first-turn advantage because when they do play first, they don't yet know whether or not their opponents are willing to cooperate, and thus have no choice but to get a score of zero. Similarly, this cooperative strategy is extremely vulnerable to exploitation by malicious bots; for instance, during cooperative play the bot who plays last in the last round can choose to stop rolling immediately to make everybody else lose (assuming, of course, that their first roll wasn't a six).



          By cooperating, all bots can achieve the optimal solution of a 100% win rate. As such, if the win rate was the only thing that mattered then cooperation would be a stable equilibrium and there would be nothing to worry about. However, some bots might prioritize other goals, such as reaching the top of the leaderboard. This means that there is a risk that another bot might defect after your last turn, which creates an incentive for you to defect first. Because the setup of this competition doesn't allow us to see what our opponents did in their prior games, we can't penalize individuals that defected. Thus, cooperation is ultimately an unstable equilibrium doomed for failure.



          Footnotes



          [1]: The primary reasons why I don't want to submit thousands of bots instead of just two are that doing so would slow the simulation by a factor on the order of 1000 [2], and that doing so would significantly mess with win percentages as other bots would almost exclusively be playing against the swarm rather than each other. More important, however, is the fact that even if I wanted to I wouldn't be able to make that many bots in a reasonable time frame without breaking the spirit of the rule that "A bot must not implement the exact same strategy as an existing one, intentionally or accidentally".



          [2]: I think there are two main reasons that the simulation slows down when running a cooperative swarm. First, more bots means more games if you want each bot to play in the same number of games (in the case study, the number of games would differ by a factor of about 77). Second, cooperative games just take longer because they last for a full 200 rounds, and within a round players have to keep rolling indefinitely. For my setup, games took about 40 times longer to simulate: the case study took a little over three minutes to run 10000 games, but after removing the cooperative swarm it would finish 10000 games in just 4.5 seconds. Between these two reasons, I estimate it would take about 3100 times longer to accurately measure the performance of bots when there is a swarm competing compared to when there isn't.






          share|improve this answer










          New contributor




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














          • 3




            Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
            – maxb
            Dec 22 at 16:37






          • 2




            I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
            – Einhaender
            Dec 22 at 17:09










          • Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
            – maxb
            Dec 22 at 17:10






          • 1




            I think your post is clear after reading it more thoroughly.
            – maxb
            Dec 22 at 17:11
















          9














          Cooperative Swarm



          Strategy



          I don't think anyone else has yet noticed the significance of this rule:




          If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.




          If every bot always rolled until they busted, then everyone would have a score of zero at the end of round 200 and everybody would win! Thus, the Cooperative Swarm's strategy is to cooperate as long as all players have a score of zero, but to play normally if anybody scores any points.



          In this post, I am submitting two bots: the first is CooperativeSwarmBot, and the second is CooperativeThrowTwice. CooperativeSwarmBot serves as a base class for all bots that are formally part of the cooperative swarm, and has placeholder behavior of simply accepting its first successful roll when cooperation fails. CooperativeSwarmBot has CooperativeSwarmBot as its parent and is identical to it in every way except that its non-cooperative behavior is to make two rolls instead of one. In the next few days I will be revising this post to add new bots that use much more intelligent behavior playing against non-cooperative bots.



          Code



          class CooperativeSwarmBot(Bot):
          def defection_strategy(self, scores, last_round):
          yield False

          def make_throw(self, scores, last_round):
          cooperate = max(scores) == 0
          if (cooperate):
          while True:
          yield True
          else:
          yield from self.defection_strategy(scores, last_round)

          class CooperativeThrowTwice(CooperativeSwarmBot):
          def defection_strategy(self, scores, last_round):
          yield True
          yield False


          Analysis



          Viability



          It is very hard to cooperate in this game because we need the support of all eight players for it to work. Since each bot class is limited to one instance per game, this is a hard goal to achieve. For example, the odds of choosing eight cooperative bots from a pool of 100 cooperative bots and 30 non-cooperative bots is:



          $$frac{100}{130} * frac{99}{129} * frac{98}{128} * frac{97}{127} * frac{96}{126} * frac{95}{125} * frac{94}{124} * frac{93}{123} approx 0.115$$



          More generally, the odds of choosing $i$ cooperative bots from a pool of $c$ cooperative bots and $n$ noncooperative bots is:



          $$frac{c! div (c - i)!}{(c+n)! div (c + n - i)!}$$



          From this equation we can easily show that we would need about 430 cooperative bots in order for 50% of games to end cooperatively, or about 2900 bots for 90% (using $i = 8$ as per the rules, and $n = 38$).



          Case Study



          For a number of reasons (see footnotes 1 and 2), a proper cooperative swarm will never compete in the official games. As such, I'll be summarizing the results of one of my own simulations in this section.



          This simulation ran 10000 games using the 38 other bots that had been posted here the last time I checked and 2900 bots that had CooperativeSwarmBot as their parent class. The controller reported that 9051 of the 10000 games (90.51%) ended at 200 rounds, which is quite close to the prediction that 90% of games would be cooperative. The implementation of these bots was trivial; other than CooperativeSwarmBot they all took this form:



          class CooperativeSwarm_1234(CooperativeSwarmBot):
          pass


          Less that 3% of the bots had a win percentage that was below 80%, and just over 11% of the bots won every single game they played. The median win percentage of the 2900 bots in the swarm is about 86%, which is outrageously good. For comparison, the top performers on the current official leaderboard win less than 22% of their games. I can't fit the full listing of the cooperative swarm within the maximum allowed length for an answer, so if you want to view that you'll have to go here instead: https://pastebin.com/3Zc8m1Ex



          Since each bot played in an average of about 27 games, luck plays a relatively large roll when you look at the results for individual bots. As I have not yet implemented an advanced strategy for non-cooperative games, most other bots benefited drastically from playing against the cooperative swarm, performing even the cooperative swarm's median win rate of 86%.



          The full results for bots that aren't in the swarm are listed below; there are two bots whose results I think deserve particular attention. First, StopBot failed to win any games at all. This is particularly tragic because the cooperative swarm was actually using the exact same strategy as StopBot was; you would have expected StopBot to win an eight of its games by chance, and a little bit more because the cooperative swarm is forced to give its opponents the first move. The second interesting result, however, is that PointsAreForNerdsBot's hard work finally paid off: it cooperated with the swarm and managed to win every single game it played!



          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |AggressiveStalker |100.0| 21| 21| 42| 40.71| 40.71| 3.48| 46.32|
          |PointsAreForNerdsBot |100.0| 31| 31| 0| 0.00| 0.00| 6.02| 0.00|
          |TakeFive |100.0| 18| 18| 44| 41.94| 41.94| 2.61| 50.93|
          |Hesitate |100.0| 26| 26| 44| 41.27| 41.27| 3.32| 41.89|
          |Crush |100.0| 34| 34| 44| 41.15| 41.15| 5.38| 6.73|
          |StepBot |97.0| 32| 33| 46| 41.15| 42.44| 4.51| 24.54|
          |LastRound |96.8| 30| 31| 44| 40.32| 41.17| 3.54| 45.05|
          |Chaser |96.8| 30| 31| 47| 42.90| 44.33| 3.04| 52.16|
          |GoHomeBot |96.8| 30| 31| 44| 40.32| 41.67| 5.60| 9.71|
          |Stalker |96.4| 27| 28| 44| 41.18| 41.44| 2.88| 57.53|
          |ClunkyChicken |96.2| 25| 26| 44| 40.96| 41.88| 2.32| 61.23|
          |AdaptiveRoller |96.0| 24| 25| 44| 39.32| 40.96| 4.49| 27.43|
          |GoTo20Bot |95.5| 21| 22| 44| 40.36| 41.33| 4.60| 30.50|
          |FortyTeen |95.0| 19| 20| 48| 44.15| 45.68| 3.71| 43.97|
          |BinaryBot |94.3| 33| 35| 44| 41.29| 41.42| 2.87| 53.07|
          |EnsureLead |93.8| 15| 16| 55| 42.56| 42.60| 4.04| 26.61|
          |Roll6Timesv2 |92.9| 26| 28| 45| 40.71| 42.27| 4.07| 29.63|
          |BringMyOwn_dice |92.1| 35| 38| 44| 40.32| 41.17| 4.09| 28.40|
          |LizduadacBot |92.0| 23| 25| 54| 47.32| 51.43| 5.70| 5.18|
          |FooBot |91.7| 22| 24| 44| 39.67| 41.45| 3.68| 51.80|
          |Alpha |91.7| 33| 36| 48| 38.89| 42.42| 2.16| 65.34|
          |QuotaBot |90.5| 19| 21| 53| 38.38| 42.42| 3.88| 24.65|
          |GoBigEarly |88.5| 23| 26| 47| 41.35| 42.87| 3.33| 46.38|
          |ExpectationsBot |88.0| 22| 25| 44| 39.08| 41.55| 3.57| 45.34|
          |LeadBy5Bot |87.5| 21| 24| 50| 37.46| 42.81| 2.20| 63.88|
          |GamblersFallacy |86.4| 19| 22| 44| 41.32| 41.58| 2.05| 63.11|
          |BePrepared |86.4| 19| 22| 59| 39.59| 44.79| 3.81| 35.96|
          |RollForLuckBot |85.7| 18| 21| 54| 41.95| 47.67| 4.68| 25.29|
          |OneStepAheadBot |84.6| 22| 26| 50| 41.35| 46.00| 3.34| 42.97|
          |FlipCoinRollDice |78.3| 18| 23| 51| 37.61| 44.72| 1.67| 75.42|
          |BlessRNG |77.8| 28| 36| 47| 40.69| 41.89| 1.43| 83.66|
          |FutureBot |77.4| 24| 31| 49| 40.16| 44.38| 2.41| 63.99|
          |SlowStart |68.4| 26| 38| 57| 38.53| 45.31| 1.99| 66.15|
          |NotTooFarBehindBot |66.7| 20| 30| 50| 37.27| 42.00| 1.29| 77.61|
          |ThrowThriceBot |63.0| 17| 27| 51| 39.63| 44.76| 2.50| 55.67|
          |OneInFiveBot |58.3| 14| 24| 54| 33.54| 44.86| 2.91| 50.19|
          |MatchLeaderBot |48.1| 13| 27| 49| 40.15| 44.15| 1.22| 82.26|
          |StopBot | 0.0| 0| 27| 43| 30.26| 0.00| 1.00| 82.77|
          +---------------------+----+--------+--------+------+------+-------+------+--------+


          Flaws



          There are a couple of drawbacks to this cooperative approach. First, when playing against non-cooperative bots cooperative bots never get the first-turn advantage because when they do play first, they don't yet know whether or not their opponents are willing to cooperate, and thus have no choice but to get a score of zero. Similarly, this cooperative strategy is extremely vulnerable to exploitation by malicious bots; for instance, during cooperative play the bot who plays last in the last round can choose to stop rolling immediately to make everybody else lose (assuming, of course, that their first roll wasn't a six).



          By cooperating, all bots can achieve the optimal solution of a 100% win rate. As such, if the win rate was the only thing that mattered then cooperation would be a stable equilibrium and there would be nothing to worry about. However, some bots might prioritize other goals, such as reaching the top of the leaderboard. This means that there is a risk that another bot might defect after your last turn, which creates an incentive for you to defect first. Because the setup of this competition doesn't allow us to see what our opponents did in their prior games, we can't penalize individuals that defected. Thus, cooperation is ultimately an unstable equilibrium doomed for failure.



          Footnotes



          [1]: The primary reasons why I don't want to submit thousands of bots instead of just two are that doing so would slow the simulation by a factor on the order of 1000 [2], and that doing so would significantly mess with win percentages as other bots would almost exclusively be playing against the swarm rather than each other. More important, however, is the fact that even if I wanted to I wouldn't be able to make that many bots in a reasonable time frame without breaking the spirit of the rule that "A bot must not implement the exact same strategy as an existing one, intentionally or accidentally".



          [2]: I think there are two main reasons that the simulation slows down when running a cooperative swarm. First, more bots means more games if you want each bot to play in the same number of games (in the case study, the number of games would differ by a factor of about 77). Second, cooperative games just take longer because they last for a full 200 rounds, and within a round players have to keep rolling indefinitely. For my setup, games took about 40 times longer to simulate: the case study took a little over three minutes to run 10000 games, but after removing the cooperative swarm it would finish 10000 games in just 4.5 seconds. Between these two reasons, I estimate it would take about 3100 times longer to accurately measure the performance of bots when there is a swarm competing compared to when there isn't.






          share|improve this answer










          New contributor




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














          • 3




            Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
            – maxb
            Dec 22 at 16:37






          • 2




            I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
            – Einhaender
            Dec 22 at 17:09










          • Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
            – maxb
            Dec 22 at 17:10






          • 1




            I think your post is clear after reading it more thoroughly.
            – maxb
            Dec 22 at 17:11














          9












          9








          9






          Cooperative Swarm



          Strategy



          I don't think anyone else has yet noticed the significance of this rule:




          If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.




          If every bot always rolled until they busted, then everyone would have a score of zero at the end of round 200 and everybody would win! Thus, the Cooperative Swarm's strategy is to cooperate as long as all players have a score of zero, but to play normally if anybody scores any points.



          In this post, I am submitting two bots: the first is CooperativeSwarmBot, and the second is CooperativeThrowTwice. CooperativeSwarmBot serves as a base class for all bots that are formally part of the cooperative swarm, and has placeholder behavior of simply accepting its first successful roll when cooperation fails. CooperativeSwarmBot has CooperativeSwarmBot as its parent and is identical to it in every way except that its non-cooperative behavior is to make two rolls instead of one. In the next few days I will be revising this post to add new bots that use much more intelligent behavior playing against non-cooperative bots.



          Code



          class CooperativeSwarmBot(Bot):
          def defection_strategy(self, scores, last_round):
          yield False

          def make_throw(self, scores, last_round):
          cooperate = max(scores) == 0
          if (cooperate):
          while True:
          yield True
          else:
          yield from self.defection_strategy(scores, last_round)

          class CooperativeThrowTwice(CooperativeSwarmBot):
          def defection_strategy(self, scores, last_round):
          yield True
          yield False


          Analysis



          Viability



          It is very hard to cooperate in this game because we need the support of all eight players for it to work. Since each bot class is limited to one instance per game, this is a hard goal to achieve. For example, the odds of choosing eight cooperative bots from a pool of 100 cooperative bots and 30 non-cooperative bots is:



          $$frac{100}{130} * frac{99}{129} * frac{98}{128} * frac{97}{127} * frac{96}{126} * frac{95}{125} * frac{94}{124} * frac{93}{123} approx 0.115$$



          More generally, the odds of choosing $i$ cooperative bots from a pool of $c$ cooperative bots and $n$ noncooperative bots is:



          $$frac{c! div (c - i)!}{(c+n)! div (c + n - i)!}$$



          From this equation we can easily show that we would need about 430 cooperative bots in order for 50% of games to end cooperatively, or about 2900 bots for 90% (using $i = 8$ as per the rules, and $n = 38$).



          Case Study



          For a number of reasons (see footnotes 1 and 2), a proper cooperative swarm will never compete in the official games. As such, I'll be summarizing the results of one of my own simulations in this section.



          This simulation ran 10000 games using the 38 other bots that had been posted here the last time I checked and 2900 bots that had CooperativeSwarmBot as their parent class. The controller reported that 9051 of the 10000 games (90.51%) ended at 200 rounds, which is quite close to the prediction that 90% of games would be cooperative. The implementation of these bots was trivial; other than CooperativeSwarmBot they all took this form:



          class CooperativeSwarm_1234(CooperativeSwarmBot):
          pass


          Less that 3% of the bots had a win percentage that was below 80%, and just over 11% of the bots won every single game they played. The median win percentage of the 2900 bots in the swarm is about 86%, which is outrageously good. For comparison, the top performers on the current official leaderboard win less than 22% of their games. I can't fit the full listing of the cooperative swarm within the maximum allowed length for an answer, so if you want to view that you'll have to go here instead: https://pastebin.com/3Zc8m1Ex



          Since each bot played in an average of about 27 games, luck plays a relatively large roll when you look at the results for individual bots. As I have not yet implemented an advanced strategy for non-cooperative games, most other bots benefited drastically from playing against the cooperative swarm, performing even the cooperative swarm's median win rate of 86%.



          The full results for bots that aren't in the swarm are listed below; there are two bots whose results I think deserve particular attention. First, StopBot failed to win any games at all. This is particularly tragic because the cooperative swarm was actually using the exact same strategy as StopBot was; you would have expected StopBot to win an eight of its games by chance, and a little bit more because the cooperative swarm is forced to give its opponents the first move. The second interesting result, however, is that PointsAreForNerdsBot's hard work finally paid off: it cooperated with the swarm and managed to win every single game it played!



          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |AggressiveStalker |100.0| 21| 21| 42| 40.71| 40.71| 3.48| 46.32|
          |PointsAreForNerdsBot |100.0| 31| 31| 0| 0.00| 0.00| 6.02| 0.00|
          |TakeFive |100.0| 18| 18| 44| 41.94| 41.94| 2.61| 50.93|
          |Hesitate |100.0| 26| 26| 44| 41.27| 41.27| 3.32| 41.89|
          |Crush |100.0| 34| 34| 44| 41.15| 41.15| 5.38| 6.73|
          |StepBot |97.0| 32| 33| 46| 41.15| 42.44| 4.51| 24.54|
          |LastRound |96.8| 30| 31| 44| 40.32| 41.17| 3.54| 45.05|
          |Chaser |96.8| 30| 31| 47| 42.90| 44.33| 3.04| 52.16|
          |GoHomeBot |96.8| 30| 31| 44| 40.32| 41.67| 5.60| 9.71|
          |Stalker |96.4| 27| 28| 44| 41.18| 41.44| 2.88| 57.53|
          |ClunkyChicken |96.2| 25| 26| 44| 40.96| 41.88| 2.32| 61.23|
          |AdaptiveRoller |96.0| 24| 25| 44| 39.32| 40.96| 4.49| 27.43|
          |GoTo20Bot |95.5| 21| 22| 44| 40.36| 41.33| 4.60| 30.50|
          |FortyTeen |95.0| 19| 20| 48| 44.15| 45.68| 3.71| 43.97|
          |BinaryBot |94.3| 33| 35| 44| 41.29| 41.42| 2.87| 53.07|
          |EnsureLead |93.8| 15| 16| 55| 42.56| 42.60| 4.04| 26.61|
          |Roll6Timesv2 |92.9| 26| 28| 45| 40.71| 42.27| 4.07| 29.63|
          |BringMyOwn_dice |92.1| 35| 38| 44| 40.32| 41.17| 4.09| 28.40|
          |LizduadacBot |92.0| 23| 25| 54| 47.32| 51.43| 5.70| 5.18|
          |FooBot |91.7| 22| 24| 44| 39.67| 41.45| 3.68| 51.80|
          |Alpha |91.7| 33| 36| 48| 38.89| 42.42| 2.16| 65.34|
          |QuotaBot |90.5| 19| 21| 53| 38.38| 42.42| 3.88| 24.65|
          |GoBigEarly |88.5| 23| 26| 47| 41.35| 42.87| 3.33| 46.38|
          |ExpectationsBot |88.0| 22| 25| 44| 39.08| 41.55| 3.57| 45.34|
          |LeadBy5Bot |87.5| 21| 24| 50| 37.46| 42.81| 2.20| 63.88|
          |GamblersFallacy |86.4| 19| 22| 44| 41.32| 41.58| 2.05| 63.11|
          |BePrepared |86.4| 19| 22| 59| 39.59| 44.79| 3.81| 35.96|
          |RollForLuckBot |85.7| 18| 21| 54| 41.95| 47.67| 4.68| 25.29|
          |OneStepAheadBot |84.6| 22| 26| 50| 41.35| 46.00| 3.34| 42.97|
          |FlipCoinRollDice |78.3| 18| 23| 51| 37.61| 44.72| 1.67| 75.42|
          |BlessRNG |77.8| 28| 36| 47| 40.69| 41.89| 1.43| 83.66|
          |FutureBot |77.4| 24| 31| 49| 40.16| 44.38| 2.41| 63.99|
          |SlowStart |68.4| 26| 38| 57| 38.53| 45.31| 1.99| 66.15|
          |NotTooFarBehindBot |66.7| 20| 30| 50| 37.27| 42.00| 1.29| 77.61|
          |ThrowThriceBot |63.0| 17| 27| 51| 39.63| 44.76| 2.50| 55.67|
          |OneInFiveBot |58.3| 14| 24| 54| 33.54| 44.86| 2.91| 50.19|
          |MatchLeaderBot |48.1| 13| 27| 49| 40.15| 44.15| 1.22| 82.26|
          |StopBot | 0.0| 0| 27| 43| 30.26| 0.00| 1.00| 82.77|
          +---------------------+----+--------+--------+------+------+-------+------+--------+


          Flaws



          There are a couple of drawbacks to this cooperative approach. First, when playing against non-cooperative bots cooperative bots never get the first-turn advantage because when they do play first, they don't yet know whether or not their opponents are willing to cooperate, and thus have no choice but to get a score of zero. Similarly, this cooperative strategy is extremely vulnerable to exploitation by malicious bots; for instance, during cooperative play the bot who plays last in the last round can choose to stop rolling immediately to make everybody else lose (assuming, of course, that their first roll wasn't a six).



          By cooperating, all bots can achieve the optimal solution of a 100% win rate. As such, if the win rate was the only thing that mattered then cooperation would be a stable equilibrium and there would be nothing to worry about. However, some bots might prioritize other goals, such as reaching the top of the leaderboard. This means that there is a risk that another bot might defect after your last turn, which creates an incentive for you to defect first. Because the setup of this competition doesn't allow us to see what our opponents did in their prior games, we can't penalize individuals that defected. Thus, cooperation is ultimately an unstable equilibrium doomed for failure.



          Footnotes



          [1]: The primary reasons why I don't want to submit thousands of bots instead of just two are that doing so would slow the simulation by a factor on the order of 1000 [2], and that doing so would significantly mess with win percentages as other bots would almost exclusively be playing against the swarm rather than each other. More important, however, is the fact that even if I wanted to I wouldn't be able to make that many bots in a reasonable time frame without breaking the spirit of the rule that "A bot must not implement the exact same strategy as an existing one, intentionally or accidentally".



          [2]: I think there are two main reasons that the simulation slows down when running a cooperative swarm. First, more bots means more games if you want each bot to play in the same number of games (in the case study, the number of games would differ by a factor of about 77). Second, cooperative games just take longer because they last for a full 200 rounds, and within a round players have to keep rolling indefinitely. For my setup, games took about 40 times longer to simulate: the case study took a little over three minutes to run 10000 games, but after removing the cooperative swarm it would finish 10000 games in just 4.5 seconds. Between these two reasons, I estimate it would take about 3100 times longer to accurately measure the performance of bots when there is a swarm competing compared to when there isn't.






          share|improve this answer










          New contributor




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









          Cooperative Swarm



          Strategy



          I don't think anyone else has yet noticed the significance of this rule:




          If the game goes to 200 rounds, the bot (or bots) with the highest score is the winner, even if they do not have 40 points or more.




          If every bot always rolled until they busted, then everyone would have a score of zero at the end of round 200 and everybody would win! Thus, the Cooperative Swarm's strategy is to cooperate as long as all players have a score of zero, but to play normally if anybody scores any points.



          In this post, I am submitting two bots: the first is CooperativeSwarmBot, and the second is CooperativeThrowTwice. CooperativeSwarmBot serves as a base class for all bots that are formally part of the cooperative swarm, and has placeholder behavior of simply accepting its first successful roll when cooperation fails. CooperativeSwarmBot has CooperativeSwarmBot as its parent and is identical to it in every way except that its non-cooperative behavior is to make two rolls instead of one. In the next few days I will be revising this post to add new bots that use much more intelligent behavior playing against non-cooperative bots.



          Code



          class CooperativeSwarmBot(Bot):
          def defection_strategy(self, scores, last_round):
          yield False

          def make_throw(self, scores, last_round):
          cooperate = max(scores) == 0
          if (cooperate):
          while True:
          yield True
          else:
          yield from self.defection_strategy(scores, last_round)

          class CooperativeThrowTwice(CooperativeSwarmBot):
          def defection_strategy(self, scores, last_round):
          yield True
          yield False


          Analysis



          Viability



          It is very hard to cooperate in this game because we need the support of all eight players for it to work. Since each bot class is limited to one instance per game, this is a hard goal to achieve. For example, the odds of choosing eight cooperative bots from a pool of 100 cooperative bots and 30 non-cooperative bots is:



          $$frac{100}{130} * frac{99}{129} * frac{98}{128} * frac{97}{127} * frac{96}{126} * frac{95}{125} * frac{94}{124} * frac{93}{123} approx 0.115$$



          More generally, the odds of choosing $i$ cooperative bots from a pool of $c$ cooperative bots and $n$ noncooperative bots is:



          $$frac{c! div (c - i)!}{(c+n)! div (c + n - i)!}$$



          From this equation we can easily show that we would need about 430 cooperative bots in order for 50% of games to end cooperatively, or about 2900 bots for 90% (using $i = 8$ as per the rules, and $n = 38$).



          Case Study



          For a number of reasons (see footnotes 1 and 2), a proper cooperative swarm will never compete in the official games. As such, I'll be summarizing the results of one of my own simulations in this section.



          This simulation ran 10000 games using the 38 other bots that had been posted here the last time I checked and 2900 bots that had CooperativeSwarmBot as their parent class. The controller reported that 9051 of the 10000 games (90.51%) ended at 200 rounds, which is quite close to the prediction that 90% of games would be cooperative. The implementation of these bots was trivial; other than CooperativeSwarmBot they all took this form:



          class CooperativeSwarm_1234(CooperativeSwarmBot):
          pass


          Less that 3% of the bots had a win percentage that was below 80%, and just over 11% of the bots won every single game they played. The median win percentage of the 2900 bots in the swarm is about 86%, which is outrageously good. For comparison, the top performers on the current official leaderboard win less than 22% of their games. I can't fit the full listing of the cooperative swarm within the maximum allowed length for an answer, so if you want to view that you'll have to go here instead: https://pastebin.com/3Zc8m1Ex



          Since each bot played in an average of about 27 games, luck plays a relatively large roll when you look at the results for individual bots. As I have not yet implemented an advanced strategy for non-cooperative games, most other bots benefited drastically from playing against the cooperative swarm, performing even the cooperative swarm's median win rate of 86%.



          The full results for bots that aren't in the swarm are listed below; there are two bots whose results I think deserve particular attention. First, StopBot failed to win any games at all. This is particularly tragic because the cooperative swarm was actually using the exact same strategy as StopBot was; you would have expected StopBot to win an eight of its games by chance, and a little bit more because the cooperative swarm is forced to give its opponents the first move. The second interesting result, however, is that PointsAreForNerdsBot's hard work finally paid off: it cooperated with the swarm and managed to win every single game it played!



          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |Bot |Win%| Wins| Played| Max| Avg|Avg win|Throws|Success%|
          +---------------------+----+--------+--------+------+------+-------+------+--------+
          |AggressiveStalker |100.0| 21| 21| 42| 40.71| 40.71| 3.48| 46.32|
          |PointsAreForNerdsBot |100.0| 31| 31| 0| 0.00| 0.00| 6.02| 0.00|
          |TakeFive |100.0| 18| 18| 44| 41.94| 41.94| 2.61| 50.93|
          |Hesitate |100.0| 26| 26| 44| 41.27| 41.27| 3.32| 41.89|
          |Crush |100.0| 34| 34| 44| 41.15| 41.15| 5.38| 6.73|
          |StepBot |97.0| 32| 33| 46| 41.15| 42.44| 4.51| 24.54|
          |LastRound |96.8| 30| 31| 44| 40.32| 41.17| 3.54| 45.05|
          |Chaser |96.8| 30| 31| 47| 42.90| 44.33| 3.04| 52.16|
          |GoHomeBot |96.8| 30| 31| 44| 40.32| 41.67| 5.60| 9.71|
          |Stalker |96.4| 27| 28| 44| 41.18| 41.44| 2.88| 57.53|
          |ClunkyChicken |96.2| 25| 26| 44| 40.96| 41.88| 2.32| 61.23|
          |AdaptiveRoller |96.0| 24| 25| 44| 39.32| 40.96| 4.49| 27.43|
          |GoTo20Bot |95.5| 21| 22| 44| 40.36| 41.33| 4.60| 30.50|
          |FortyTeen |95.0| 19| 20| 48| 44.15| 45.68| 3.71| 43.97|
          |BinaryBot |94.3| 33| 35| 44| 41.29| 41.42| 2.87| 53.07|
          |EnsureLead |93.8| 15| 16| 55| 42.56| 42.60| 4.04| 26.61|
          |Roll6Timesv2 |92.9| 26| 28| 45| 40.71| 42.27| 4.07| 29.63|
          |BringMyOwn_dice |92.1| 35| 38| 44| 40.32| 41.17| 4.09| 28.40|
          |LizduadacBot |92.0| 23| 25| 54| 47.32| 51.43| 5.70| 5.18|
          |FooBot |91.7| 22| 24| 44| 39.67| 41.45| 3.68| 51.80|
          |Alpha |91.7| 33| 36| 48| 38.89| 42.42| 2.16| 65.34|
          |QuotaBot |90.5| 19| 21| 53| 38.38| 42.42| 3.88| 24.65|
          |GoBigEarly |88.5| 23| 26| 47| 41.35| 42.87| 3.33| 46.38|
          |ExpectationsBot |88.0| 22| 25| 44| 39.08| 41.55| 3.57| 45.34|
          |LeadBy5Bot |87.5| 21| 24| 50| 37.46| 42.81| 2.20| 63.88|
          |GamblersFallacy |86.4| 19| 22| 44| 41.32| 41.58| 2.05| 63.11|
          |BePrepared |86.4| 19| 22| 59| 39.59| 44.79| 3.81| 35.96|
          |RollForLuckBot |85.7| 18| 21| 54| 41.95| 47.67| 4.68| 25.29|
          |OneStepAheadBot |84.6| 22| 26| 50| 41.35| 46.00| 3.34| 42.97|
          |FlipCoinRollDice |78.3| 18| 23| 51| 37.61| 44.72| 1.67| 75.42|
          |BlessRNG |77.8| 28| 36| 47| 40.69| 41.89| 1.43| 83.66|
          |FutureBot |77.4| 24| 31| 49| 40.16| 44.38| 2.41| 63.99|
          |SlowStart |68.4| 26| 38| 57| 38.53| 45.31| 1.99| 66.15|
          |NotTooFarBehindBot |66.7| 20| 30| 50| 37.27| 42.00| 1.29| 77.61|
          |ThrowThriceBot |63.0| 17| 27| 51| 39.63| 44.76| 2.50| 55.67|
          |OneInFiveBot |58.3| 14| 24| 54| 33.54| 44.86| 2.91| 50.19|
          |MatchLeaderBot |48.1| 13| 27| 49| 40.15| 44.15| 1.22| 82.26|
          |StopBot | 0.0| 0| 27| 43| 30.26| 0.00| 1.00| 82.77|
          +---------------------+----+--------+--------+------+------+-------+------+--------+


          Flaws



          There are a couple of drawbacks to this cooperative approach. First, when playing against non-cooperative bots cooperative bots never get the first-turn advantage because when they do play first, they don't yet know whether or not their opponents are willing to cooperate, and thus have no choice but to get a score of zero. Similarly, this cooperative strategy is extremely vulnerable to exploitation by malicious bots; for instance, during cooperative play the bot who plays last in the last round can choose to stop rolling immediately to make everybody else lose (assuming, of course, that their first roll wasn't a six).



          By cooperating, all bots can achieve the optimal solution of a 100% win rate. As such, if the win rate was the only thing that mattered then cooperation would be a stable equilibrium and there would be nothing to worry about. However, some bots might prioritize other goals, such as reaching the top of the leaderboard. This means that there is a risk that another bot might defect after your last turn, which creates an incentive for you to defect first. Because the setup of this competition doesn't allow us to see what our opponents did in their prior games, we can't penalize individuals that defected. Thus, cooperation is ultimately an unstable equilibrium doomed for failure.



          Footnotes



          [1]: The primary reasons why I don't want to submit thousands of bots instead of just two are that doing so would slow the simulation by a factor on the order of 1000 [2], and that doing so would significantly mess with win percentages as other bots would almost exclusively be playing against the swarm rather than each other. More important, however, is the fact that even if I wanted to I wouldn't be able to make that many bots in a reasonable time frame without breaking the spirit of the rule that "A bot must not implement the exact same strategy as an existing one, intentionally or accidentally".



          [2]: I think there are two main reasons that the simulation slows down when running a cooperative swarm. First, more bots means more games if you want each bot to play in the same number of games (in the case study, the number of games would differ by a factor of about 77). Second, cooperative games just take longer because they last for a full 200 rounds, and within a round players have to keep rolling indefinitely. For my setup, games took about 40 times longer to simulate: the case study took a little over three minutes to run 10000 games, but after removing the cooperative swarm it would finish 10000 games in just 4.5 seconds. Between these two reasons, I estimate it would take about 3100 times longer to accurately measure the performance of bots when there is a swarm competing compared to when there isn't.







          share|improve this answer










          New contributor




          Einhaender 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 Dec 22 at 17:00





















          New contributor




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









          answered Dec 22 at 15:52









          Einhaender

          913




          913




          New contributor




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





          New contributor





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






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








          • 3




            Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
            – maxb
            Dec 22 at 16:37






          • 2




            I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
            – Einhaender
            Dec 22 at 17:09










          • Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
            – maxb
            Dec 22 at 17:10






          • 1




            I think your post is clear after reading it more thoroughly.
            – maxb
            Dec 22 at 17:11














          • 3




            Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
            – maxb
            Dec 22 at 16:37






          • 2




            I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
            – Einhaender
            Dec 22 at 17:09










          • Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
            – maxb
            Dec 22 at 17:10






          • 1




            I think your post is clear after reading it more thoroughly.
            – maxb
            Dec 22 at 17:11








          3




          3




          Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
          – maxb
          Dec 22 at 16:37




          Wow. And welcome to PPCG. This is quite the first answer. I wasn't really planning on a situation like this. You certainly found a loophole in the rules. I'm not really sure how I should score this, since your answer is a collection of bots rather than a single bot. However, the only thing I'll say right now is that it feels unfair that one participant would control 98.7% of all bots.
          – maxb
          Dec 22 at 16:37




          2




          2




          I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
          – Einhaender
          Dec 22 at 17:09




          I actually don't want duplicate bots to be in the official competition; that's why I ran the simulation myself instead of submitting thousands of very nearly identical bots. I'll revise my submission to make that more clear.
          – Einhaender
          Dec 22 at 17:09












          Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
          – maxb
          Dec 22 at 17:10




          Had I anticipated an answer like this, I would have changed the games that go to 200 rounds so that they don't give scores to players. However, as you note, there is a rule about creating identical bots which would make this strategy be against the rules. I'm not going to change the rules, as it would be unfair to everyone who has made a bot. However, the concept of cooperation is very interesting, And I hope that there are other bots submitted which implement the cooperation strategy in combination with its own unique strategy.
          – maxb
          Dec 22 at 17:10




          1




          1




          I think your post is clear after reading it more thoroughly.
          – maxb
          Dec 22 at 17:11




          I think your post is clear after reading it more thoroughly.
          – maxb
          Dec 22 at 17:11











          5














          NotTooFarBehindBot



          class NotTooFarBehindBot(Bot):
          def make_throw(self, scores, last_round):
          while True:
          current_score = scores[self.index] + sum(self.current_throws)
          number_of_bots_ahead = sum(1 for x in scores if x > current_score)
          if number_of_bots_ahead > 1:
          yield True
          continue
          if number_of_bots_ahead != 0 and last_round:
          yield True
          continue
          break
          yield False


          The idea is that other bots may lose points, so being 2nd isn't bad - but if you're very behind, you might as well go for broke.






          share|improve this answer










          New contributor




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














          • 1




            Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
            – maxb
            Dec 19 at 13:31






          • 6




            I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
            – maxb
            Dec 19 at 13:49










          • Thanks - will make that change!
            – Stuart Moore
            Dec 19 at 13:52
















          5














          NotTooFarBehindBot



          class NotTooFarBehindBot(Bot):
          def make_throw(self, scores, last_round):
          while True:
          current_score = scores[self.index] + sum(self.current_throws)
          number_of_bots_ahead = sum(1 for x in scores if x > current_score)
          if number_of_bots_ahead > 1:
          yield True
          continue
          if number_of_bots_ahead != 0 and last_round:
          yield True
          continue
          break
          yield False


          The idea is that other bots may lose points, so being 2nd isn't bad - but if you're very behind, you might as well go for broke.






          share|improve this answer










          New contributor




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














          • 1




            Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
            – maxb
            Dec 19 at 13:31






          • 6




            I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
            – maxb
            Dec 19 at 13:49










          • Thanks - will make that change!
            – Stuart Moore
            Dec 19 at 13:52














          5












          5








          5






          NotTooFarBehindBot



          class NotTooFarBehindBot(Bot):
          def make_throw(self, scores, last_round):
          while True:
          current_score = scores[self.index] + sum(self.current_throws)
          number_of_bots_ahead = sum(1 for x in scores if x > current_score)
          if number_of_bots_ahead > 1:
          yield True
          continue
          if number_of_bots_ahead != 0 and last_round:
          yield True
          continue
          break
          yield False


          The idea is that other bots may lose points, so being 2nd isn't bad - but if you're very behind, you might as well go for broke.






          share|improve this answer










          New contributor




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









          NotTooFarBehindBot



          class NotTooFarBehindBot(Bot):
          def make_throw(self, scores, last_round):
          while True:
          current_score = scores[self.index] + sum(self.current_throws)
          number_of_bots_ahead = sum(1 for x in scores if x > current_score)
          if number_of_bots_ahead > 1:
          yield True
          continue
          if number_of_bots_ahead != 0 and last_round:
          yield True
          continue
          break
          yield False


          The idea is that other bots may lose points, so being 2nd isn't bad - but if you're very behind, you might as well go for broke.







          share|improve this answer










          New contributor




          Stuart Moore 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 Dec 19 at 17:25





















          New contributor




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









          answered Dec 19 at 13:17









          Stuart Moore

          1814




          1814




          New contributor




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





          New contributor





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






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








          • 1




            Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
            – maxb
            Dec 19 at 13:31






          • 6




            I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
            – maxb
            Dec 19 at 13:49










          • Thanks - will make that change!
            – Stuart Moore
            Dec 19 at 13:52














          • 1




            Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
            – maxb
            Dec 19 at 13:31






          • 6




            I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
            – maxb
            Dec 19 at 13:49










          • Thanks - will make that change!
            – Stuart Moore
            Dec 19 at 13:52








          1




          1




          Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
          – maxb
          Dec 19 at 13:31




          Welcome to PPCG! I'm looking through your submission, and it seems that the more players are in the game, the lower the win percentage is for your bot. I can't tell why straight away. With bots being matched 1vs1 you get a 10% winrate. The idea sounds promising, and the code looks correct, so I can't really tell why your winrate isn't higher.
          – maxb
          Dec 19 at 13:31




          6




          6




          I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
          – maxb
          Dec 19 at 13:49




          I have looked into the behavior, and this line had me confused: 6: Bot NotTooFarBehindBot plays [4, 2, 4, 2, 3, 3, 5, 5, 1, 4, 1, 4, 2, 4, 3, 6] with scores [0, 9, 0, 20, 0, 0, 0] and last round == False. Even though your bot is in the lead after 7 throws, it continues until it hits a 6. As I'm typing this I figured out the issue! The scores only contain the total scores, not the die cases for the current round. You should modify it to be current_score = scores[self.index] + sum(self.current_throws).
          – maxb
          Dec 19 at 13:49












          Thanks - will make that change!
          – Stuart Moore
          Dec 19 at 13:52




          Thanks - will make that change!
          – Stuart Moore
          Dec 19 at 13:52











          5














          EnsureLead



          class EnsureLead(Bot):

          def make_throw(self, scores, last_round):
          otherScores = scores[self.index+1:] + scores[:self.index]
          maxOtherScore = max(otherScores)
          maxOthersToCome = 0
          for i in otherScores:
          if (i >= 40): break
          else: maxOthersToCome = max(maxOthersToCome, i)
          while True:
          currentScore = sum(self.current_throws)
          totalScore = scores[self.index] + currentScore
          if not last_round:
          if totalScore >= 40:
          if totalScore < maxOtherScore + 10:
          yield True
          else:
          yield False
          elif currentScore < 20:
          yield True
          else:
          yield False
          else:
          if totalScore < maxOtherScore + 1:
          yield True
          elif totalScore < maxOthersToCome + 10:
          yield True
          else:
          yield False


          EnsureLead borrows ideas from GoTo20Bot. It adds the concept that it always considers (when in last_round or reaching 40) that there are others which will have at least one more roll. Thus, the bot tries to get a bit ahead of them, such that they have to catch up.






          share|improve this answer










          New contributor




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























            5














            EnsureLead



            class EnsureLead(Bot):

            def make_throw(self, scores, last_round):
            otherScores = scores[self.index+1:] + scores[:self.index]
            maxOtherScore = max(otherScores)
            maxOthersToCome = 0
            for i in otherScores:
            if (i >= 40): break
            else: maxOthersToCome = max(maxOthersToCome, i)
            while True:
            currentScore = sum(self.current_throws)
            totalScore = scores[self.index] + currentScore
            if not last_round:
            if totalScore >= 40:
            if totalScore < maxOtherScore + 10:
            yield True
            else:
            yield False
            elif currentScore < 20:
            yield True
            else:
            yield False
            else:
            if totalScore < maxOtherScore + 1:
            yield True
            elif totalScore < maxOthersToCome + 10:
            yield True
            else:
            yield False


            EnsureLead borrows ideas from GoTo20Bot. It adds the concept that it always considers (when in last_round or reaching 40) that there are others which will have at least one more roll. Thus, the bot tries to get a bit ahead of them, such that they have to catch up.






            share|improve this answer










            New contributor




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





















              5












              5








              5






              EnsureLead



              class EnsureLead(Bot):

              def make_throw(self, scores, last_round):
              otherScores = scores[self.index+1:] + scores[:self.index]
              maxOtherScore = max(otherScores)
              maxOthersToCome = 0
              for i in otherScores:
              if (i >= 40): break
              else: maxOthersToCome = max(maxOthersToCome, i)
              while True:
              currentScore = sum(self.current_throws)
              totalScore = scores[self.index] + currentScore
              if not last_round:
              if totalScore >= 40:
              if totalScore < maxOtherScore + 10:
              yield True
              else:
              yield False
              elif currentScore < 20:
              yield True
              else:
              yield False
              else:
              if totalScore < maxOtherScore + 1:
              yield True
              elif totalScore < maxOthersToCome + 10:
              yield True
              else:
              yield False


              EnsureLead borrows ideas from GoTo20Bot. It adds the concept that it always considers (when in last_round or reaching 40) that there are others which will have at least one more roll. Thus, the bot tries to get a bit ahead of them, such that they have to catch up.






              share|improve this answer










              New contributor




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









              EnsureLead



              class EnsureLead(Bot):

              def make_throw(self, scores, last_round):
              otherScores = scores[self.index+1:] + scores[:self.index]
              maxOtherScore = max(otherScores)
              maxOthersToCome = 0
              for i in otherScores:
              if (i >= 40): break
              else: maxOthersToCome = max(maxOthersToCome, i)
              while True:
              currentScore = sum(self.current_throws)
              totalScore = scores[self.index] + currentScore
              if not last_round:
              if totalScore >= 40:
              if totalScore < maxOtherScore + 10:
              yield True
              else:
              yield False
              elif currentScore < 20:
              yield True
              else:
              yield False
              else:
              if totalScore < maxOtherScore + 1:
              yield True
              elif totalScore < maxOthersToCome + 10:
              yield True
              else:
              yield False


              EnsureLead borrows ideas from GoTo20Bot. It adds the concept that it always considers (when in last_round or reaching 40) that there are others which will have at least one more roll. Thus, the bot tries to get a bit ahead of them, such that they have to catch up.







              share|improve this answer










              New contributor




              Dirk Herrmann 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 Dec 19 at 23:24





















              New contributor




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









              answered Dec 19 at 23:16









              Dirk Herrmann

              1515




              1515




              New contributor




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





              New contributor





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






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























                  4














                  Alpha



                  class Alpha(Bot):
                  def make_throw(self, scores, last_round):
                  # Throw until we're the best.
                  while scores[self.index] + sum(self.current_throws) <= max(scores):
                  yield True

                  # Throw once more to assert dominance.
                  yield True
                  yield False


                  Alpha refuses ever to be second to anyone. So long as there is a bot with a higher score, it will keep rolling.






                  share|improve this answer























                  • Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                    – Spitemaster
                    Dec 19 at 17:14










                  • @Spitemaster Fixed, thanks.
                    – Mnemonic
                    Dec 19 at 17:24
















                  4














                  Alpha



                  class Alpha(Bot):
                  def make_throw(self, scores, last_round):
                  # Throw until we're the best.
                  while scores[self.index] + sum(self.current_throws) <= max(scores):
                  yield True

                  # Throw once more to assert dominance.
                  yield True
                  yield False


                  Alpha refuses ever to be second to anyone. So long as there is a bot with a higher score, it will keep rolling.






                  share|improve this answer























                  • Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                    – Spitemaster
                    Dec 19 at 17:14










                  • @Spitemaster Fixed, thanks.
                    – Mnemonic
                    Dec 19 at 17:24














                  4












                  4








                  4






                  Alpha



                  class Alpha(Bot):
                  def make_throw(self, scores, last_round):
                  # Throw until we're the best.
                  while scores[self.index] + sum(self.current_throws) <= max(scores):
                  yield True

                  # Throw once more to assert dominance.
                  yield True
                  yield False


                  Alpha refuses ever to be second to anyone. So long as there is a bot with a higher score, it will keep rolling.






                  share|improve this answer














                  Alpha



                  class Alpha(Bot):
                  def make_throw(self, scores, last_round):
                  # Throw until we're the best.
                  while scores[self.index] + sum(self.current_throws) <= max(scores):
                  yield True

                  # Throw once more to assert dominance.
                  yield True
                  yield False


                  Alpha refuses ever to be second to anyone. So long as there is a bot with a higher score, it will keep rolling.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 19 at 17:23

























                  answered Dec 19 at 17:13









                  Mnemonic

                  4,6951630




                  4,6951630












                  • Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                    – Spitemaster
                    Dec 19 at 17:14










                  • @Spitemaster Fixed, thanks.
                    – Mnemonic
                    Dec 19 at 17:24


















                  • Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                    – Spitemaster
                    Dec 19 at 17:14










                  • @Spitemaster Fixed, thanks.
                    – Mnemonic
                    Dec 19 at 17:24
















                  Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                  – Spitemaster
                  Dec 19 at 17:14




                  Because of how yield works, if it starts rolling it will never stop. You'll want to update my_score in the loop.
                  – Spitemaster
                  Dec 19 at 17:14












                  @Spitemaster Fixed, thanks.
                  – Mnemonic
                  Dec 19 at 17:24




                  @Spitemaster Fixed, thanks.
                  – Mnemonic
                  Dec 19 at 17:24











                  3














                  FooBot



                  class FooBot(Bot):
                  def make_throw(self, scores, last_round):
                  max_score = max(scores)

                  while True:
                  round_score = sum(self.current_throws)
                  my_score = scores[self.index] + round_score

                  if last_round:
                  if my_score >= max_score:
                  break
                  else:
                  if my_score >= self.end_score or round_score >= 16:
                  break

                  yield True

                  yield False





                  share|improve this answer























                  • # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                    – Spitemaster
                    Dec 19 at 15:50










                  • Thanks. I was misled by the name of the method.
                    – Peter Taylor
                    Dec 19 at 16:00










                  • @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                    – maxb
                    Dec 20 at 9:02
















                  3














                  FooBot



                  class FooBot(Bot):
                  def make_throw(self, scores, last_round):
                  max_score = max(scores)

                  while True:
                  round_score = sum(self.current_throws)
                  my_score = scores[self.index] + round_score

                  if last_round:
                  if my_score >= max_score:
                  break
                  else:
                  if my_score >= self.end_score or round_score >= 16:
                  break

                  yield True

                  yield False





                  share|improve this answer























                  • # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                    – Spitemaster
                    Dec 19 at 15:50










                  • Thanks. I was misled by the name of the method.
                    – Peter Taylor
                    Dec 19 at 16:00










                  • @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                    – maxb
                    Dec 20 at 9:02














                  3












                  3








                  3






                  FooBot



                  class FooBot(Bot):
                  def make_throw(self, scores, last_round):
                  max_score = max(scores)

                  while True:
                  round_score = sum(self.current_throws)
                  my_score = scores[self.index] + round_score

                  if last_round:
                  if my_score >= max_score:
                  break
                  else:
                  if my_score >= self.end_score or round_score >= 16:
                  break

                  yield True

                  yield False





                  share|improve this answer














                  FooBot



                  class FooBot(Bot):
                  def make_throw(self, scores, last_round):
                  max_score = max(scores)

                  while True:
                  round_score = sum(self.current_throws)
                  my_score = scores[self.index] + round_score

                  if last_round:
                  if my_score >= max_score:
                  break
                  else:
                  if my_score >= self.end_score or round_score >= 16:
                  break

                  yield True

                  yield False






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 19 at 16:00

























                  answered Dec 19 at 15:09









                  Peter Taylor

                  39k453142




                  39k453142












                  • # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                    – Spitemaster
                    Dec 19 at 15:50










                  • Thanks. I was misled by the name of the method.
                    – Peter Taylor
                    Dec 19 at 16:00










                  • @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                    – maxb
                    Dec 20 at 9:02


















                  • # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                    – Spitemaster
                    Dec 19 at 15:50










                  • Thanks. I was misled by the name of the method.
                    – Peter Taylor
                    Dec 19 at 16:00










                  • @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                    – maxb
                    Dec 20 at 9:02
















                  # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                  – Spitemaster
                  Dec 19 at 15:50




                  # Must throw at least once is unneeded - it throws once before calling your bot. Your bot will always throw a minimum of twice.
                  – Spitemaster
                  Dec 19 at 15:50












                  Thanks. I was misled by the name of the method.
                  – Peter Taylor
                  Dec 19 at 16:00




                  Thanks. I was misled by the name of the method.
                  – Peter Taylor
                  Dec 19 at 16:00












                  @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                  – maxb
                  Dec 20 at 9:02




                  @PeterTaylor Thanks for your submission! I named the make_throw method early on, when I wanted players to be able to skip their turn. I guess a more appropriate name would be keep_throwing. Thanks for the feedback in the sandbox, it really helped make this a proper challenge!
                  – maxb
                  Dec 20 at 9:02











                  3














                  Go Big Early



                  class GoBigEarly(Bot):
                  def make_throw(self, scores, last_round):
                  yield True # always do a 2nd roll
                  while scores[self.index] + sum(self.current_throws) < 25:
                  yield True
                  yield False


                  Concept: Try to win big on an early roll (getting to 25) then creep up from there 2 rolls at a time.






                  share|improve this answer








                  New contributor




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























                    3














                    Go Big Early



                    class GoBigEarly(Bot):
                    def make_throw(self, scores, last_round):
                    yield True # always do a 2nd roll
                    while scores[self.index] + sum(self.current_throws) < 25:
                    yield True
                    yield False


                    Concept: Try to win big on an early roll (getting to 25) then creep up from there 2 rolls at a time.






                    share|improve this answer








                    New contributor




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





















                      3












                      3








                      3






                      Go Big Early



                      class GoBigEarly(Bot):
                      def make_throw(self, scores, last_round):
                      yield True # always do a 2nd roll
                      while scores[self.index] + sum(self.current_throws) < 25:
                      yield True
                      yield False


                      Concept: Try to win big on an early roll (getting to 25) then creep up from there 2 rolls at a time.






                      share|improve this answer








                      New contributor




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









                      Go Big Early



                      class GoBigEarly(Bot):
                      def make_throw(self, scores, last_round):
                      yield True # always do a 2nd roll
                      while scores[self.index] + sum(self.current_throws) < 25:
                      yield True
                      yield False


                      Concept: Try to win big on an early roll (getting to 25) then creep up from there 2 rolls at a time.







                      share|improve this answer








                      New contributor




                      Stuart Moore 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




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









                      answered Dec 19 at 17:24









                      Stuart Moore

                      1814




                      1814




                      New contributor




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





                      New contributor





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






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























                          3














                          Roll6TimesV2



                          Doesn't beat the current best, but I think it will fair better with more bots in play.



                          class Roll6Timesv2(Bot):
                          def make_throw(self, scores, last_round):

                          if not last_round:
                          i = 0
                          maximum=6
                          while ((i<maximum) and sum(self.current_throws)+scores[self.index]<=40 ):
                          yield True
                          i=i+1

                          if last_round:
                          while scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False


                          Really awesome game by the way.






                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                            – maxb
                            Dec 19 at 20:05
















                          3














                          Roll6TimesV2



                          Doesn't beat the current best, but I think it will fair better with more bots in play.



                          class Roll6Timesv2(Bot):
                          def make_throw(self, scores, last_round):

                          if not last_round:
                          i = 0
                          maximum=6
                          while ((i<maximum) and sum(self.current_throws)+scores[self.index]<=40 ):
                          yield True
                          i=i+1

                          if last_round:
                          while scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False


                          Really awesome game by the way.






                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                            – maxb
                            Dec 19 at 20:05














                          3












                          3








                          3






                          Roll6TimesV2



                          Doesn't beat the current best, but I think it will fair better with more bots in play.



                          class Roll6Timesv2(Bot):
                          def make_throw(self, scores, last_round):

                          if not last_round:
                          i = 0
                          maximum=6
                          while ((i<maximum) and sum(self.current_throws)+scores[self.index]<=40 ):
                          yield True
                          i=i+1

                          if last_round:
                          while scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False


                          Really awesome game by the way.






                          share|improve this answer










                          New contributor




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









                          Roll6TimesV2



                          Doesn't beat the current best, but I think it will fair better with more bots in play.



                          class Roll6Timesv2(Bot):
                          def make_throw(self, scores, last_round):

                          if not last_round:
                          i = 0
                          maximum=6
                          while ((i<maximum) and sum(self.current_throws)+scores[self.index]<=40 ):
                          yield True
                          i=i+1

                          if last_round:
                          while scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False


                          Really awesome game by the way.







                          share|improve this answer










                          New contributor




                          itsmephil12345 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 Dec 19 at 19:44









                          maxb

                          2,90611131




                          2,90611131






                          New contributor




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









                          answered Dec 19 at 15:09









                          itsmephil12345

                          313




                          313




                          New contributor




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





                          New contributor





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






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












                          • Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                            – maxb
                            Dec 19 at 20:05


















                          • Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                            – maxb
                            Dec 19 at 20:05
















                          Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                          – maxb
                          Dec 19 at 20:05




                          Welcome to PPCG! Very impressive for not only your first KotH challenge, but your first answer. Glad that you liked the game! I have had lots of discussion about the best tactic for the game after the evening when I played it, so it seemed perfect for a challenge. You're currently in third place out of 18.
                          – maxb
                          Dec 19 at 20:05











                          3














                          GoHomeBot



                          class GoHomeBot(Bot):
                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 40:
                          yield True
                          yield False


                          We want to go big or go home, right? GoHomeBot mostly just goes home. (But does surprisingly well!)






                          share|improve this answer





















                          • Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                            – maxb
                            Dec 20 at 5:57










                          • It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                            – Belhenix
                            Dec 20 at 19:48
















                          3














                          GoHomeBot



                          class GoHomeBot(Bot):
                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 40:
                          yield True
                          yield False


                          We want to go big or go home, right? GoHomeBot mostly just goes home. (But does surprisingly well!)






                          share|improve this answer





















                          • Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                            – maxb
                            Dec 20 at 5:57










                          • It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                            – Belhenix
                            Dec 20 at 19:48














                          3












                          3








                          3






                          GoHomeBot



                          class GoHomeBot(Bot):
                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 40:
                          yield True
                          yield False


                          We want to go big or go home, right? GoHomeBot mostly just goes home. (But does surprisingly well!)






                          share|improve this answer












                          GoHomeBot



                          class GoHomeBot(Bot):
                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 40:
                          yield True
                          yield False


                          We want to go big or go home, right? GoHomeBot mostly just goes home. (But does surprisingly well!)







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 19 at 21:17









                          Spitemaster

                          3736




                          3736












                          • Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                            – maxb
                            Dec 20 at 5:57










                          • It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                            – Belhenix
                            Dec 20 at 19:48


















                          • Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                            – maxb
                            Dec 20 at 5:57










                          • It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                            – Belhenix
                            Dec 20 at 19:48
















                          Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                          – maxb
                          Dec 20 at 5:57




                          Since this bot always goes for 40 points, it will never have any points in the scores list. There was a bot like this before (the GoToEnd bot), but david deleted their answer. I'll replace that bot by yours.
                          – maxb
                          Dec 20 at 5:57












                          It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                          – Belhenix
                          Dec 20 at 19:48




                          It's quite funny, seeing this bots' expaned stats: Except for pointsAreForNerds and StopBot, this bot has the lowest average points, and yet it has a nice win ratio
                          – Belhenix
                          Dec 20 at 19:48











                          3














                          PointsAreForNerdsBot



                          class PointsAreForNerdsBot(Bot):
                          def make_throw(self, scores, last_round):
                          while True:
                          yield True


                          This one needs no explanation.



                          OneInFiveBot



                          class OneInFiveBot(Bot):
                          def make_throw(self, scores, last_round):
                          while random.randint(1,5) < 5:
                          yield True
                          yield False


                          Keeps rolling until it rolls a five on it's own 5-sided die. Five is less than six, so it HAS TO WIN!






                          share|improve this answer








                          New contributor




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














                          • 1




                            Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                            – maxb
                            Dec 20 at 8:34






                          • 2




                            the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                            – AKroell
                            Dec 20 at 14:37










                          • Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                            – Zacharý
                            Dec 20 at 21:25












                          • @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                            – The_Bob
                            Dec 21 at 5:55






                          • 2




                            I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                            – Peter Taylor
                            Dec 21 at 21:54
















                          3














                          PointsAreForNerdsBot



                          class PointsAreForNerdsBot(Bot):
                          def make_throw(self, scores, last_round):
                          while True:
                          yield True


                          This one needs no explanation.



                          OneInFiveBot



                          class OneInFiveBot(Bot):
                          def make_throw(self, scores, last_round):
                          while random.randint(1,5) < 5:
                          yield True
                          yield False


                          Keeps rolling until it rolls a five on it's own 5-sided die. Five is less than six, so it HAS TO WIN!






                          share|improve this answer








                          New contributor




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














                          • 1




                            Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                            – maxb
                            Dec 20 at 8:34






                          • 2




                            the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                            – AKroell
                            Dec 20 at 14:37










                          • Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                            – Zacharý
                            Dec 20 at 21:25












                          • @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                            – The_Bob
                            Dec 21 at 5:55






                          • 2




                            I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                            – Peter Taylor
                            Dec 21 at 21:54














                          3












                          3








                          3






                          PointsAreForNerdsBot



                          class PointsAreForNerdsBot(Bot):
                          def make_throw(self, scores, last_round):
                          while True:
                          yield True


                          This one needs no explanation.



                          OneInFiveBot



                          class OneInFiveBot(Bot):
                          def make_throw(self, scores, last_round):
                          while random.randint(1,5) < 5:
                          yield True
                          yield False


                          Keeps rolling until it rolls a five on it's own 5-sided die. Five is less than six, so it HAS TO WIN!






                          share|improve this answer








                          New contributor




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









                          PointsAreForNerdsBot



                          class PointsAreForNerdsBot(Bot):
                          def make_throw(self, scores, last_round):
                          while True:
                          yield True


                          This one needs no explanation.



                          OneInFiveBot



                          class OneInFiveBot(Bot):
                          def make_throw(self, scores, last_round):
                          while random.randint(1,5) < 5:
                          yield True
                          yield False


                          Keeps rolling until it rolls a five on it's own 5-sided die. Five is less than six, so it HAS TO WIN!







                          share|improve this answer








                          New contributor




                          The_Bob 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




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









                          answered Dec 20 at 0:28









                          The_Bob

                          391




                          391




                          New contributor




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





                          New contributor





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






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








                          • 1




                            Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                            – maxb
                            Dec 20 at 8:34






                          • 2




                            the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                            – AKroell
                            Dec 20 at 14:37










                          • Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                            – Zacharý
                            Dec 20 at 21:25












                          • @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                            – The_Bob
                            Dec 21 at 5:55






                          • 2




                            I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                            – Peter Taylor
                            Dec 21 at 21:54














                          • 1




                            Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                            – maxb
                            Dec 20 at 8:34






                          • 2




                            the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                            – AKroell
                            Dec 20 at 14:37










                          • Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                            – Zacharý
                            Dec 20 at 21:25












                          • @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                            – The_Bob
                            Dec 21 at 5:55






                          • 2




                            I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                            – Peter Taylor
                            Dec 21 at 21:54








                          1




                          1




                          Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                          – maxb
                          Dec 20 at 8:34




                          Welcome to PPCG! I'm sure you're aware, but your first bot is literally the worst bot in this competition! The OneInFiveBot is a neat idea, but I think it suffers in the end game compared to some of the more advanced bots. Still a great submission!
                          – maxb
                          Dec 20 at 8:34




                          2




                          2




                          the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                          – AKroell
                          Dec 20 at 14:37




                          the OneInFiveBot is quite interesting in the way that he consistently has the highest overall score reached.
                          – AKroell
                          Dec 20 at 14:37












                          Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                          – Zacharý
                          Dec 20 at 21:25






                          Thanks for giving StopBot a punching bag :P. The OneInFiveBot actually is pretty neat, nice job!
                          – Zacharý
                          Dec 20 at 21:25














                          @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                          – The_Bob
                          Dec 21 at 5:55




                          @maxb Yep, that's where I got the name. I honestly didn't test OneInFiveBot and it's doing much better than I expected
                          – The_Bob
                          Dec 21 at 5:55




                          2




                          2




                          I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                          – Peter Taylor
                          Dec 21 at 21:54




                          I'm afraid that to stick to community norms, PointsAreForNerdsBots should be deleted.
                          – Peter Taylor
                          Dec 21 at 21:54











                          3














                          StopBot



                          class StopBot(Bot):
                          def make_throw(self, scores, last_round):
                          yield False


                          Literally only one throw.



                          This is equivalent to the base Bot class.






                          share|improve this answer























                          • Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                            – maxb
                            Dec 19 at 19:42










                          • I know, somebody had to post that bot though. Degenerate bots for the loss.
                            – Zacharý
                            Dec 19 at 21:04






                          • 5




                            I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                            – maxb
                            Dec 20 at 8:28






                          • 1




                            IT WON A GAME?! That is surprising.
                            – Zacharý
                            Dec 20 at 21:17
















                          3














                          StopBot



                          class StopBot(Bot):
                          def make_throw(self, scores, last_round):
                          yield False


                          Literally only one throw.



                          This is equivalent to the base Bot class.






                          share|improve this answer























                          • Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                            – maxb
                            Dec 19 at 19:42










                          • I know, somebody had to post that bot though. Degenerate bots for the loss.
                            – Zacharý
                            Dec 19 at 21:04






                          • 5




                            I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                            – maxb
                            Dec 20 at 8:28






                          • 1




                            IT WON A GAME?! That is surprising.
                            – Zacharý
                            Dec 20 at 21:17














                          3












                          3








                          3






                          StopBot



                          class StopBot(Bot):
                          def make_throw(self, scores, last_round):
                          yield False


                          Literally only one throw.



                          This is equivalent to the base Bot class.






                          share|improve this answer














                          StopBot



                          class StopBot(Bot):
                          def make_throw(self, scores, last_round):
                          yield False


                          Literally only one throw.



                          This is equivalent to the base Bot class.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 21 at 2:20

























                          answered Dec 19 at 17:46









                          Zacharý

                          5,19511035




                          5,19511035












                          • Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                            – maxb
                            Dec 19 at 19:42










                          • I know, somebody had to post that bot though. Degenerate bots for the loss.
                            – Zacharý
                            Dec 19 at 21:04






                          • 5




                            I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                            – maxb
                            Dec 20 at 8:28






                          • 1




                            IT WON A GAME?! That is surprising.
                            – Zacharý
                            Dec 20 at 21:17


















                          • Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                            – maxb
                            Dec 19 at 19:42










                          • I know, somebody had to post that bot though. Degenerate bots for the loss.
                            – Zacharý
                            Dec 19 at 21:04






                          • 5




                            I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                            – maxb
                            Dec 20 at 8:28






                          • 1




                            IT WON A GAME?! That is surprising.
                            – Zacharý
                            Dec 20 at 21:17
















                          Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                          – maxb
                          Dec 19 at 19:42




                          Don't be sorry! You're following all the rules, though I'm afraid that your bot is not terribly effective with an average of 2.5 points per round.
                          – maxb
                          Dec 19 at 19:42












                          I know, somebody had to post that bot though. Degenerate bots for the loss.
                          – Zacharý
                          Dec 19 at 21:04




                          I know, somebody had to post that bot though. Degenerate bots for the loss.
                          – Zacharý
                          Dec 19 at 21:04




                          5




                          5




                          I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                          – maxb
                          Dec 20 at 8:28




                          I'd say that I'm impressed by your bot securing exactly one win in the last simulation, proving that it's not completely useless.
                          – maxb
                          Dec 20 at 8:28




                          1




                          1




                          IT WON A GAME?! That is surprising.
                          – Zacharý
                          Dec 20 at 21:17




                          IT WON A GAME?! That is surprising.
                          – Zacharý
                          Dec 20 at 21:17











                          3














                          LizduadacBot



                          Tries to win in 1 step. End condition is somewhat arbritrary.



                          This is also my first post (and I'm new to Python), so if I beat "PointsAreForNerdsBot", I'd be happy!





                          class LizduadacBot(Bot):

                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 50 or scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False





                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                            – maxb
                            Dec 21 at 23:30










                          • By "hard time", they mean it's impossible (unless I misunderstood greatly)
                            – Zacharý
                            Dec 22 at 1:37










                          • @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                            – lizduadac
                            Dec 22 at 23:39
















                          3














                          LizduadacBot



                          Tries to win in 1 step. End condition is somewhat arbritrary.



                          This is also my first post (and I'm new to Python), so if I beat "PointsAreForNerdsBot", I'd be happy!





                          class LizduadacBot(Bot):

                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 50 or scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False





                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                            – maxb
                            Dec 21 at 23:30










                          • By "hard time", they mean it's impossible (unless I misunderstood greatly)
                            – Zacharý
                            Dec 22 at 1:37










                          • @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                            – lizduadac
                            Dec 22 at 23:39














                          3












                          3








                          3






                          LizduadacBot



                          Tries to win in 1 step. End condition is somewhat arbritrary.



                          This is also my first post (and I'm new to Python), so if I beat "PointsAreForNerdsBot", I'd be happy!





                          class LizduadacBot(Bot):

                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 50 or scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False





                          share|improve this answer










                          New contributor




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









                          LizduadacBot



                          Tries to win in 1 step. End condition is somewhat arbritrary.



                          This is also my first post (and I'm new to Python), so if I beat "PointsAreForNerdsBot", I'd be happy!





                          class LizduadacBot(Bot):

                          def make_throw(self, scores, last_round):
                          while scores[self.index] + sum(self.current_throws) < 50 or scores[self.index] + sum(self.current_throws) < max(scores):
                          yield True
                          yield False






                          share|improve this answer










                          New contributor




                          lizduadac 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 Dec 21 at 22:11





















                          New contributor




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









                          answered Dec 21 at 22:05









                          lizduadac

                          313




                          313




                          New contributor




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





                          New contributor





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






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












                          • Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                            – maxb
                            Dec 21 at 23:30










                          • By "hard time", they mean it's impossible (unless I misunderstood greatly)
                            – Zacharý
                            Dec 22 at 1:37










                          • @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                            – lizduadac
                            Dec 22 at 23:39


















                          • Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                            – maxb
                            Dec 21 at 23:30










                          • By "hard time", they mean it's impossible (unless I misunderstood greatly)
                            – Zacharý
                            Dec 22 at 1:37










                          • @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                            – lizduadac
                            Dec 22 at 23:39
















                          Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                          – maxb
                          Dec 21 at 23:30




                          Welcome to PPCG (and welcome to Python)! You'd have a hard time losing against PointsAreForNerdsBot, but your bot actually fares quite well. I'll update the score either later tonight or tomorrow, but your winrate is about 15%, which is higher than the average 12.5%.
                          – maxb
                          Dec 21 at 23:30












                          By "hard time", they mean it's impossible (unless I misunderstood greatly)
                          – Zacharý
                          Dec 22 at 1:37




                          By "hard time", they mean it's impossible (unless I misunderstood greatly)
                          – Zacharý
                          Dec 22 at 1:37












                          @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                          – lizduadac
                          Dec 22 at 23:39




                          @maxb I actually didn't think the win rate would be that high! (I didn't test it out locally). I wonder if changing the 50 to be a bit higher/lower would increase the win rate.
                          – lizduadac
                          Dec 22 at 23:39











                          3














                          SlowStart



                          This bot implements the TCP Slow Start algorithm. It adjusts its number of rolls (nor) according to its previous turn: if it didn't roll a 6 in the previous turn, increases the nor for this turn; whereas it reduces nor if it did.



                          class SlowStart(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.completeLastRound = False
                          self.nor = 1
                          self.threshold = 8

                          def updateValues(self):
                          if self.completeLastRound:
                          if self.nor < self.threshold:
                          self.nor *= 2
                          else:
                          self.nor += 1
                          else:
                          self.threshold = self.nor // 2
                          self.nor = 1


                          def make_throw(self, scores, last_round):

                          self.updateValues()
                          self.completeLastRound = False

                          i = 1
                          while i < self.nor:
                          yield True

                          self.completeLastRound = True
                          yield False





                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                            – maxb
                            Dec 20 at 11:27






                          • 2




                            Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                            – maxb
                            Dec 20 at 11:32










                          • In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                            – maxb
                            Dec 20 at 12:25
















                          3














                          SlowStart



                          This bot implements the TCP Slow Start algorithm. It adjusts its number of rolls (nor) according to its previous turn: if it didn't roll a 6 in the previous turn, increases the nor for this turn; whereas it reduces nor if it did.



                          class SlowStart(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.completeLastRound = False
                          self.nor = 1
                          self.threshold = 8

                          def updateValues(self):
                          if self.completeLastRound:
                          if self.nor < self.threshold:
                          self.nor *= 2
                          else:
                          self.nor += 1
                          else:
                          self.threshold = self.nor // 2
                          self.nor = 1


                          def make_throw(self, scores, last_round):

                          self.updateValues()
                          self.completeLastRound = False

                          i = 1
                          while i < self.nor:
                          yield True

                          self.completeLastRound = True
                          yield False





                          share|improve this answer










                          New contributor




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


















                          • Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                            – maxb
                            Dec 20 at 11:27






                          • 2




                            Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                            – maxb
                            Dec 20 at 11:32










                          • In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                            – maxb
                            Dec 20 at 12:25














                          3












                          3








                          3






                          SlowStart



                          This bot implements the TCP Slow Start algorithm. It adjusts its number of rolls (nor) according to its previous turn: if it didn't roll a 6 in the previous turn, increases the nor for this turn; whereas it reduces nor if it did.



                          class SlowStart(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.completeLastRound = False
                          self.nor = 1
                          self.threshold = 8

                          def updateValues(self):
                          if self.completeLastRound:
                          if self.nor < self.threshold:
                          self.nor *= 2
                          else:
                          self.nor += 1
                          else:
                          self.threshold = self.nor // 2
                          self.nor = 1


                          def make_throw(self, scores, last_round):

                          self.updateValues()
                          self.completeLastRound = False

                          i = 1
                          while i < self.nor:
                          yield True

                          self.completeLastRound = True
                          yield False





                          share|improve this answer










                          New contributor




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









                          SlowStart



                          This bot implements the TCP Slow Start algorithm. It adjusts its number of rolls (nor) according to its previous turn: if it didn't roll a 6 in the previous turn, increases the nor for this turn; whereas it reduces nor if it did.



                          class SlowStart(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.completeLastRound = False
                          self.nor = 1
                          self.threshold = 8

                          def updateValues(self):
                          if self.completeLastRound:
                          if self.nor < self.threshold:
                          self.nor *= 2
                          else:
                          self.nor += 1
                          else:
                          self.threshold = self.nor // 2
                          self.nor = 1


                          def make_throw(self, scores, last_round):

                          self.updateValues()
                          self.completeLastRound = False

                          i = 1
                          while i < self.nor:
                          yield True

                          self.completeLastRound = True
                          yield False






                          share|improve this answer










                          New contributor




                          quite.SimpLe 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 Dec 22 at 22:46









                          BMO

                          11.3k22185




                          11.3k22185






                          New contributor




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









                          answered Dec 20 at 11:11









                          quite.SimpLe

                          312




                          312




                          New contributor




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





                          New contributor





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






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












                          • Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                            – maxb
                            Dec 20 at 11:27






                          • 2




                            Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                            – maxb
                            Dec 20 at 11:32










                          • In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                            – maxb
                            Dec 20 at 12:25


















                          • Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                            – maxb
                            Dec 20 at 11:27






                          • 2




                            Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                            – maxb
                            Dec 20 at 11:32










                          • In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                            – maxb
                            Dec 20 at 12:25
















                          Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                          – maxb
                          Dec 20 at 11:27




                          Welcome to PPCG! Interesting approach, I don't know how sensitive it is to random fluctuations. Two things that are needed to make this run: def updateValues(): should be def updateValues(self): (or def update_values(self): if you want to follow PEP8). Secondly, the call updateValues() should instead be self.updateValues() (or self.update_vales()).
                          – maxb
                          Dec 20 at 11:27




                          2




                          2




                          Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                          – maxb
                          Dec 20 at 11:32




                          Also, I think you need to update your i variable in the while loop. Right now your bot either passes the while loop entirely or is stuck in the while loop until it hits 6.
                          – maxb
                          Dec 20 at 11:32












                          In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                          – maxb
                          Dec 20 at 12:25




                          In the current highscore, I took the liberty of implementing these changes. I think you could experiment with the initial value for self.nor and see how it affects the performance of your bot.
                          – maxb
                          Dec 20 at 12:25











                          2














                          BringMyOwn_dice (BMO_d)





                          This bot loves dice, it brings 2 (seems to perform the best) dice of its own. Before throwing dice in a round, it throws its own 2 dice and computes their sum, this is the number of throws it is going to perform, it only throws if it doesn't already have 40 points.



                          class BringMyOwn_dice(Bot):

                          def __init__(self, *args):
                          import random as rnd
                          self.die = lambda: rnd.randint(1,6)
                          super().__init__(*args)

                          def make_throw(self, scores, last_round):

                          nfaces = self.die() + self.die()

                          s = scores[self.index]
                          max_scores = max(scores)

                          for _ in range(nfaces):
                          if s + sum(self.current_throws) > 39:
                          break
                          yield True

                          yield False





                          share|improve this answer



















                          • 2




                            I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                            – maxb
                            Dec 19 at 15:08
















                          2














                          BringMyOwn_dice (BMO_d)





                          This bot loves dice, it brings 2 (seems to perform the best) dice of its own. Before throwing dice in a round, it throws its own 2 dice and computes their sum, this is the number of throws it is going to perform, it only throws if it doesn't already have 40 points.



                          class BringMyOwn_dice(Bot):

                          def __init__(self, *args):
                          import random as rnd
                          self.die = lambda: rnd.randint(1,6)
                          super().__init__(*args)

                          def make_throw(self, scores, last_round):

                          nfaces = self.die() + self.die()

                          s = scores[self.index]
                          max_scores = max(scores)

                          for _ in range(nfaces):
                          if s + sum(self.current_throws) > 39:
                          break
                          yield True

                          yield False





                          share|improve this answer



















                          • 2




                            I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                            – maxb
                            Dec 19 at 15:08














                          2












                          2








                          2






                          BringMyOwn_dice (BMO_d)





                          This bot loves dice, it brings 2 (seems to perform the best) dice of its own. Before throwing dice in a round, it throws its own 2 dice and computes their sum, this is the number of throws it is going to perform, it only throws if it doesn't already have 40 points.



                          class BringMyOwn_dice(Bot):

                          def __init__(self, *args):
                          import random as rnd
                          self.die = lambda: rnd.randint(1,6)
                          super().__init__(*args)

                          def make_throw(self, scores, last_round):

                          nfaces = self.die() + self.die()

                          s = scores[self.index]
                          max_scores = max(scores)

                          for _ in range(nfaces):
                          if s + sum(self.current_throws) > 39:
                          break
                          yield True

                          yield False





                          share|improve this answer














                          BringMyOwn_dice (BMO_d)





                          This bot loves dice, it brings 2 (seems to perform the best) dice of its own. Before throwing dice in a round, it throws its own 2 dice and computes their sum, this is the number of throws it is going to perform, it only throws if it doesn't already have 40 points.



                          class BringMyOwn_dice(Bot):

                          def __init__(self, *args):
                          import random as rnd
                          self.die = lambda: rnd.randint(1,6)
                          super().__init__(*args)

                          def make_throw(self, scores, last_round):

                          nfaces = self.die() + self.die()

                          s = scores[self.index]
                          max_scores = max(scores)

                          for _ in range(nfaces):
                          if s + sum(self.current_throws) > 39:
                          break
                          yield True

                          yield False






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 19 at 15:22

























                          answered Dec 19 at 14:57









                          BMO

                          11.3k22185




                          11.3k22185








                          • 2




                            I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                            – maxb
                            Dec 19 at 15:08














                          • 2




                            I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                            – maxb
                            Dec 19 at 15:08








                          2




                          2




                          I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                          – maxb
                          Dec 19 at 15:08




                          I was thinking of a random bot using a coin flip, but this is more in spirit with the challenge! I think that two dice perform the best, since you get the most points per round when you cast the die 5-6 times, close to the average score when casting two dice.
                          – maxb
                          Dec 19 at 15:08











                          2














                          QuotaBot



                          A naive "quota" system I implemeneted, which actually seemed to score fairly highly overall.





                          class QuotaBot(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.quota = 20
                          self.minquota = 15
                          self.maxquota = 35

                          def make_throw(self, scores, last_round):
                          # Reduce quota if ahead, increase if behind
                          mean = sum(scores) / len(scores)
                          own_score = scores[self.index]

                          if own_score < mean - 5:
                          self.quota += 1.5
                          if own_score > mean + 5:
                          self.quota -= 1.5

                          self.quota = max(min(self.quota, self.maxquota), self.minquota)

                          if last_round:
                          self.quota = max(scores) - own_score + 1

                          while sum(self.current_throws) < self.quota:
                          yield True

                          yield False







                          share|improve this answer























                          • if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                            – Spitemaster
                            Dec 19 at 17:05












                          • @Spitemaster was an error pasting into stack exchange, should work now.
                            – FlipTack
                            Dec 19 at 17:09










                          • @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                            – FlipTack
                            Dec 19 at 17:09
















                          2














                          QuotaBot



                          A naive "quota" system I implemeneted, which actually seemed to score fairly highly overall.





                          class QuotaBot(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.quota = 20
                          self.minquota = 15
                          self.maxquota = 35

                          def make_throw(self, scores, last_round):
                          # Reduce quota if ahead, increase if behind
                          mean = sum(scores) / len(scores)
                          own_score = scores[self.index]

                          if own_score < mean - 5:
                          self.quota += 1.5
                          if own_score > mean + 5:
                          self.quota -= 1.5

                          self.quota = max(min(self.quota, self.maxquota), self.minquota)

                          if last_round:
                          self.quota = max(scores) - own_score + 1

                          while sum(self.current_throws) < self.quota:
                          yield True

                          yield False







                          share|improve this answer























                          • if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                            – Spitemaster
                            Dec 19 at 17:05












                          • @Spitemaster was an error pasting into stack exchange, should work now.
                            – FlipTack
                            Dec 19 at 17:09










                          • @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                            – FlipTack
                            Dec 19 at 17:09














                          2












                          2








                          2






                          QuotaBot



                          A naive "quota" system I implemeneted, which actually seemed to score fairly highly overall.





                          class QuotaBot(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.quota = 20
                          self.minquota = 15
                          self.maxquota = 35

                          def make_throw(self, scores, last_round):
                          # Reduce quota if ahead, increase if behind
                          mean = sum(scores) / len(scores)
                          own_score = scores[self.index]

                          if own_score < mean - 5:
                          self.quota += 1.5
                          if own_score > mean + 5:
                          self.quota -= 1.5

                          self.quota = max(min(self.quota, self.maxquota), self.minquota)

                          if last_round:
                          self.quota = max(scores) - own_score + 1

                          while sum(self.current_throws) < self.quota:
                          yield True

                          yield False







                          share|improve this answer














                          QuotaBot



                          A naive "quota" system I implemeneted, which actually seemed to score fairly highly overall.





                          class QuotaBot(Bot):
                          def __init__(self, *args):
                          super().__init__(*args)
                          self.quota = 20
                          self.minquota = 15
                          self.maxquota = 35

                          def make_throw(self, scores, last_round):
                          # Reduce quota if ahead, increase if behind
                          mean = sum(scores) / len(scores)
                          own_score = scores[self.index]

                          if own_score < mean - 5:
                          self.quota += 1.5
                          if own_score > mean + 5:
                          self.quota -= 1.5

                          self.quota = max(min(self.quota, self.maxquota), self.minquota)

                          if last_round:
                          self.quota = max(scores) - own_score + 1

                          while sum(self.current_throws) < self.quota:
                          yield True

                          yield False








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 19 at 17:09

























                          answered Dec 19 at 16:52









                          FlipTack

                          9,12834089




                          9,12834089












                          • if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                            – Spitemaster
                            Dec 19 at 17:05












                          • @Spitemaster was an error pasting into stack exchange, should work now.
                            – FlipTack
                            Dec 19 at 17:09










                          • @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                            – FlipTack
                            Dec 19 at 17:09


















                          • if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                            – Spitemaster
                            Dec 19 at 17:05












                          • @Spitemaster was an error pasting into stack exchange, should work now.
                            – FlipTack
                            Dec 19 at 17:09










                          • @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                            – FlipTack
                            Dec 19 at 17:09
















                          if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                          – Spitemaster
                          Dec 19 at 17:05






                          if own_score mean + 5: gives an error for me. Also while sum(self.current_throws)
                          – Spitemaster
                          Dec 19 at 17:05














                          @Spitemaster was an error pasting into stack exchange, should work now.
                          – FlipTack
                          Dec 19 at 17:09




                          @Spitemaster was an error pasting into stack exchange, should work now.
                          – FlipTack
                          Dec 19 at 17:09












                          @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                          – FlipTack
                          Dec 19 at 17:09




                          @Spitemaster it's because there were < and > symbols which interfered with the <pre> tags i was using
                          – FlipTack
                          Dec 19 at 17:09











                          2














                          BinaryBot



                          Tries to get close to the end score, so that as soon as somebody else triggers the last round it can beat their score for the win. Target is always halfway between current score and end score.





                          class BinaryBot(Bot):

                          def make_throw(self, scores, last_round):
                          target = (self.end_score + scores[self.index]) / 2
                          if last_round:
                          target = max(scores)

                          while scores[self.index] + sum(self.current_throws) < target:
                          yield True

                          yield False





                          share|improve this answer























                          • Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                            – Christian Sievers
                            Dec 19 at 22:15
















                          2














                          BinaryBot



                          Tries to get close to the end score, so that as soon as somebody else triggers the last round it can beat their score for the win. Target is always halfway between current score and end score.





                          class BinaryBot(Bot):

                          def make_throw(self, scores, last_round):
                          target = (self.end_score + scores[self.index]) / 2
                          if last_round:
                          target = max(scores)

                          while scores[self.index] + sum(self.current_throws) < target:
                          yield True

                          yield False





                          share|improve this answer























                          • Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                            – Christian Sievers
                            Dec 19 at 22:15














                          2












                          2








                          2






                          BinaryBot



                          Tries to get close to the end score, so that as soon as somebody else triggers the last round it can beat their score for the win. Target is always halfway between current score and end score.





                          class BinaryBot(Bot):

                          def make_throw(self, scores, last_round):
                          target = (self.end_score + scores[self.index]) / 2
                          if last_round:
                          target = max(scores)

                          while scores[self.index] + sum(self.current_throws) < target:
                          yield True

                          yield False





                          share|improve this answer














                          BinaryBot



                          Tries to get close to the end score, so that as soon as somebody else triggers the last round it can beat their score for the win. Target is always halfway between current score and end score.





                          class BinaryBot(Bot):

                          def make_throw(self, scores, last_round):
                          target = (self.end_score + scores[self.index]) / 2
                          if last_round:
                          target = max(scores)

                          while scores[self.index] + sum(self.current_throws) < target:
                          yield True

                          yield False






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 19 at 22:38

























                          answered Dec 19 at 21:36









                          Cain

                          939513




                          939513












                          • Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                            – Christian Sievers
                            Dec 19 at 22:15


















                          • Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                            – Christian Sievers
                            Dec 19 at 22:15
















                          Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                          – Christian Sievers
                          Dec 19 at 22:15




                          Interesting, Hesitate also refuses to cross the line first. You need to surround your function with the class stuff.
                          – Christian Sievers
                          Dec 19 at 22:15











                          2














                          BlessRNG



                          class BlessRNG(Bot):
                          def make_throw(self, scores, last_round):
                          if random.randint(1,2) == 1 :
                          yield True
                          yield False


                          BlessRNG FrankerZ GabeN BlessRNG






                          share|improve this answer










                          New contributor




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























                            2














                            BlessRNG



                            class BlessRNG(Bot):
                            def make_throw(self, scores, last_round):
                            if random.randint(1,2) == 1 :
                            yield True
                            yield False


                            BlessRNG FrankerZ GabeN BlessRNG






                            share|improve this answer










                            New contributor




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





















                              2












                              2








                              2






                              BlessRNG



                              class BlessRNG(Bot):
                              def make_throw(self, scores, last_round):
                              if random.randint(1,2) == 1 :
                              yield True
                              yield False


                              BlessRNG FrankerZ GabeN BlessRNG






                              share|improve this answer










                              New contributor




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









                              BlessRNG



                              class BlessRNG(Bot):
                              def make_throw(self, scores, last_round):
                              if random.randint(1,2) == 1 :
                              yield True
                              yield False


                              BlessRNG FrankerZ GabeN BlessRNG







                              share|improve this answer










                              New contributor




                              Dice Mastah 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 Dec 20 at 12:26









                              maxb

                              2,90611131




                              2,90611131






                              New contributor




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









                              answered Dec 20 at 4:40









                              Dice Mastah

                              211




                              211




                              New contributor




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





                              New contributor





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






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























                                  1














                                  class ThrowThriceBot(Bot):

                                  def make_throw(self, scores, last_round):
                                  yield True
                                  yield True
                                  yield False


                                  Well, that one is obvious






                                  share|improve this answer





















                                  • I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                    – maxb
                                    Dec 19 at 13:21










                                  • Also, congratulations on your first KotH answer!
                                    – maxb
                                    Dec 19 at 13:34
















                                  1














                                  class ThrowThriceBot(Bot):

                                  def make_throw(self, scores, last_round):
                                  yield True
                                  yield True
                                  yield False


                                  Well, that one is obvious






                                  share|improve this answer





















                                  • I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                    – maxb
                                    Dec 19 at 13:21










                                  • Also, congratulations on your first KotH answer!
                                    – maxb
                                    Dec 19 at 13:34














                                  1












                                  1








                                  1






                                  class ThrowThriceBot(Bot):

                                  def make_throw(self, scores, last_round):
                                  yield True
                                  yield True
                                  yield False


                                  Well, that one is obvious






                                  share|improve this answer












                                  class ThrowThriceBot(Bot):

                                  def make_throw(self, scores, last_round):
                                  yield True
                                  yield True
                                  yield False


                                  Well, that one is obvious







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Dec 19 at 13:00









                                  michi7x7

                                  36526




                                  36526












                                  • I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                    – maxb
                                    Dec 19 at 13:21










                                  • Also, congratulations on your first KotH answer!
                                    – maxb
                                    Dec 19 at 13:34


















                                  • I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                    – maxb
                                    Dec 19 at 13:21










                                  • Also, congratulations on your first KotH answer!
                                    – maxb
                                    Dec 19 at 13:34
















                                  I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                  – maxb
                                  Dec 19 at 13:21




                                  I have done some experiments with that class of bots (it was the tactic I used when I played the game for the first time). I went with 4 throws then, though 5-6 have a higher average score per round.
                                  – maxb
                                  Dec 19 at 13:21












                                  Also, congratulations on your first KotH answer!
                                  – maxb
                                  Dec 19 at 13:34




                                  Also, congratulations on your first KotH answer!
                                  – maxb
                                  Dec 19 at 13:34











                                  1














                                  Hesitate



                                  class Hesitate(Bot):
                                  def make_throw(self, scores, last_round):
                                  myscore = scores[self.index]
                                  if last_round:
                                  target = max(scores)+1
                                  elif myscore==0:
                                  target = 17
                                  else:
                                  target = 35
                                  while myscore+sum(self.current_throws) < target:
                                  yield True
                                  yield False





                                  share|improve this answer


























                                    1














                                    Hesitate



                                    class Hesitate(Bot):
                                    def make_throw(self, scores, last_round):
                                    myscore = scores[self.index]
                                    if last_round:
                                    target = max(scores)+1
                                    elif myscore==0:
                                    target = 17
                                    else:
                                    target = 35
                                    while myscore+sum(self.current_throws) < target:
                                    yield True
                                    yield False





                                    share|improve this answer
























                                      1












                                      1








                                      1






                                      Hesitate



                                      class Hesitate(Bot):
                                      def make_throw(self, scores, last_round):
                                      myscore = scores[self.index]
                                      if last_round:
                                      target = max(scores)+1
                                      elif myscore==0:
                                      target = 17
                                      else:
                                      target = 35
                                      while myscore+sum(self.current_throws) < target:
                                      yield True
                                      yield False





                                      share|improve this answer












                                      Hesitate



                                      class Hesitate(Bot):
                                      def make_throw(self, scores, last_round):
                                      myscore = scores[self.index]
                                      if last_round:
                                      target = max(scores)+1
                                      elif myscore==0:
                                      target = 17
                                      else:
                                      target = 35
                                      while myscore+sum(self.current_throws) < target:
                                      yield True
                                      yield False






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Dec 19 at 15:55









                                      Christian Sievers

                                      4,92711019




                                      4,92711019























                                          1














                                          class LastRound(Bot):
                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 15 and not last_round and scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          while max(scores) > scores[self.index] + sum(self.current_throws):
                                          yield True
                                          yield False


                                          LastRound acts like it's always the last round and it's the last bot: it keeps rolling until it's in the lead. It also doesn't want to settle for less than 15 points unless it actually is the last round or it reaches 40 points.






                                          share|improve this answer























                                          • Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                            – maxb
                                            Dec 19 at 12:44






                                          • 1




                                            I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                            – Stuart Moore
                                            Dec 19 at 14:09










                                          • @StuartMoore Haha, yes, I think you're right. Thanks!
                                            – Spitemaster
                                            Dec 19 at 15:07










                                          • I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                            – Stuart Moore
                                            Dec 19 at 15:15






                                          • 2




                                            That's intentional. It always tries to be in the lead when ending its turn.
                                            – Spitemaster
                                            Dec 19 at 15:48
















                                          1














                                          class LastRound(Bot):
                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 15 and not last_round and scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          while max(scores) > scores[self.index] + sum(self.current_throws):
                                          yield True
                                          yield False


                                          LastRound acts like it's always the last round and it's the last bot: it keeps rolling until it's in the lead. It also doesn't want to settle for less than 15 points unless it actually is the last round or it reaches 40 points.






                                          share|improve this answer























                                          • Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                            – maxb
                                            Dec 19 at 12:44






                                          • 1




                                            I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                            – Stuart Moore
                                            Dec 19 at 14:09










                                          • @StuartMoore Haha, yes, I think you're right. Thanks!
                                            – Spitemaster
                                            Dec 19 at 15:07










                                          • I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                            – Stuart Moore
                                            Dec 19 at 15:15






                                          • 2




                                            That's intentional. It always tries to be in the lead when ending its turn.
                                            – Spitemaster
                                            Dec 19 at 15:48














                                          1












                                          1








                                          1






                                          class LastRound(Bot):
                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 15 and not last_round and scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          while max(scores) > scores[self.index] + sum(self.current_throws):
                                          yield True
                                          yield False


                                          LastRound acts like it's always the last round and it's the last bot: it keeps rolling until it's in the lead. It also doesn't want to settle for less than 15 points unless it actually is the last round or it reaches 40 points.






                                          share|improve this answer














                                          class LastRound(Bot):
                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 15 and not last_round and scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          while max(scores) > scores[self.index] + sum(self.current_throws):
                                          yield True
                                          yield False


                                          LastRound acts like it's always the last round and it's the last bot: it keeps rolling until it's in the lead. It also doesn't want to settle for less than 15 points unless it actually is the last round or it reaches 40 points.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Dec 19 at 16:35

























                                          answered Dec 19 at 12:26









                                          Spitemaster

                                          3736




                                          3736












                                          • Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                            – maxb
                                            Dec 19 at 12:44






                                          • 1




                                            I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                            – Stuart Moore
                                            Dec 19 at 14:09










                                          • @StuartMoore Haha, yes, I think you're right. Thanks!
                                            – Spitemaster
                                            Dec 19 at 15:07










                                          • I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                            – Stuart Moore
                                            Dec 19 at 15:15






                                          • 2




                                            That's intentional. It always tries to be in the lead when ending its turn.
                                            – Spitemaster
                                            Dec 19 at 15:48


















                                          • Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                            – maxb
                                            Dec 19 at 12:44






                                          • 1




                                            I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                            – Stuart Moore
                                            Dec 19 at 14:09










                                          • @StuartMoore Haha, yes, I think you're right. Thanks!
                                            – Spitemaster
                                            Dec 19 at 15:07










                                          • I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                            – Stuart Moore
                                            Dec 19 at 15:15






                                          • 2




                                            That's intentional. It always tries to be in the lead when ending its turn.
                                            – Spitemaster
                                            Dec 19 at 15:48
















                                          Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                          – maxb
                                          Dec 19 at 12:44




                                          Interesting approach. I think your bot suffers if it starts falling behind. Since the odds of getting >30 points in a single round are low, your bot is more likely to stay at its current score.
                                          – maxb
                                          Dec 19 at 12:44




                                          1




                                          1




                                          I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                          – Stuart Moore
                                          Dec 19 at 14:09




                                          I suspect this suffers from the same mistake I made (see NotTooFarBehindBot comments) - as in the last round, if you're not winning you'll keep throwing until you get a 6 (scores[self.index] never updates) Actually - do you have that inequality the wrong way? max(scores) will always be >= scores[self.index]
                                          – Stuart Moore
                                          Dec 19 at 14:09












                                          @StuartMoore Haha, yes, I think you're right. Thanks!
                                          – Spitemaster
                                          Dec 19 at 15:07




                                          @StuartMoore Haha, yes, I think you're right. Thanks!
                                          – Spitemaster
                                          Dec 19 at 15:07












                                          I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                          – Stuart Moore
                                          Dec 19 at 15:15




                                          I suspect you want "and last_round" on the 2nd while to do what you want - otherwise the 2nd while will be used whether or not last_round is true
                                          – Stuart Moore
                                          Dec 19 at 15:15




                                          2




                                          2




                                          That's intentional. It always tries to be in the lead when ending its turn.
                                          – Spitemaster
                                          Dec 19 at 15:48




                                          That's intentional. It always tries to be in the lead when ending its turn.
                                          – Spitemaster
                                          Dec 19 at 15:48











                                          1














                                          Take Five



                                          class TakeFive(Bot):
                                          def make_throw(self, scores, last_round):
                                          # Throw until we hit a 5.
                                          while self.current_throws[-1] != 5:
                                          # Don't get greedy.
                                          if scores[self.index] + sum(self.current_throws) >= self.end_score:
                                          break
                                          yield True

                                          # Go for the win on the last round.
                                          if last_round:
                                          while scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          yield False


                                          Half the time, we'll roll a 5 before a 6. When we do, cash out.






                                          share|improve this answer





















                                          • If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                            – Mnemonic
                                            Dec 19 at 21:08












                                          • In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                            – Spitemaster
                                            Dec 19 at 21:16
















                                          1














                                          Take Five



                                          class TakeFive(Bot):
                                          def make_throw(self, scores, last_round):
                                          # Throw until we hit a 5.
                                          while self.current_throws[-1] != 5:
                                          # Don't get greedy.
                                          if scores[self.index] + sum(self.current_throws) >= self.end_score:
                                          break
                                          yield True

                                          # Go for the win on the last round.
                                          if last_round:
                                          while scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          yield False


                                          Half the time, we'll roll a 5 before a 6. When we do, cash out.






                                          share|improve this answer





















                                          • If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                            – Mnemonic
                                            Dec 19 at 21:08












                                          • In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                            – Spitemaster
                                            Dec 19 at 21:16














                                          1












                                          1








                                          1






                                          Take Five



                                          class TakeFive(Bot):
                                          def make_throw(self, scores, last_round):
                                          # Throw until we hit a 5.
                                          while self.current_throws[-1] != 5:
                                          # Don't get greedy.
                                          if scores[self.index] + sum(self.current_throws) >= self.end_score:
                                          break
                                          yield True

                                          # Go for the win on the last round.
                                          if last_round:
                                          while scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          yield False


                                          Half the time, we'll roll a 5 before a 6. When we do, cash out.






                                          share|improve this answer












                                          Take Five



                                          class TakeFive(Bot):
                                          def make_throw(self, scores, last_round):
                                          # Throw until we hit a 5.
                                          while self.current_throws[-1] != 5:
                                          # Don't get greedy.
                                          if scores[self.index] + sum(self.current_throws) >= self.end_score:
                                          break
                                          yield True

                                          # Go for the win on the last round.
                                          if last_round:
                                          while scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          yield False


                                          Half the time, we'll roll a 5 before a 6. When we do, cash out.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Dec 19 at 21:05









                                          Mnemonic

                                          4,6951630




                                          4,6951630












                                          • If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                            – Mnemonic
                                            Dec 19 at 21:08












                                          • In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                            – Spitemaster
                                            Dec 19 at 21:16


















                                          • If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                            – Mnemonic
                                            Dec 19 at 21:08












                                          • In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                            – Spitemaster
                                            Dec 19 at 21:16
















                                          If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                          – Mnemonic
                                          Dec 19 at 21:08






                                          If we stop at 1 instead, it makes slower progress, but it's more likely to get to 40 in a single bound.
                                          – Mnemonic
                                          Dec 19 at 21:08














                                          In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                          – Spitemaster
                                          Dec 19 at 21:16




                                          In my tests, TakeOne got 20.868 points per round compared to TakeFive's 24.262 points per round (and also brought winrate from 0.291 to 0.259). So I don't think it's worth it.
                                          – Spitemaster
                                          Dec 19 at 21:16











                                          1














                                          ExpectationsBot



                                          Just plays it straight, calculates the expected value for the dice throw and only makes it if it's positive.





                                          class ExpectationsBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          #Positive average gain is 2.5, is the chance of loss greater than that?
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          while 2.5 > (costOf6 / 6.0):
                                          yield True
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          yield False


                                          I was having trouble running the controller, got a "NameError: name 'bots_per_game' is not defined" on the multithreaded one, so really no idea how this performs.






                                          share|improve this answer



















                                          • 1




                                            I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                            – Stuart Moore
                                            Dec 19 at 17:47










                                          • @StuartMoore That...is a very true point, yes
                                            – Cain
                                            Dec 19 at 18:39










                                          • I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                            – maxb
                                            Dec 19 at 19:47










                                          • @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                            – Cain
                                            Dec 19 at 21:23
















                                          1














                                          ExpectationsBot



                                          Just plays it straight, calculates the expected value for the dice throw and only makes it if it's positive.





                                          class ExpectationsBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          #Positive average gain is 2.5, is the chance of loss greater than that?
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          while 2.5 > (costOf6 / 6.0):
                                          yield True
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          yield False


                                          I was having trouble running the controller, got a "NameError: name 'bots_per_game' is not defined" on the multithreaded one, so really no idea how this performs.






                                          share|improve this answer



















                                          • 1




                                            I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                            – Stuart Moore
                                            Dec 19 at 17:47










                                          • @StuartMoore That...is a very true point, yes
                                            – Cain
                                            Dec 19 at 18:39










                                          • I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                            – maxb
                                            Dec 19 at 19:47










                                          • @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                            – Cain
                                            Dec 19 at 21:23














                                          1












                                          1








                                          1






                                          ExpectationsBot



                                          Just plays it straight, calculates the expected value for the dice throw and only makes it if it's positive.





                                          class ExpectationsBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          #Positive average gain is 2.5, is the chance of loss greater than that?
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          while 2.5 > (costOf6 / 6.0):
                                          yield True
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          yield False


                                          I was having trouble running the controller, got a "NameError: name 'bots_per_game' is not defined" on the multithreaded one, so really no idea how this performs.






                                          share|improve this answer














                                          ExpectationsBot



                                          Just plays it straight, calculates the expected value for the dice throw and only makes it if it's positive.





                                          class ExpectationsBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          #Positive average gain is 2.5, is the chance of loss greater than that?
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          while 2.5 > (costOf6 / 6.0):
                                          yield True
                                          costOf6 = sum(self.current_throws) if scores[self.index] + sum(self.current_throws) < 40 else scores[self.index] + sum(self.current_throws)
                                          yield False


                                          I was having trouble running the controller, got a "NameError: name 'bots_per_game' is not defined" on the multithreaded one, so really no idea how this performs.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Dec 20 at 8:20









                                          maxb

                                          2,90611131




                                          2,90611131










                                          answered Dec 19 at 17:42









                                          Cain

                                          939513




                                          939513








                                          • 1




                                            I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                            – Stuart Moore
                                            Dec 19 at 17:47










                                          • @StuartMoore That...is a very true point, yes
                                            – Cain
                                            Dec 19 at 18:39










                                          • I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                            – maxb
                                            Dec 19 at 19:47










                                          • @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                            – Cain
                                            Dec 19 at 21:23














                                          • 1




                                            I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                            – Stuart Moore
                                            Dec 19 at 17:47










                                          • @StuartMoore That...is a very true point, yes
                                            – Cain
                                            Dec 19 at 18:39










                                          • I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                            – maxb
                                            Dec 19 at 19:47










                                          • @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                            – Cain
                                            Dec 19 at 21:23








                                          1




                                          1




                                          I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                          – Stuart Moore
                                          Dec 19 at 17:47




                                          I think this ends up being equivalent to a "Go to 16" bot, but we don't have one of those yet
                                          – Stuart Moore
                                          Dec 19 at 17:47












                                          @StuartMoore That...is a very true point, yes
                                          – Cain
                                          Dec 19 at 18:39




                                          @StuartMoore That...is a very true point, yes
                                          – Cain
                                          Dec 19 at 18:39












                                          I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                          – maxb
                                          Dec 19 at 19:47




                                          I ran into your issues with the controller when I ran it on my Windows machine. Somehow it ran fine on my Linux machine. I'm updating the controller, and will update the post once it is done.
                                          – maxb
                                          Dec 19 at 19:47












                                          @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                          – Cain
                                          Dec 19 at 21:23




                                          @maxb Thanks, probably something about which variables are available in the different process. FYI also updated this, I made a silly error around yielding :/
                                          – Cain
                                          Dec 19 at 21:23











                                          1














                                          FortyTeen



                                          class FortyTeen(Bot):
                                          def make_throw(self, scores, last_round):
                                          if last_round:
                                          max_projected_score = max([score+14 if score<self.end_score else score for score in scores])
                                          target = max_projected_score - scores[self.index]
                                          else:
                                          target = 14

                                          while sum(self.current_throws) < target:
                                          yield True
                                          yield False


                                          Try for 14 points until the last round, then assume everyone else is going to try for 14 points and try to tie that score.






                                          share|improve this answer























                                          • I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                            – tsh
                                            Dec 20 at 3:01










                                          • I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                            – maxb
                                            Dec 20 at 8:23










                                          • Oops, edited to fix.
                                            – histocrat
                                            Dec 20 at 13:08
















                                          1














                                          FortyTeen



                                          class FortyTeen(Bot):
                                          def make_throw(self, scores, last_round):
                                          if last_round:
                                          max_projected_score = max([score+14 if score<self.end_score else score for score in scores])
                                          target = max_projected_score - scores[self.index]
                                          else:
                                          target = 14

                                          while sum(self.current_throws) < target:
                                          yield True
                                          yield False


                                          Try for 14 points until the last round, then assume everyone else is going to try for 14 points and try to tie that score.






                                          share|improve this answer























                                          • I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                            – tsh
                                            Dec 20 at 3:01










                                          • I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                            – maxb
                                            Dec 20 at 8:23










                                          • Oops, edited to fix.
                                            – histocrat
                                            Dec 20 at 13:08














                                          1












                                          1








                                          1






                                          FortyTeen



                                          class FortyTeen(Bot):
                                          def make_throw(self, scores, last_round):
                                          if last_round:
                                          max_projected_score = max([score+14 if score<self.end_score else score for score in scores])
                                          target = max_projected_score - scores[self.index]
                                          else:
                                          target = 14

                                          while sum(self.current_throws) < target:
                                          yield True
                                          yield False


                                          Try for 14 points until the last round, then assume everyone else is going to try for 14 points and try to tie that score.






                                          share|improve this answer














                                          FortyTeen



                                          class FortyTeen(Bot):
                                          def make_throw(self, scores, last_round):
                                          if last_round:
                                          max_projected_score = max([score+14 if score<self.end_score else score for score in scores])
                                          target = max_projected_score - scores[self.index]
                                          else:
                                          target = 14

                                          while sum(self.current_throws) < target:
                                          yield True
                                          yield False


                                          Try for 14 points until the last round, then assume everyone else is going to try for 14 points and try to tie that score.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Dec 20 at 13:07

























                                          answered Dec 20 at 2:40









                                          histocrat

                                          18.8k43072




                                          18.8k43072












                                          • I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                            – tsh
                                            Dec 20 at 3:01










                                          • I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                            – maxb
                                            Dec 20 at 8:23










                                          • Oops, edited to fix.
                                            – histocrat
                                            Dec 20 at 13:08


















                                          • I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                            – tsh
                                            Dec 20 at 3:01










                                          • I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                            – maxb
                                            Dec 20 at 8:23










                                          • Oops, edited to fix.
                                            – histocrat
                                            Dec 20 at 13:08
















                                          I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                          – tsh
                                          Dec 20 at 3:01




                                          I got TypeError: unsupported operand type(s) for -: 'list' and 'int' with your bot.
                                          – tsh
                                          Dec 20 at 3:01












                                          I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                          – maxb
                                          Dec 20 at 8:23




                                          I'm assuming that your max_projected_score should be the maximum of the list rather than the entire list, am I correct? Otherwise i get the same issue as tsh.
                                          – maxb
                                          Dec 20 at 8:23












                                          Oops, edited to fix.
                                          – histocrat
                                          Dec 20 at 13:08




                                          Oops, edited to fix.
                                          – histocrat
                                          Dec 20 at 13:08











                                          1














                                          Chaser



                                          class Chaser(Bot):
                                          def make_throw(self, scores, last_round):
                                          while max(scores) > (scores[self.index] + sum(self.current_throws)):
                                          yield True
                                          while last_round and (scores[self.index] + sum(self.current_throws)) < 44:
                                          yield True
                                          while self.not_thrown_firce() and sum(self.current_throws, scores[self.index]) < 44:
                                          yield True
                                          yield False

                                          def not_thrown_firce(self):
                                          return len(self.current_throws) < 4


                                          Chaser tries to catch up to position one
                                          If it's the last round he desperately tries to reach at least 50 points
                                          Just for good measure he throws at least four times no matter what



                                          [edit 1: added go-for-gold strategy in the last round]



                                          [edit 2: updated logic because I mistakenly thought a bot would score at 40 rather than only the highest bot scoring]



                                          [edit 3: made chaser a little more defensive in the end game]






                                          share|improve this answer










                                          New contributor




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


















                                          • Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                            – maxb
                                            Dec 20 at 9:50










                                          • Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                            – AKroell
                                            Dec 20 at 10:02










                                          • @JonathanFrech thanks, fixed
                                            – AKroell
                                            Dec 20 at 12:38
















                                          1














                                          Chaser



                                          class Chaser(Bot):
                                          def make_throw(self, scores, last_round):
                                          while max(scores) > (scores[self.index] + sum(self.current_throws)):
                                          yield True
                                          while last_round and (scores[self.index] + sum(self.current_throws)) < 44:
                                          yield True
                                          while self.not_thrown_firce() and sum(self.current_throws, scores[self.index]) < 44:
                                          yield True
                                          yield False

                                          def not_thrown_firce(self):
                                          return len(self.current_throws) < 4


                                          Chaser tries to catch up to position one
                                          If it's the last round he desperately tries to reach at least 50 points
                                          Just for good measure he throws at least four times no matter what



                                          [edit 1: added go-for-gold strategy in the last round]



                                          [edit 2: updated logic because I mistakenly thought a bot would score at 40 rather than only the highest bot scoring]



                                          [edit 3: made chaser a little more defensive in the end game]






                                          share|improve this answer










                                          New contributor




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


















                                          • Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                            – maxb
                                            Dec 20 at 9:50










                                          • Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                            – AKroell
                                            Dec 20 at 10:02










                                          • @JonathanFrech thanks, fixed
                                            – AKroell
                                            Dec 20 at 12:38














                                          1












                                          1








                                          1






                                          Chaser



                                          class Chaser(Bot):
                                          def make_throw(self, scores, last_round):
                                          while max(scores) > (scores[self.index] + sum(self.current_throws)):
                                          yield True
                                          while last_round and (scores[self.index] + sum(self.current_throws)) < 44:
                                          yield True
                                          while self.not_thrown_firce() and sum(self.current_throws, scores[self.index]) < 44:
                                          yield True
                                          yield False

                                          def not_thrown_firce(self):
                                          return len(self.current_throws) < 4


                                          Chaser tries to catch up to position one
                                          If it's the last round he desperately tries to reach at least 50 points
                                          Just for good measure he throws at least four times no matter what



                                          [edit 1: added go-for-gold strategy in the last round]



                                          [edit 2: updated logic because I mistakenly thought a bot would score at 40 rather than only the highest bot scoring]



                                          [edit 3: made chaser a little more defensive in the end game]






                                          share|improve this answer










                                          New contributor




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









                                          Chaser



                                          class Chaser(Bot):
                                          def make_throw(self, scores, last_round):
                                          while max(scores) > (scores[self.index] + sum(self.current_throws)):
                                          yield True
                                          while last_round and (scores[self.index] + sum(self.current_throws)) < 44:
                                          yield True
                                          while self.not_thrown_firce() and sum(self.current_throws, scores[self.index]) < 44:
                                          yield True
                                          yield False

                                          def not_thrown_firce(self):
                                          return len(self.current_throws) < 4


                                          Chaser tries to catch up to position one
                                          If it's the last round he desperately tries to reach at least 50 points
                                          Just for good measure he throws at least four times no matter what



                                          [edit 1: added go-for-gold strategy in the last round]



                                          [edit 2: updated logic because I mistakenly thought a bot would score at 40 rather than only the highest bot scoring]



                                          [edit 3: made chaser a little more defensive in the end game]







                                          share|improve this answer










                                          New contributor




                                          AKroell 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 Dec 20 at 14:22





















                                          New contributor




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









                                          answered Dec 20 at 9:30









                                          AKroell

                                          1113




                                          1113




                                          New contributor




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





                                          New contributor





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






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












                                          • Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                            – maxb
                                            Dec 20 at 9:50










                                          • Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                            – AKroell
                                            Dec 20 at 10:02










                                          • @JonathanFrech thanks, fixed
                                            – AKroell
                                            Dec 20 at 12:38


















                                          • Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                            – maxb
                                            Dec 20 at 9:50










                                          • Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                            – AKroell
                                            Dec 20 at 10:02










                                          • @JonathanFrech thanks, fixed
                                            – AKroell
                                            Dec 20 at 12:38
















                                          Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                          – maxb
                                          Dec 20 at 9:50




                                          Welcome to PPCG! Neat idea to not only try to catch up, but also pass the first place. I'm running a simulation right now, and I wish you luck!
                                          – maxb
                                          Dec 20 at 9:50












                                          Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                          – AKroell
                                          Dec 20 at 10:02




                                          Thanks! Initially I tried to surpass the previous leader by a fixed amount (tried values between 6 and 20) but it turns out just throwing twice more fairs better.
                                          – AKroell
                                          Dec 20 at 10:02












                                          @JonathanFrech thanks, fixed
                                          – AKroell
                                          Dec 20 at 12:38




                                          @JonathanFrech thanks, fixed
                                          – AKroell
                                          Dec 20 at 12:38











                                          1














                                          FutureBot



                                          class FutureBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while (random.randint(1,6) != 6) and (random.randint(1,6) != 6):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          OneStepAheadBot



                                          class OneStepAheadBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,6) != 6:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          A pair of bots, they bring their own sets of dice and rolls them to predict the future. If one is a 6 they stop, FutureBot can't remember which of it's 2 dice was for the next roll so it gives up.



                                          I wonder which will do better.



                                          OneStepAhead is a little too similar to OneInFive for my taste, but I also want to see how it compares to FutureBot and OneInFive.



                                          Edit: Now they stop after hitting 45






                                          share|improve this answer










                                          New contributor




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


















                                          • Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                            – maxb
                                            Dec 20 at 16:31










                                          • Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                            – william porter
                                            Dec 20 at 16:34


















                                          1














                                          FutureBot



                                          class FutureBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while (random.randint(1,6) != 6) and (random.randint(1,6) != 6):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          OneStepAheadBot



                                          class OneStepAheadBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,6) != 6:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          A pair of bots, they bring their own sets of dice and rolls them to predict the future. If one is a 6 they stop, FutureBot can't remember which of it's 2 dice was for the next roll so it gives up.



                                          I wonder which will do better.



                                          OneStepAhead is a little too similar to OneInFive for my taste, but I also want to see how it compares to FutureBot and OneInFive.



                                          Edit: Now they stop after hitting 45






                                          share|improve this answer










                                          New contributor




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


















                                          • Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                            – maxb
                                            Dec 20 at 16:31










                                          • Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                            – william porter
                                            Dec 20 at 16:34
















                                          1












                                          1








                                          1






                                          FutureBot



                                          class FutureBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while (random.randint(1,6) != 6) and (random.randint(1,6) != 6):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          OneStepAheadBot



                                          class OneStepAheadBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,6) != 6:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          A pair of bots, they bring their own sets of dice and rolls them to predict the future. If one is a 6 they stop, FutureBot can't remember which of it's 2 dice was for the next roll so it gives up.



                                          I wonder which will do better.



                                          OneStepAhead is a little too similar to OneInFive for my taste, but I also want to see how it compares to FutureBot and OneInFive.



                                          Edit: Now they stop after hitting 45






                                          share|improve this answer










                                          New contributor




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









                                          FutureBot



                                          class FutureBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while (random.randint(1,6) != 6) and (random.randint(1,6) != 6):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          OneStepAheadBot



                                          class OneStepAheadBot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,6) != 6:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > (self.end_score+5):
                                          break
                                          yield True
                                          yield False


                                          A pair of bots, they bring their own sets of dice and rolls them to predict the future. If one is a 6 they stop, FutureBot can't remember which of it's 2 dice was for the next roll so it gives up.



                                          I wonder which will do better.



                                          OneStepAhead is a little too similar to OneInFive for my taste, but I also want to see how it compares to FutureBot and OneInFive.



                                          Edit: Now they stop after hitting 45







                                          share|improve this answer










                                          New contributor




                                          william porter 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 Dec 21 at 8:46









                                          maxb

                                          2,90611131




                                          2,90611131






                                          New contributor




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









                                          answered Dec 20 at 16:16









                                          william porter

                                          1214




                                          1214




                                          New contributor




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





                                          New contributor





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






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












                                          • Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                            – maxb
                                            Dec 20 at 16:31










                                          • Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                            – william porter
                                            Dec 20 at 16:34




















                                          • Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                            – maxb
                                            Dec 20 at 16:31










                                          • Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                            – william porter
                                            Dec 20 at 16:34


















                                          Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                          – maxb
                                          Dec 20 at 16:31




                                          Welcome to PPCG! Your bot definitely plays with the spirit of the game! I'll run a simulation later this evening.
                                          – maxb
                                          Dec 20 at 16:31












                                          Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                          – william porter
                                          Dec 20 at 16:34






                                          Thanks! I'm curious as to how well it'll do, but I'm guessing it'll be on the low side.
                                          – william porter
                                          Dec 20 at 16:34













                                          1














                                          FlipCoinRollDice



                                          class FlipCoinRollDice(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,2) == 2:
                                          throws = random.randint(1,6) != 6
                                          x = 0
                                          while x < throws:
                                          x = x + 1
                                          yield True
                                          yield False


                                          This is a weird (untested) one. It flips a coin and if it's heads it rolls a dice and throws the amount the dice shows.



                                          I can't test it now so if there are syntax errors, let me know :)






                                          share|improve this answer





















                                          • When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                            – maxb
                                            Dec 21 at 14:37










                                          • Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                            – Martijn Vissers
                                            Dec 21 at 14:57






                                          • 1




                                            Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                            – maxb
                                            Dec 21 at 15:02










                                          • Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                            – Belhenix
                                            Dec 21 at 16:53
















                                          1














                                          FlipCoinRollDice



                                          class FlipCoinRollDice(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,2) == 2:
                                          throws = random.randint(1,6) != 6
                                          x = 0
                                          while x < throws:
                                          x = x + 1
                                          yield True
                                          yield False


                                          This is a weird (untested) one. It flips a coin and if it's heads it rolls a dice and throws the amount the dice shows.



                                          I can't test it now so if there are syntax errors, let me know :)






                                          share|improve this answer





















                                          • When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                            – maxb
                                            Dec 21 at 14:37










                                          • Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                            – Martijn Vissers
                                            Dec 21 at 14:57






                                          • 1




                                            Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                            – maxb
                                            Dec 21 at 15:02










                                          • Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                            – Belhenix
                                            Dec 21 at 16:53














                                          1












                                          1








                                          1






                                          FlipCoinRollDice



                                          class FlipCoinRollDice(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,2) == 2:
                                          throws = random.randint(1,6) != 6
                                          x = 0
                                          while x < throws:
                                          x = x + 1
                                          yield True
                                          yield False


                                          This is a weird (untested) one. It flips a coin and if it's heads it rolls a dice and throws the amount the dice shows.



                                          I can't test it now so if there are syntax errors, let me know :)






                                          share|improve this answer












                                          FlipCoinRollDice



                                          class FlipCoinRollDice(Bot):
                                          def make_throw(self, scores, last_round):
                                          while random.randint(1,2) == 2:
                                          throws = random.randint(1,6) != 6
                                          x = 0
                                          while x < throws:
                                          x = x + 1
                                          yield True
                                          yield False


                                          This is a weird (untested) one. It flips a coin and if it's heads it rolls a dice and throws the amount the dice shows.



                                          I can't test it now so if there are syntax errors, let me know :)







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Dec 21 at 14:26









                                          Martijn Vissers

                                          301311




                                          301311












                                          • When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                            – maxb
                                            Dec 21 at 14:37










                                          • Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                            – Martijn Vissers
                                            Dec 21 at 14:57






                                          • 1




                                            Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                            – maxb
                                            Dec 21 at 15:02










                                          • Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                            – Belhenix
                                            Dec 21 at 16:53


















                                          • When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                            – maxb
                                            Dec 21 at 14:37










                                          • Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                            – Martijn Vissers
                                            Dec 21 at 14:57






                                          • 1




                                            Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                            – maxb
                                            Dec 21 at 15:02










                                          • Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                            – Belhenix
                                            Dec 21 at 16:53
















                                          When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                          – maxb
                                          Dec 21 at 14:37




                                          When I saw the name, I was afraid that it'd be a copy of the BlessRNG or BringMyOwn_dice bots, but this is some kind of middle ground in a way. I'm running a simulation now! Congratulations on your first KotH answer by the way!
                                          – maxb
                                          Dec 21 at 14:37












                                          Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                          – Martijn Vissers
                                          Dec 21 at 14:57




                                          Thank you :) I was hesitant to post it at first. It might not perform the best but it will be interesting to see.
                                          – Martijn Vissers
                                          Dec 21 at 14:57




                                          1




                                          1




                                          Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                          – maxb
                                          Dec 21 at 15:02




                                          Don't hesitate, just look at PointsAreForNerdsBot, it's fun to participate even if you don't win.
                                          – maxb
                                          Dec 21 at 15:02












                                          Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                          – Belhenix
                                          Dec 21 at 16:53




                                          Rather than a syntax error it's a logic error: throws = random.randint(1,6) != 6 evaluates to a boolean instead of the random number
                                          – Belhenix
                                          Dec 21 at 16:53











                                          1














                                          LeadBy5Bot



                                          class LeadBy5Bot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while True:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          score_to_beat = max(scores) + 5
                                          if current_score >= score_to_beat:
                                          break
                                          yield True
                                          yield False


                                          Always wants to be in the lead by 5.



                                          Edit: New Bot



                                          RollForLuckBot



                                          class RollForLuckBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 21:
                                          yield True
                                          score_to_beat = max([x for i,x in enumerate(scores) if i!=self.index]) + 10
                                          score_to_beat = max(score_to_beat, 44)
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          while (last_round or (current_score >= 40)):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > score_to_beat:
                                          break
                                          yield True
                                          # roll more if we're feeling lucky
                                          while (random.randint(1,6) == self.current_throws[-1]):
                                          yield True
                                          yield False


                                          A bot that borrows from EnsureLead, I prefer using 21 as it's the average of 6d6 (6x3.5), with 6 dice rolls leaving > 70% chance of the next roll being a 6. Also, we continue to roll if we roll a separate die and match our last throw after hitting 21.






                                          share|improve this answer










                                          New contributor




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


















                                          • Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                            – william porter
                                            Dec 19 at 21:51










                                          • as a note, yield true should have upper T (python error)
                                            – Belhenix
                                            Dec 20 at 0:09










                                          • @Belhenix Edited, guess I missed that when I was typing it out.
                                            – william porter
                                            Dec 20 at 0:11










                                          • Woo, it made it into the top 50% (14 out of 28)
                                            – william porter
                                            Dec 20 at 17:35
















                                          1














                                          LeadBy5Bot



                                          class LeadBy5Bot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while True:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          score_to_beat = max(scores) + 5
                                          if current_score >= score_to_beat:
                                          break
                                          yield True
                                          yield False


                                          Always wants to be in the lead by 5.



                                          Edit: New Bot



                                          RollForLuckBot



                                          class RollForLuckBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 21:
                                          yield True
                                          score_to_beat = max([x for i,x in enumerate(scores) if i!=self.index]) + 10
                                          score_to_beat = max(score_to_beat, 44)
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          while (last_round or (current_score >= 40)):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > score_to_beat:
                                          break
                                          yield True
                                          # roll more if we're feeling lucky
                                          while (random.randint(1,6) == self.current_throws[-1]):
                                          yield True
                                          yield False


                                          A bot that borrows from EnsureLead, I prefer using 21 as it's the average of 6d6 (6x3.5), with 6 dice rolls leaving > 70% chance of the next roll being a 6. Also, we continue to roll if we roll a separate die and match our last throw after hitting 21.






                                          share|improve this answer










                                          New contributor




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


















                                          • Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                            – william porter
                                            Dec 19 at 21:51










                                          • as a note, yield true should have upper T (python error)
                                            – Belhenix
                                            Dec 20 at 0:09










                                          • @Belhenix Edited, guess I missed that when I was typing it out.
                                            – william porter
                                            Dec 20 at 0:11










                                          • Woo, it made it into the top 50% (14 out of 28)
                                            – william porter
                                            Dec 20 at 17:35














                                          1












                                          1








                                          1






                                          LeadBy5Bot



                                          class LeadBy5Bot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while True:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          score_to_beat = max(scores) + 5
                                          if current_score >= score_to_beat:
                                          break
                                          yield True
                                          yield False


                                          Always wants to be in the lead by 5.



                                          Edit: New Bot



                                          RollForLuckBot



                                          class RollForLuckBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 21:
                                          yield True
                                          score_to_beat = max([x for i,x in enumerate(scores) if i!=self.index]) + 10
                                          score_to_beat = max(score_to_beat, 44)
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          while (last_round or (current_score >= 40)):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > score_to_beat:
                                          break
                                          yield True
                                          # roll more if we're feeling lucky
                                          while (random.randint(1,6) == self.current_throws[-1]):
                                          yield True
                                          yield False


                                          A bot that borrows from EnsureLead, I prefer using 21 as it's the average of 6d6 (6x3.5), with 6 dice rolls leaving > 70% chance of the next roll being a 6. Also, we continue to roll if we roll a separate die and match our last throw after hitting 21.






                                          share|improve this answer










                                          New contributor




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









                                          LeadBy5Bot



                                          class LeadBy5Bot(Bot):
                                          def make_throw(self, scores, last_round):
                                          while True:
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          score_to_beat = max(scores) + 5
                                          if current_score >= score_to_beat:
                                          break
                                          yield True
                                          yield False


                                          Always wants to be in the lead by 5.



                                          Edit: New Bot



                                          RollForLuckBot



                                          class RollForLuckBot(Bot):

                                          def make_throw(self, scores, last_round):
                                          while sum(self.current_throws) < 21:
                                          yield True
                                          score_to_beat = max([x for i,x in enumerate(scores) if i!=self.index]) + 10
                                          score_to_beat = max(score_to_beat, 44)
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          while (last_round or (current_score >= 40)):
                                          current_score = scores[self.index] + sum(self.current_throws)
                                          if current_score > score_to_beat:
                                          break
                                          yield True
                                          # roll more if we're feeling lucky
                                          while (random.randint(1,6) == self.current_throws[-1]):
                                          yield True
                                          yield False


                                          A bot that borrows from EnsureLead, I prefer using 21 as it's the average of 6d6 (6x3.5), with 6 dice rolls leaving > 70% chance of the next roll being a 6. Also, we continue to roll if we roll a separate die and match our last throw after hitting 21.







                                          share|improve this answer










                                          New contributor




                                          william porter 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 Dec 21 at 17:40





















                                          New contributor




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









                                          answered Dec 19 at 21:50









                                          william porter

                                          1214




                                          1214




                                          New contributor




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





                                          New contributor





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






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












                                          • Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                            – william porter
                                            Dec 19 at 21:51










                                          • as a note, yield true should have upper T (python error)
                                            – Belhenix
                                            Dec 20 at 0:09










                                          • @Belhenix Edited, guess I missed that when I was typing it out.
                                            – william porter
                                            Dec 20 at 0:11










                                          • Woo, it made it into the top 50% (14 out of 28)
                                            – william porter
                                            Dec 20 at 17:35


















                                          • Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                            – william porter
                                            Dec 19 at 21:51










                                          • as a note, yield true should have upper T (python error)
                                            – Belhenix
                                            Dec 20 at 0:09










                                          • @Belhenix Edited, guess I missed that when I was typing it out.
                                            – william porter
                                            Dec 20 at 0:11










                                          • Woo, it made it into the top 50% (14 out of 28)
                                            – william porter
                                            Dec 20 at 17:35
















                                          Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                          – william porter
                                          Dec 19 at 21:51




                                          Didn't notice AlphaBot till after making it. I'm curious how they'll do in a game together.
                                          – william porter
                                          Dec 19 at 21:51












                                          as a note, yield true should have upper T (python error)
                                          – Belhenix
                                          Dec 20 at 0:09




                                          as a note, yield true should have upper T (python error)
                                          – Belhenix
                                          Dec 20 at 0:09












                                          @Belhenix Edited, guess I missed that when I was typing it out.
                                          – william porter
                                          Dec 20 at 0:11




                                          @Belhenix Edited, guess I missed that when I was typing it out.
                                          – william porter
                                          Dec 20 at 0:11












                                          Woo, it made it into the top 50% (14 out of 28)
                                          – william porter
                                          Dec 20 at 17:35




                                          Woo, it made it into the top 50% (14 out of 28)
                                          – william porter
                                          Dec 20 at 17:35











                                          1














                                          Stalker



                                          This bot tries to be within 4 points from the leader by the last round. Otherwise gets moderate gains



                                          class Stalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False

                                          # throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False


                                          AgressiveStalker



                                          This one goes aggressive if he is leading late towards the end game, otherwise stalks



                                          class AggressiveStalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False


                                          # if we are leading go for the win
                                          if max(scores) > 25 and max(scores) == scores[self.index]:
                                          while scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          yield False

                                          # if we are behind throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False





                                          share|improve this answer

















                                          • 1




                                            Very impressive securing the fifth place with AggressiveStalker!
                                            – maxb
                                            Dec 22 at 11:07
















                                          1














                                          Stalker



                                          This bot tries to be within 4 points from the leader by the last round. Otherwise gets moderate gains



                                          class Stalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False

                                          # throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False


                                          AgressiveStalker



                                          This one goes aggressive if he is leading late towards the end game, otherwise stalks



                                          class AggressiveStalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False


                                          # if we are leading go for the win
                                          if max(scores) > 25 and max(scores) == scores[self.index]:
                                          while scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          yield False

                                          # if we are behind throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False





                                          share|improve this answer

















                                          • 1




                                            Very impressive securing the fifth place with AggressiveStalker!
                                            – maxb
                                            Dec 22 at 11:07














                                          1












                                          1








                                          1






                                          Stalker



                                          This bot tries to be within 4 points from the leader by the last round. Otherwise gets moderate gains



                                          class Stalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False

                                          # throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False


                                          AgressiveStalker



                                          This one goes aggressive if he is leading late towards the end game, otherwise stalks



                                          class AggressiveStalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False


                                          # if we are leading go for the win
                                          if max(scores) > 25 and max(scores) == scores[self.index]:
                                          while scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          yield False

                                          # if we are behind throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False





                                          share|improve this answer












                                          Stalker



                                          This bot tries to be within 4 points from the leader by the last round. Otherwise gets moderate gains



                                          class Stalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False

                                          # throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False


                                          AgressiveStalker



                                          This one goes aggressive if he is leading late towards the end game, otherwise stalks



                                          class AggressiveStalker(Bot):

                                          def make_throw(self, scores, last_round):

                                          # on last round pray to rng gods to beat the highest score
                                          while last_round and scores[self.index] + sum(self.current_throws) <= max(scores):
                                          yield True

                                          if last_round and scores[self.index] + sum(self.current_throws) > max(scores):
                                          yield False

                                          # on the earlier rounds try to aim a moderate gain
                                          if max(scores) < 26:
                                          while sum(self.current_throws) < 16:
                                          yield True
                                          yield False


                                          # if we are leading go for the win
                                          if max(scores) > 25 and max(scores) == scores[self.index]:
                                          while scores[self.index] + sum(self.current_throws) < 40:
                                          yield True
                                          yield False

                                          # if we are behind throw until 1 dice throw behind the leader
                                          target = max(scores) - 5

                                          while scores[self.index] + sum(self.current_throws) <= target:
                                          yield True
                                          yield False






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Dec 21 at 21:34









                                          Ofya

                                          1716




                                          1716








                                          • 1




                                            Very impressive securing the fifth place with AggressiveStalker!
                                            – maxb
                                            Dec 22 at 11:07














                                          • 1




                                            Very impressive securing the fifth place with AggressiveStalker!
                                            – maxb
                                            Dec 22 at 11:07








                                          1




                                          1




                                          Very impressive securing the fifth place with AggressiveStalker!
                                          – maxb
                                          Dec 22 at 11:07




                                          Very impressive securing the fifth place with AggressiveStalker!
                                          – maxb
                                          Dec 22 at 11:07










                                          1 2
                                          next

















                                          draft saved

                                          draft discarded




















































                                          If this is an answer to a challenge…




                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                          More generally…




                                          • …Please make sure to answer the question and provide sufficient detail.


                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).






                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177765%2fa-game-of-dice-but-avoid-number-6%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Список кардиналов, возведённых папой римским Каликстом III

                                          Deduzione

                                          Mysql.sock missing - “Can't connect to local MySQL server through socket”