def __init__(self): self.inventory = Inventory() self.incantation = Incantation() self.alive = True self.level = 1 self.look = [] self.cmd_queue = [] self.state = macro.AI_LOOK
def enough_trantor_for_incantation(self): if self.level == 1: return True incant = Incantation.incantation_to_level_up(self.level) trant_ready = self.messages.nb_of_trantor_ready_for_incantation( self.team, self.level) + 1 return incant.nb_player <= trant_ready
def action_to_perform(self): """ define next actio to perform by the trantor """ if self.inventory.nb_food < 4: return State.SEARCH_FOOD if self.messages.someone_to_join(self.team, self.level) != None: return State.JOIN_TRANTOR_FOR_INCANTATION if Incantation.is_trantor_ready(self): return State.START_INCANTATION return State.SEARCH_STONE
def stone_to_find(self): if self.voir == None: return None resources = Incantation.missing_resources(self) if resources == []: return None # first take the resources we can have imediately for res in resources: if self.voir[0].get_qt(res) > 0: return res return resources[0]
class Ai: """ Ai """ def __init__(self): self.inventory = Inventory() self.incantation = Incantation() self.alive = True self.level = 1 self.look = [] self.cmd_queue = [] self.state = macro.AI_LOOK def is_alive(self): """ Returns wether bot is alive or not Returns: bool: Bot is alive """ return self.alive def add_cmd(self, cmd): """ Add command in queue Args: cmd (str): command """ self.cmd_queue.append(cmd) def delete_cmd(self): """ Remove first command of queue """ self.cmd_queue.pop(0) def check_incantation(self): """ Check if the bot can perform an incantation """ return self.incantation.compare_ressources(self.inventory.bag, self.level) def update_look(self, data): """ Update look Args: data (str): data """ if not data or data == 'ko': return False data = data.replace('[', '') \ .replace(']', '') \ .split(',') nb_player = data[0].count('player') self.inventory.bag['player'] = nb_player self.look = data return True