Esempio n. 1
0
    def DetermineGameStats(self, gameState: TekkenGameState):
        frames_ago = 4
        if self.current_game_event == None:
            if gameState.DidOppComboCounterJustStartXFramesAgo(frames_ago):
                gameState.BackToTheFuture(frames_ago)

                combo_counter_damage = gameState.GetOppComboDamageXFramesAgo(1)

                was_unblockable = gameState.IsOppAttackUnblockable()
                was_antiair = gameState.IsOppAttackAntiair()
                was_block_punish = gameState.DidBotStartGettingPunishedXFramesAgo(
                    1)
                perfect_punish = False
                if was_block_punish:
                    perfect_punish = gameState.WasBotMoveOnLastFrameXFramesAgo(
                        2)
                was_counter_hit = gameState.IsBotGettingCounterHit()
                was_ground_hit = gameState.IsBotGettingHitOnGround()

                was_whiff_punish = gameState.GetBotStartupXFramesAgo(2) > 0

                was_low_hit = gameState.IsOppAttackLow()
                was_mid_hit_on_crouching = gameState.IsOppAttackMid(
                ) and gameState.IsBotCrouching()
                was_throw = gameState.IsBotBeingThrown()

                was_damaged_during_attack = gameState.DidOppTakeDamageDuringStartup(
                )

                gameState.ReturnToPresent()

                if was_unblockable:
                    hit = GameStatEventEntry.EntryType.UNBLOCKABLE
                elif was_antiair:
                    hit = GameStatEventEntry.EntryType.ANTIAIR
                elif was_throw:
                    hit = GameStatEventEntry.EntryType.THROW
                elif was_damaged_during_attack:
                    hit = GameStatEventEntry.EntryType.POWER_CRUSHED
                elif was_block_punish:
                    hit = GameStatEventEntry.EntryType.PUNISH
                elif was_counter_hit:
                    hit = GameStatEventEntry.EntryType.COUNTER
                elif was_ground_hit:
                    hit = GameStatEventEntry.EntryType.GROUND
                elif was_whiff_punish:
                    hit = GameStatEventEntry.EntryType.WHIFF_PUNISH
                elif was_low_hit:
                    hit = GameStatEventEntry.EntryType.LOW
                elif was_mid_hit_on_crouching:
                    hit = GameStatEventEntry.EntryType.MID
                else:
                    hit = GameStatEventEntry.EntryType.NO_BLOCK
                self.current_game_event = GameStatEventEntry(
                    hit, combo_counter_damage)

                #print("event open")
            else:
                bot_damage_taken = gameState.DidBotJustTakeDamage(frames_ago +
                                                                  1)
                if bot_damage_taken > 0:
                    print('armored')
                    game_event = GameStatEventEntry(
                        GameStatEventEntry.EntryType.ARMORED, 0
                    )  #this is probably gonna break for Yoshimitsu's self damage moves
                    game_event.close_entry(1, bot_damage_taken, 0)

                    self.GameEvents.append(game_event)

        else:

            if gameState.DidOppComboCounterJustEndXFramesAgo(
                    frames_ago) or gameState.WasFightReset():
                hits = gameState.GetOppComboHitsXFramesAgo(frames_ago + 1)
                damage = gameState.GetOppComboDamageXFramesAgo(frames_ago + 1)
                juggle = gameState.GetOppJuggleDamageXFramesAgo(frames_ago + 1)
                self.current_game_event.close_entry(hits, damage, juggle)
                self.GameEvents.append(self.current_game_event)
                self.current_game_event = None
                #print("event closed")

        if gameState.WasFightReset():
            if (gameState.GetTimer(frames_ago) < 3600
                    and len(self.GameEvents) > 0) or True:
                summary = RoundSummary(
                    self.GameEvents, gameState.GetOppRoundSummary(frames_ago))
            self.GameEvents = []
