def hero_heuristic(self, status, hero_id): """ Heuristic that estimates the elo utility for a single hero. Arguments: status (Status): the game status. hero_id (int): the hero's id. Returns: float: the estimated utility for the hero. """ return hero_utility(status, hero_id, self.hero_score)
logger.set_header(game_number=game_number) logger.set_header(hero_id=env.hero_id) logger.set_header(elo=env.get_status().heroes[env.hero_id].elo) # Main loop of the game while not env.get_status().finished: print("(*) Game {}/{}".format(game_number, args.number)) print("(*) View url:", env.view_url) status = env.get_status() logger.store_status(status.turn, env.get_status_text()) print("(*) Status:\n", status, sep="") action = bot.think(status) print("(*) Action:", action) env.send_action(action) print("(*) Game over.") hero = status.heroes[env.hero_id] elo_diff = int(hero_utility(status, hero.id)) print("(*) Elo: {} {:+}".format(hero.elo, elo_diff)) # Log result logger.set_header(finished=True) logger.set_header(elo_diff=elo_diff) logger.write_data() print("(*) Wait a couple of seconds...") time.sleep(3) except Exception as e: print("/!\ Uncaught exception:", e)