def DetermineFrameData(self, gameState):
        if (
                gameState.IsBotBlocking() or gameState.IsBotGettingHit() or gameState.IsBotBeingThrown() or gameState.IsBotBeingKnockedDown() or gameState.IsBotBeingWallSplatted()):  # or gameState.IsBotUsingOppMovelist()): #or  gameState.IsBotStartedBeingJuggled() or gameState.IsBotJustGrounded()):
            # print(gameState.stateLog[-1].bot.move_id)
            # print(gameState.stateLog[-1].bot.move_timer)
            # print(gameState.stateLog[-1].bot.recovery)
            # print(gameState.DidBotIdChangeXMovesAgo(self.active_frame_wait))

            if gameState.DidBotIdChangeXMovesAgo(self.active_frame_wait) or gameState.DidBotTimerInterruptXMovesAgo(
                    self.active_frame_wait):  # or gameState.DidOppIdChangeXMovesAgo(self.active_frame_wait):

                is_recovering_before_long_active_frame_move_completes = (
                        gameState.GetBotRecovery() - gameState.GetBotMoveTimer() == 0)
                gameState.BackToTheFuture(self.active_frame_wait)

                # print(gameState.GetOppActiveFrames())
                if (
                        not self.active_frame_wait >= gameState.GetOppActiveFrames() + 1) and not is_recovering_before_long_active_frame_move_completes:
                    self.active_frame_wait += 1
                else:
                    gameState.ReturnToPresent()

                    currentActiveFrame = gameState.GetLastActiveFrameHitWasOn(self.active_frame_wait)

                    gameState.BackToTheFuture(self.active_frame_wait)

                    opp_id = gameState.GetOppMoveId()

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

                    frameDataEntry.currentActiveFrame = currentActiveFrame

                    frameDataEntry.currentFrameAdvantage = '??'
                    frameDataEntry.move_id = opp_id
                    # frameDataEntry.damage =
                    frameDataEntry.damage = gameState.GetOppDamage()
                    frameDataEntry.startup = gameState.GetOppStartup()

                    if frameDataEntry.damage == 0 and frameDataEntry.startup == 0:
                        frameDataEntry.startup, frameDataEntry.damage = gameState.GetOppLatestNonZeroStartupAndDamage()

                    frameDataEntry.activeFrames = gameState.GetOppActiveFrames()
                    frameDataEntry.hitType = AttackType(gameState.GetOppAttackType()).name
                    if gameState.IsOppAttackThrow():
                        frameDataEntry.hitType += "_THROW"

                    frameDataEntry.recovery = gameState.GetOppRecovery()

                    # frameDataEntry.input = frameDataEntry.InputTupleToInputString(gameState.GetOppLastMoveInput())

                    frameDataEntry.input = gameState.GetCurrentOppMoveString()

                    frameDataEntry.technical_state_reports = gameState.GetOppTechnicalStates(frameDataEntry.startup - 1)

                    frameDataEntry.tracking = gameState.GetOppTrackingType(frameDataEntry.startup)

                    # print(gameState.GetRangeOfMove())

                    gameState.ReturnToPresent()

                    # frameDataEntry.throwTech = gameState.GetBotThrowTech(frameDataEntry.activeFrames + frameDataEntry.startup)
                    frameDataEntry.throwTech = gameState.GetBotThrowTech(1)

                    time_till_recovery_opp = gameState.GetOppFramesTillNextMove()
                    time_till_recovery_bot = gameState.GetBotFramesTillNextMove()

                    new_frame_advantage_calc = time_till_recovery_bot - time_till_recovery_opp

                    frameDataEntry.currentFrameAdvantage = frameDataEntry.WithPlusIfNeeded(new_frame_advantage_calc)

                    if gameState.IsBotBlocking():
                        frameDataEntry.onBlock = new_frame_advantage_calc
                    else:
                        if gameState.IsBotGettingCounterHit():
                            frameDataEntry.onCounterHit = new_frame_advantage_calc
                        else:
                            frameDataEntry.onNormalHit = new_frame_advantage_calc

                    frameDataEntry.hitRecovery = time_till_recovery_opp
                    frameDataEntry.blockRecovery = time_till_recovery_bot

                    frameDataEntry.move_str = gameState.GetCurrentOppMoveName()
                    frameDataEntry.prefix = self.GetPlayerString()

                    print(str(frameDataEntry))

                    self.current_frame_data_entry = frameDataEntry

                    gameState.BackToTheFuture(self.active_frame_wait)

                    self.active_frame_wait = 1
                gameState.ReturnToPresent()