Esempio n. 2
0
    def Update(self, gameState: TekkenGameState):
        if self.isPlayerOne:
            gameState.FlipMirror()

        bot_id = gameState.GetBotMoveId()
        opp_id = gameState.GetOppMoveId()
        bot_timer = gameState.GetBotMoveTimer()
        opp_timer = gameState.GetOppMoveTimer()

        if (gameState.IsOppWhiffing()) and (
                gameState.IsBotBlocking() or gameState.IsBotGettingHit()
                or gameState.IsBotBeingThrown()
                or gameState.IsBotStartedBeingJuggled()
                or gameState.IsBotBeingKnockedDown()
                or gameState.IsBotJustGrounded()):

            if gameState.DidBotIdChangeXMovesAgo(
                    self.active_frame_wait
            ) or gameState.DidBotTimerReduceXMovesAgo(
                    self.active_frame_wait
            ):  #or (opp_id != self.previous_opp_id and (100 < opp_id < 10000))
                if not self.active_frame_wait >= gameState.GetOppActiveFrames(
                ) + 1:
                    self.active_frame_wait += 1
                else:
                    self.active_frame_wait = 1

                    if opp_id in self.FrameData:
                        frameDataEntry = self.FrameData[opp_id]
                    else:
                        frameDataEntry = FrameDataEntry()
                        self.FrameData[opp_id] = frameDataEntry

                    frameDataEntry.currentFrameAdvantage = '??'
                    frameDataEntry.move_id = opp_id
                    frameDataEntry.damage = gameState.GetMostRecentOppDamage()

                    if gameState.GetOppStartup() > 0:
                        frameDataEntry.startup = gameState.GetOppStartup()
                        frameDataEntry.activeFrames = gameState.GetOppActiveFrames(
                        )
                        frameDataEntry.hitType = AttackType(
                            gameState.GetOppAttackType()).name
                        if gameState.IsOppAttackThrow():
                            frameDataEntry.hitType += "_THROW"
                        oldRecovery = 0
                    else:
                        snapshotOpp = gameState.GetLastOppWithDifferentMoveId()
                        if snapshotOpp != None:
                            frameDataEntry.startup = snapshotOpp.startup
                            frameDataEntry.activeFrames = snapshotOpp.GetActiveFrames(
                            )
                            frameDataEntry.hitType = AttackType(
                                snapshotOpp.attack_type).name
                            if snapshotOpp.IsAttackThrow():
                                frameDataEntry.hitType += "_THROW"
                            oldRecovery = snapshotOpp.recovery

                    try:
                        frameDataEntry.recovery = gameState.GetOppRecovery(
                        ) - frameDataEntry.startup - frameDataEntry.activeFrames + 1
                    except:
                        frameDataEntry.recovery = "?!"

                    time_till_recovery_opp = gameState.GetOppRecovery(
                    ) - gameState.GetOppMoveTimer()
                    time_till_recovery_bot = gameState.GetBotRecovery(
                    ) - gameState.GetBotMoveTimer()
                    new_frame_advantage_calc = time_till_recovery_bot - time_till_recovery_opp
                    old_frame_advantage_calc = None

                    if gameState.IsBotBlocking():
                        old_frame_advantage_calc = gameState.GetBotRecovery(
                        ) + frameDataEntry.startup - gameState.GetOppRecovery(
                        )
                        split_recovery_breakpoint = 3  #below this number are split recovery moves that don't need startup subtracted, like Steve's ff+2, above it are Lili's d/b+4 or Alisa's d+3+4
                        if oldRecovery > gameState.GetOppRecovery(
                        ) + split_recovery_breakpoint:  #ankle breaker moves and a few others have a split recovery
                            old_frame_advantage_calc -= frameDataEntry.startup
                        frameDataEntry.onBlock = new_frame_advantage_calc

                        frameDataEntry.currentFrameAdvantage = frameDataEntry.WithPlusIfNeeded(
                            frameDataEntry.onBlock)
                        frameDataEntry.blockFrames = frameDataEntry.recovery - frameDataEntry.startup

                    else:  # gameState.IsBotGettingHit() or :
                        old_frame_advantage_calc = gameState.GetFrameDataOfCurrentOppMove(
                        )
                        frameDataEntry.onNormalHit = new_frame_advantage_calc
                        frameDataEntry.currentFrameAdvantage = frameDataEntry.WithPlusIfNeeded(
                            frameDataEntry.onNormalHit)
                    #elif gameState.IsBotStartedBeingJuggled():
                    #frameDataEntry.onNormalHit = "JUGG"
                    #elif gameState.IsBotBeingKnockedDown():
                    #frameDataEntry.onNormalHit = "KDWN"
                    #elif gameState.IsBotJustGrounded():
                    #   frameDataEntry.onNormalHit = "GRND"
                    #elif gameState.IsBotBeingThrown():
                    #   pass

                    if self.isPlayerOne:
                        prefix = "p1: "
                    else:
                        prefix = 'p2: '

                    if old_frame_advantage_calc != new_frame_advantage_calc:
                        print(
                            "Frame advantage inconsistent calculation.  Old = "
                            + str(old_frame_advantage_calc) + " New: " +
                            str(new_frame_advantage_calc),
                            file=sys.stderr)

                    print(prefix + str(frameDataEntry))

        if self.isPlayerOne:
            gameState.FlipMirror()
