def tags_to_remove(self) -> List[str]: tag_factories = [Replay.create_player_tag, Replay.create_opponent_tag] deprecated_tags = flatten([[ tag_factory(_PROXY_TAG_PREFIX + structure.lower()) for structure in _PRODUCTION_STRUCTURES.keys() ] for tag_factory in tag_factories]) return deprecated_tags + flatten([[ _make_tag(tag_factory, structure) for structure in _PRODUCTION_STRUCTURES.keys() ] for tag_factory in tag_factories])
def tags_to_remove(self) -> List[str]: return flatten( [[tag_factory(BIO_TAG_NAME), tag_factory(MECH_TAG_NAME)] for tag_factory in [ Replay.create_player_tag, Replay.create_opponent_tag, ]])
def generate_tags(self, replay: Replay, replay_data_extractor: ReplayDataExtractor) -> List[str]: def get_unit_types( participant: Optional[sc2reader.objects.Participant], ) -> Set[str]: if not participant or not participant.units: return set() return set( ReplayDataExtractor.get_original_unit_name(unit) for unit in participant.units if unit.is_army) def generate_tags_inner( tag_factory: Callable[[str], str], participant: Optional[sc2reader.objects.Participant], ) -> List[str]: unit_types = get_unit_types(participant) return [ _make_tag(tag_factory, unit_type) for unit_type in unit_types if unit_type in HIGH_TECH_UNITS ] return flatten([ generate_tags_inner(Replay.create_player_tag, replay_data_extractor.player), generate_tags_inner(Replay.create_opponent_tag, replay_data_extractor.opponent), ])
def tags_to_remove(self) -> List[str]: return flatten( [[tag_factory(unit_name) for unit_name in HIGH_TECH_UNITS] for tag_factory in [ Replay.create_player_tag, Replay.create_opponent_tag, ]])
def tags_to_remove(self) -> List[str]: return flatten([[ tag_factory(tag_name) for _, tag_name in _PROTOSS_TECH_STRUCTURES.items() ] for tag_factory in [ Replay.create_player_tag, Replay.create_opponent_tag, ]])
def tags_to_remove(self) -> List[str]: race_tag_factories: List[Callable[[str], str]] = [ Replay.create_player_tag, Replay.create_opponent_tag, ] return flatten( [[race_tag_factory(race_name) for race_name in RACE_NAMES] for race_tag_factory in race_tag_factories])
def generate_tags(self, replay: Replay, replay_data_extractor: ReplayDataExtractor) -> List[str]: def get_army_supply( participant: Optional[sc2reader.objects.Participant], predicate: Callable[[Unit], bool] = None, ) -> float: def apply_predicate(unit: Unit) -> bool: return True if predicate is None else predicate(unit) if not participant: return 0 army_units = [ unit for unit in participant.units if unit.is_army and apply_predicate(unit) and unit.started_at < ReplayDataExtractor.LATE_GAME_START ] return sum(unit.supply for unit in army_units) def get_bio_supply( participant: Optional[sc2reader.objects.Participant], ) -> float: return get_army_supply( participant, lambda unit: ReplayDataExtractor.get_original_unit_name(unit) in _BIO_UNITS, ) def get_mech_supply( participant: Optional[sc2reader.objects.Participant], ) -> float: return get_army_supply( participant, lambda unit: ReplayDataExtractor.get_original_unit_name(unit) in _MECH_UNITS, ) def generate_tags_inner( participant: Optional[sc2reader.objects.Participant], tag_factory: Callable[[str], str], ) -> List[str]: bio_supply = get_bio_supply(participant) mech_supply = get_mech_supply(participant) army_supply = get_army_supply(participant) tags = [] if (bio_supply > mech_supply and bio_supply > army_supply * 0.5 and bio_supply > 35): tags.append(tag_factory(BIO_TAG_NAME)) if (mech_supply > bio_supply and mech_supply > army_supply * 0.5 and mech_supply > 35): tags.append(tag_factory(MECH_TAG_NAME)) return tags return flatten([ generate_tags_inner(replay_data_extractor.player, Replay.create_player_tag), generate_tags_inner(replay_data_extractor.opponent, Replay.create_opponent_tag), ])
def tags_to_remove(self) -> List[str]: tag_factories: List[Callable[[str], str]] = [ Replay.create_player_tag, Replay.create_opponent_tag, ] return flatten( [ [tag_factory(outcome) for outcome in OUTCOMES] for tag_factory in tag_factories ] )
def calculate_tag_frequency_table( replays: List[Replay], ignore_tags: List[str]) -> Dict[str, int]: tag_set = set(flatten(replay.tags for replay in replays)) frequency_table: Dict[str, int] = dict( (tag, _calculate_tag_frequency(tag, replays)) for tag in tag_set.difference(ignore_tags)) return OrderedDict( sorted( ((tag, freq) for tag, freq in frequency_table.items()), key=lambda x: x[1], reverse=True, ))