示例#2
0
    def determine_frame_data(self, game_state):
        if(
                game_state.is_bot_blocking()
                or game_state.is_bot_getting_hit()
                or game_state.is_bot_being_thrown()
                or game_state.is_bot_being_knocked_down()
                or game_state.is_bot_being_wall_splatted()
                # or game_state.is_bot_using_opp_movelist()
                # or game_state.is_bot_started_being_juggled()
                # or game_state.is_bot_just_grounded()
        ):
            # print(game_state.state_log[-1].bot.move_id)
            # print(game_state.state_log[-1].bot.move_timer)
            # print(game_state.state_log[-1].bot.recovery)
            # print(
            #   game_state.did_bot_id_change_x_moves_ago(
            #       self.active_frame_wait
            #   )
            # )

            if(
                    game_state.did_bot_id_change_x_moves_ago(
                        self.active_frame_wait
                    ) or game_state.did_bot_timer_interrupt_x_moves_ago(
                        self.active_frame_wait
                    )
                    # or game_state.did_opp_id_change_x_moves_ago(
                    #   self.active_frame_wait
                    # )
            ):
                is_recovering_before_long_active_frame_move_completes = (
                    game_state.get_bot_recovery()
                    - game_state.get_bot_move_timer() == 0
                )
                game_state.back_to_the_future(self.active_frame_wait)

                #print(game_state.get_opp_active_frames())
                if(
                        not self.active_frame_wait
                        >= game_state.get_opp_active_frames() + 1
                        and not
                        is_recovering_before_long_active_frame_move_completes
                ):
                    self.active_frame_wait += 1
                else:
                    game_state.return_to_present()
                    currentActiveFrame = (
                        game_state.get_last_active_frame_hit_was_on(
                            self.active_frame_wait
                        )
                    )
                    game_state.back_to_the_future(self.active_frame_wait)
                    opp_id = game_state.get_opp_move_id()

                    if opp_id in self.frame_data:
                        frame_data_entry = self.frame_data[opp_id]
                    else:
                        frame_data_entry = FrameDataEntry(
                            self.print_extended_frame_data
                        )
                        self.frame_data[opp_id] = frame_data_entry

                    frame_data_entry.currentActiveFrame = currentActiveFrame

                    frame_data_entry.currentFrameAdvantage = '??'
                    frame_data_entry.move_id = opp_id
                    # frame_data_entry.damage =
                    frame_data_entry.damage = game_state.get_opp_damage()
                    frame_data_entry.startup = game_state.get_opp_startup()

                    if(
                            frame_data_entry.damage == 0
                            and frame_data_entry.startup == 0
                    ):
                        frame_data_entry.startup, frame_data_entry.damage = (
                            game_state
                            .get_opp_latest_non_zero_startup_and_damage()
                        )

                    frame_data_entry.activeFrames = (
                        game_state.get_opp_active_frames()
                    )
                    frame_data_entry.hitType = AttackType(
                        game_state.get_opp_attack_type()
                    ).name
                    if game_state.is_opp_attack_throw():
                        frame_data_entry.hitType += "_THROW"

                    frame_data_entry.recovery = game_state.get_opp_recovery()

                    # frame_data_entry.input = (
                    #   frame_data_entry.InputTupleToInputString(
                    #       game_state.get_opp_last_move_input()
                    #   )
                    # )
                    frame_data_entry.input = (
                        game_state.get_current_opp_move_string()
                    )

                    frame_data_entry.technical_state_reports = (
                        game_state.get_opp_technical_states(
                            frame_data_entry.startup - 1
                        )
                    )
                    frame_data_entry.tracking = (
                        game_state.get_opp_tracking_type(
                            frame_data_entry.startup
                        )
                    )
                    # print(game_state.get_range_of_move())
                    game_state.return_to_present()

                    # frame_data_entry.throwTech = (
                    #   game_state.get_bot_throw_tech(
                    #       frame_data_entry.activeFrames
                    #       + frame_data_entry.startup
                    #   )
                    # )
                    frame_data_entry.throwTech = game_state.get_bot_throw_tech(
                        1
                    )

                    time_till_recovery_opp = (
                        game_state.get_opp_frames_till_next_move()
                    )
                    time_till_recovery_bot = (
                        game_state.get_bot_frames_till_next_move()
                    )
                    new_frame_advantage_calc = (
                        time_till_recovery_bot - time_till_recovery_opp
                    )
                    frame_data_entry.currentFrameAdvantage = (
                        frame_data_entry.WithPlusIfNeeded(
                            new_frame_advantage_calc
                        )
                    )

                    if game_state.is_bot_blocking():
                        frame_data_entry.onBlock = new_frame_advantage_calc
                    else:
                        if game_state.is_bot_getting_counter_hit():
                            frame_data_entry.onCounterHit = (
                                new_frame_advantage_calc
                            )
                        else:
                            frame_data_entry.onNormalHit = (
                                new_frame_advantage_calc
                            )

                    frame_data_entry.hitRecovery = time_till_recovery_opp
                    frame_data_entry.blockRecovery = time_till_recovery_bot

                    frame_data_entry.move_str = (
                        game_state.get_current_opp_move_name()
                    )
                    frame_data_entry.prefix = self.get_player_string(game_state)

                    sys.stdout.write(frame_data_entry)

                    self.current_frame_data_entry = frame_data_entry

                    game_state.back_to_the_future(self.active_frame_wait)

                    self.active_frame_wait = 1
                game_state.return_to_present()
