def run(self): strategy = MyStrategy() debug = Debug(self.writer) while True: message = model.ServerMessageGame.read_from(self.reader) if message.player_view is None: print("THE AND") break player_view = message.player_view #print("Level:" , player_view.game.level) actions = {} cont = 0 for unit in player_view.game.units: #print("cont = ", cont , " >> my_id", player_view.my_id) #print("cont = ", cont , " >> unit", unit) #print("cont = ", cont , " >>units::", player_view.game.units , "XXX") #print("cont = ", cont , " >>game::", player_view.game , "YYY") cont += 1 if unit.player_id == player_view.my_id: actions[unit.id] = strategy.get_action( unit, player_view.game, debug) else: print("PLAYER:unit.position.x", unit.position.x) print("PLAYER:unit.position.y", unit.position.y) ''' print("PLAYER:unit" , unit) print("PLAYER:unit.mines" , unit.mines) print("PLAYER:unit.health" , unit.health) print("PLAYER:unit.weapon" , unit.weapon) print("PLAYER:unit.id" , unit.id) print("PLAYER:unit.jump_state" , unit.jump_state) print("PLAYER:unit.on_ground" , unit.on_ground) print("PLAYER:unit.on_ladder" , unit.on_ladder) print("PLAYER:unit.player_id" , unit.player_id) print("PLAYER:unit.position" , unit.position) print("PLAYER:unit.size" , unit.size) print("PLAYER:unit.stand" , unit.stand) print("PLAYER:unit.walked_right" , unit.walked_right) print("PLAYER:unit_pos.y" , unit.position.y) ''' model.PlayerMessageGame.ActionMessage( model.Versioned(actions)).write_to(self.writer) self.writer.flush()
def run(self): strategy = MyStrategy() debug = Debug(self.writer) while True: message = model.ServerMessageGame.read_from(self.reader) if message.player_view is None: break player_view = message.player_view actions = {} for unit in player_view.game.units: if unit.player_id == player_view.my_id: actions[unit.id] = strategy.get_action( unit, player_view.game, debug) model.PlayerMessageGame.ActionMessage( model.Versioned(actions)).write_to(self.writer) self.writer.flush()
def run(self): strategy = MyStrategy() debug = Debug(self.writer) while True: message = model.ServerMessageGame.read_from(self.reader) if message.player_view is None: break player_view = message.player_view actions = {} for unit in player_view.game.units: if unit.player_id == player_view.my_id: actions[unit.id] = strategy.get_action( unit, player_view.game, debug) print("PLAYER:unit" , unit) print("PLAYER:unit.mines" , unit.mines) print("PLAYER:unit.health" , unit.health) print("PLAYER:unit.weapon" , unit.weapon) print("PLAYER:unit.id" , unit.id) print("PLAYER:unit.jump_state" , unit.jump_state) model.PlayerMessageGame.ActionMessage( model.Versioned(actions)).write_to(self.writer) self.writer.flush()