"num_dice": current_num_dice, "dice_values": [], # no dice rolled yet } game_trace.append(current_turn) return current_num_dice def mod_dice(): roll = dice() if not game_trace: raise RuntimeError( "roll_dice called before either strategy function") game_trace[-1]["dice_values"].append(roll) return roll s0, s1 = play( lambda a, b: mod_strategy(0, a, b), lambda a, b: mod_strategy(1, a, b), score0, score1, dice=mod_dice, goal=goal, say=safe(say), feral_hogs=feral_hogs, ) return s0, s1, game_trace if __name__ == "__main__" or "gunicorn" in os.environ.get( "SERVER_SOFTWARE", ""): app = start(PORT, DEFAULT_SERVER, GUI_FOLDER)
"""Return a list of word_speed values describing the game.""" words = prompt.split() progress = Server.request_all_progress(targets=targets) start_times = [p[0][1] for p in progress] times_per_player = [[p[1] - s for p in ps] for s, ps in zip(start_times, progress)] game = cats.time_per_word(times_per_player, words) return cats.fastest_words(game) multiplayer.create_multiplayer_server() ############### # Favicons # ############### @route def favicon(): favicon_folder = os.path.join(GUI_FOLDER, "favicons") favicons = os.listdir(favicon_folder) path = os.path.join(favicon_folder, random.choice(favicons)) with open(path, "rb") as f: data = f.read() image_b64 = base64.b64encode(data).decode("utf-8") return "data:image/png;base64," + image_b64 if __name__ == "__main__" or os.environ.get("ENV") == "prod": app = start(PORT, DEFAULT_SERVER, GUI_FOLDER, multiplayer.db_init)