Esempio n. 3
0
    def DetermineGameStats(self, gameState: TekkenGameState):
        frames_ago = 4
        if self.current_game_event == None:
            if gameState.DidOppComboCounterJustStartXFramesAgo(frames_ago):
                gameState.BackToTheFuture(frames_ago)

                combo_counter_damage = gameState.GetOppComboDamageXFramesAgo(1)

                was_unblockable = gameState.IsOppAttackUnblockable()
                was_antiair = gameState.IsOppAttackAntiair()
                was_block_punish = gameState.DidBotStartGettingPunishedXFramesAgo(1)
                perfect_punish = False
                if was_block_punish:
                    perfect_punish = gameState.BotFramesUntilRecoveryXFramesAgo(2) == 1
                was_counter_hit = gameState.IsBotGettingCounterHit()
                was_ground_hit = gameState.IsBotGettingHitOnGround()

                was_whiff_punish = gameState.GetBotStartupXFramesAgo(2) > 0

                was_low_hit = gameState.IsOppAttackLow()
                was_mid_hit_on_crouching = gameState.IsOppAttackMid() and gameState.IsBotCrouching()
                was_throw = gameState.IsBotBeingThrown()

                was_damaged_during_attack = gameState.DidOppTakeDamageDuringStartup()



                gameState.ReturnToPresent()

                if was_unblockable:
                    hit = GameStatEventEntry.EntryType.UNBLOCKABLE
                elif was_antiair:
                    hit = GameStatEventEntry.EntryType.ANTIAIR
                elif was_throw:
                    hit = GameStatEventEntry.EntryType.THROW
                elif was_damaged_during_attack:
                    hit = GameStatEventEntry.EntryType.POWER_CRUSHED
                elif was_block_punish:
                    hit = GameStatEventEntry.EntryType.PUNISH
                elif was_counter_hit:
                    hit = GameStatEventEntry.EntryType.COUNTER
                elif was_ground_hit:
                    hit = GameStatEventEntry.EntryType.GROUND
                elif was_whiff_punish:
                    hit = GameStatEventEntry.EntryType.WHIFF_PUNISH
                elif was_low_hit:
                    hit = GameStatEventEntry.EntryType.LOW
                elif was_mid_hit_on_crouching:
                    hit = GameStatEventEntry.EntryType.MID
                else:
                    hit = GameStatEventEntry.EntryType.NO_BLOCK
                self.current_game_event = GameStatEventEntry(gameState.stateLog[-1].timer_frames_remaining, self.GetPlayerString(True), hit, combo_counter_damage)

                #print("event open")
            else:
                bot_damage_taken = gameState.DidBotJustTakeDamage(frames_ago + 1)
                if bot_damage_taken > 0:
                    #print('armored')
                    game_event = GameStatEventEntry(gameState.stateLog[-1].timer_frames_remaining, self.GetPlayerString(True), GameStatEventEntry.EntryType.ARMORED, 0) #this is probably gonna break for Yoshimitsu's self damage moves
                    game_event.close_entry(gameState.stateLog[-1].timer_frames_remaining, 1, bot_damage_taken, 0, len(self.GameEvents))

                    self.GameEvents.append(game_event)



        else:
            if gameState.DidOppComboCounterJustEndXFramesAgo(frames_ago) or gameState.WasFightReset():
                hits = gameState.GetOppComboHitsXFramesAgo(frames_ago + 1)
                damage = gameState.GetOppComboDamageXFramesAgo(frames_ago + 1)
                juggle = gameState.GetOppJuggleDamageXFramesAgo(frames_ago + 1)
                self.current_game_event.close_entry(gameState.stateLog[-1].timer_frames_remaining, hits, damage, juggle, len(self.GameEvents))
                self.GameEvents.append(self.current_game_event)
                self.current_game_event = None
                #print("event closed")





        if gameState.WasFightReset():
            #print("p1: NOW:0")
            #print("p2: NOW:0")
            if self.isPlayerOne:
                if gameState.gameReader.flagToReacquireNames == False and self.was_fight_being_reacquired:
                    self.is_match_recorded = False

                    for entry in self.get_matchup_record(gameState):
                        print(entry)


                round_number = gameState.GetRoundNumber()
                print("!ROUND | {} | HIT".format(round_number))
                if (gameState.stateLog[-1].bot.wins == 3 or gameState.stateLog[-1].opp.wins == 3) and not self.is_match_recorded:
                    self.is_match_recorded = True

                    player_name = "You"
                    p1_char_name = gameState.stateLog[-1].opp.character_name
                    p1_wins = gameState.stateLog[-1].opp.wins

                    opponent_name = gameState.stateLog[-1].opponent_name
                    p2_char_name = gameState.stateLog[-1].bot.character_name
                    p2_wins = gameState.stateLog[-1].bot.wins

                    if gameState.stateLog[-1].is_player_player_one:
                        player_char, player_wins = p1_char_name, p1_wins
                        opponent_char, opponent_wins = p2_char_name, p2_wins
                    else:
                        player_char, player_wins = p2_char_name, p2_wins
                        opponent_char, opponent_wins = p1_char_name, p1_wins

                    if player_wins == opponent_wins:
                        result = 'DRAW'
                    elif player_wins > opponent_wins:
                        result = 'WIN'
                    else:
                        result = "LOSS"

                    match_result = '{} | {} | {} | vs | {} | {} | {}-{} | {}'.format(result, player_name, player_char, opponent_name, opponent_char, player_wins, opponent_wins, time.strftime('%Y_%m_%d_%H.%M'))
                    print("{}".format(match_result))
                    self.AddStat(result, player_char, opponent_name, opponent_char)
                    with open(self.stat_filename, "a", encoding='utf-8') as fa:
                        fa.write(match_result + '\n')
            if (gameState.GetTimer(frames_ago) < 3600 and len(self.GameEvents) > 0) or True:
                summary = RoundSummary(self.GameEvents, gameState.GetOppRoundSummary(frames_ago))

            self.GameEvents = []

        self.was_fight_being_reacquired = gameState.gameReader.flagToReacquireNames