示例#3
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()
    def DetermineFrameData(self, gameState):
        opp_id = gameState.GetOppMoveId()
        if self.second_opinion:
            self.second_opinion_timer += 1
            landingCanceledFrames = gameState.GetOppMoveInterruptedFrames()
            if landingCanceledFrames > 0:
                bot_recovery = (gameState.GetBotRecovery() -
                                gameState.GetBotMoveTimer())
                opp_recovery = (gameState.GetOppRecovery() -
                                gameState.GetOppMoveTimer())
                # fa = (self.stored_bot_recovery - self.second_opinion_timer) - opp_recovery
                if self.second_opinion_timer < self.stored_bot_recovery:
                    fa = bot_recovery - opp_recovery
                else:
                    fa = (self.stored_bot_recovery -
                          self.second_opinion_timer) - opp_recovery
                fa_string = self.FrameData[
                    self.stored_opp_id].WithPlusIfNeeded(fa)

                print(self.stored_prefix + "JUMP CANCELED -> " + fa_string +
                      " NOW:" + fa_string)

                self.second_opinion = False
                self.second_opinion_timer = 0

            if self.second_opinion_timer > self.stored_opp_recovery:
                # print("check {}".format(self.stored_opp_recovery))
                # print(gameState.stateLog[-1].opp.IsBufferable())
                # print(gameState.GetOppTechnicalStates(self.stored_opp_recovery)[2])
                # print(gameState.GetOppTechnicalStates(self.stored_opp_recovery)[3])
                self.second_opinion = False
                self.second_opinion_timer = 0
        #if gameState.IsOppWhiffingXFramesAgo(self.active_frame_wait + 1)) and \
        if (
                gameState.IsBotBlocking() or gameState.IsBotGettingHit()
                or gameState.IsBotBeingThrown()
                or gameState.IsBotBeingKnockedDown()
        ):  #or  gameState.IsBotStartedBeingJuggled() or gameState.IsBotJustGrounded()):
            # print(gameState.stateLog[-1].bot.move_id)
            #print(gameState.stateLog[-1].bot.move_timer)
            #print(gameState.stateLog[-1].bot.recovery)
            #print(gameState.DidBotIdChangeXMovesAgo(self.active_frame_wait))

            if gameState.DidBotIdChangeXMovesAgo(
                    self.active_frame_wait
            ) or gameState.DidBotTimerInterruptXMovesAgo(
                    self.active_frame_wait
            ):  # or gameState.DidOppIdChangeXMovesAgo(self.active_frame_wait):

                is_recovering_before_long_active_frame_move_completes = (
                    gameState.GetBotRecovery() -
                    gameState.GetBotMoveTimer() == 0)
                gameState.BackToTheFuture(self.active_frame_wait)

                #print(gameState.GetOppActiveFrames())
                if (
                        not self.active_frame_wait >=
                        gameState.GetOppActiveFrames() + 1
                ) and not is_recovering_before_long_active_frame_move_completes:
                    self.active_frame_wait += 1
                else:
                    gameState.ReturnToPresent()

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

                    frameDataEntry.currentActiveFrame = gameState.GetLastActiveFrameHitWasOn(
                        self.active_frame_wait)

                    gameState.BackToTheFuture(self.active_frame_wait)

                    frameDataEntry.currentFrameAdvantage = '??'
                    frameDataEntry.move_id = opp_id
                    # frameDataEntry.damage =
                    frameDataEntry.damage = gameState.GetOppDamage()
                    frameDataEntry.startup = gameState.GetOppStartup()

                    if frameDataEntry.damage == 0 and frameDataEntry.startup == 0:
                        frameDataEntry.startup, frameDataEntry.damage = gameState.GetOppLatestNonZeroStartupAndDamage(
                        )

                    frameDataEntry.activeFrames = gameState.GetOppActiveFrames(
                    )
                    frameDataEntry.hitType = AttackType(
                        gameState.GetOppAttackType()).name
                    if gameState.IsOppAttackThrow():
                        frameDataEntry.hitType += "_THROW"

                    #fastestRageMoveFrames = 120
                    #longestRageMoveFrames = 150
                    #if frameDataEntry.startup > fastestRageMoveFrames:  # and gameState.DidOpponentUseRageRecently(longestRageMoveFrames):
                    #frameDataEntry.startup = gameState.GetBotElapsedFramesOfRageMove(frameDataEntry.startup)

                    frameDataEntry.recovery = gameState.GetOppRecovery()

                    frameDataEntry.input = frameDataEntry.InputTupleToInputString(
                        gameState.GetOppLastMoveInput())

                    frameDataEntry.technical_state_reports = gameState.GetOppTechnicalStates(
                        frameDataEntry.startup - 1)

                    frameDataEntry.tracking = gameState.GetOppTrackingType(
                        frameDataEntry.startup)

                    #print(gameState.GetRangeOfMove())

                    gameState.ReturnToPresent()

                    #frameDataEntry.throwTech = gameState.GetBotThrowTech(frameDataEntry.activeFrames + frameDataEntry.startup)
                    frameDataEntry.throwTech = gameState.GetBotThrowTech(1)

                    time_till_recovery_opp = gameState.GetOppFramesTillNextMove(
                    )
                    time_till_recovery_bot = gameState.GetBotFramesTillNextMove(
                    )

                    new_frame_advantage_calc = time_till_recovery_bot - time_till_recovery_opp

                    frameDataEntry.currentFrameAdvantage = frameDataEntry.WithPlusIfNeeded(
                        new_frame_advantage_calc)

                    if gameState.IsBotBlocking():
                        frameDataEntry.onBlock = new_frame_advantage_calc
                    else:
                        if gameState.IsBotGettingCounterHit():
                            frameDataEntry.onCounterHit = new_frame_advantage_calc
                        else:
                            frameDataEntry.onNormalHit = new_frame_advantage_calc

                    frameDataEntry.hitRecovery = time_till_recovery_opp
                    frameDataEntry.blockRecovery = time_till_recovery_bot

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

                    print(prefix + str(frameDataEntry))

                    # print(gameState.stateLog[-1].opp.startup)
                    # print(time_till_recovery_bot)

                    self.second_opinion = True
                    self.stored_bot_recovery = time_till_recovery_bot
                    self.stored_opp_recovery = time_till_recovery_opp
                    self.stored_prefix = prefix
                    self.stored_opp_id = opp_id
                    self.second_opinion_timer = 0

                    gameState.BackToTheFuture(self.active_frame_wait)

                    self.active_frame_wait = 1
                gameState.ReturnToPresent()