Esempio n. 1
0
    def Update(self, gameState: TekkenGameState):
        BotBehaviors.Basic(gameState, self.botCommands)

        if self.botCommands.IsAvailable():
            BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
            if gameState.IsBotBlocking() or gameState.IsBotGettingHit():
                self.botCommands.AddCommand(self.response)
Esempio n. 2
0
    def Update(self, gameState: TekkenGameState):
        self.p1_name = gameState.GetBotName()
        self.p2_name = gameState.GetOppName()

        bot_input = gameState.GetBotInputState()
        opp_input = gameState.GetOppInputState()
        #self.input_log.append(bot_input[0].name + "," + bot_input[1].name + "|" + opp_input[0].name + "," + opp_input[1].name)
        self.input_log.append((bot_input, opp_input))
Esempio n. 3
0
 def BlockAllAttacks(gameState: TekkenGameState, botCommands: BotCommands):
     if gameState.IsOppAttacking():
         if gameState.IsOppAttackLow():
             botCommands.BlockLowFull(
                 max(0, gameState.GetOppTimeUntilImpact()))
         else:
             botCommands.BlockMidFull(
                 max(0, gameState.GetOppTimeUntilImpact()))
Esempio n. 4
0
    def __init__(self):
        self.toplevel = Tk()
        self.recorder = MatchRecorder()
        self.game_state = TekkenGameState()

        self.playback_going = False
        self.is_recording = False  #set this to true to record some matches
        self.is_playback_mode = True
Esempio n. 5
0
    def Update(self, gameState: TekkenGameState):
        super().Update(gameState)

        #self.cyclopedia_p1.Update(gameState)
        #self.cyclopedia_p2.Update(gameState)
        
        currentPlayerMoveName = gameState.GetCurrentOppMoveName()
        if(currentPlayerMoveName != self.LastPlayerMoveName):
            self.LastPlayerMoveName = currentPlayerMoveName
            #print(self.LastPlayerMoveName)
        
        ###Testing
        #test = self.OppMovelist.getMoveById(5)
        #print(self.OppMovelist.DidMoveJustHappen(self.BotMoveHistory, test))
        
        
        ###End Testing
        
        if self.botCommands.IsAvailable() and gameState.IsForegroundPID():
            
            if gameState.stateLog[-1].bot.hit_outcome in self.HitList():
                if self.lastMove:
                    print("Punished")
                #get player character's correct punishes
                #if player used correct punish count as punished
                self.lastMove = None
            
            BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
            #Check to see if the bot is standing
            if gameState.stateLog[-1].bot.simple_state != (SimpleMoveStates.STANDING):
                self.FrameLastAction = self.frameCounter
            else:
                if  self.distance > 1500:
                    self.botCommands.AddCommand(self.botCommands.ForwarddashSmall())
                elif self.DetermineIfAction():
                    if len(self.queue) == 0:
                        
                        self.lastMove = self.Movelist.getNextGameplanMove()
                        if(self.overlay != None):
                            self.overlay.WriteToOverlay(self.Movelist.getMoveName(self.lastMove) + "\t" + self.Movelist.getMoveOnBlock(self.lastMove))
                            self.FrameLastAction = self.frameCounter

                        self.queue.append(self.lastMove)
                        self.queue.append(self.lastMove)
                        self.queue.append(self.lastMove)
                    else:
                        self.lastMove = self.queue.pop(0)
                        command = self.Movelist.getMoveCommand(self.lastMove)
                        print("Move: " + self.Movelist.getMoveName(self.lastMove) + "\nID: " + self.Movelist.getMoveId(self.lastMove) + "\n") 
                        if command is not None:
                            self.botCommands.AddCommand(ParseMoveList(command))
                            self.CountOfAttempts = self.CountOfAttempts + 1
    def Update(self, gameState: TekkenGameState):
        if self.isPlayerOne:
            gameState.FlipMirror()

        # self.CheckJumpFrameDataFallback(gameState)

        self.DetermineFrameData(gameState)

        self.DetermineGameStats(gameState)

        self.DetermineCoachingTips(gameState)

        if self.isPlayerOne:
            gameState.FlipMirror()
Esempio n. 7
0
    def DetermineCoachingTips(self, gameState: TekkenGameState):

        if self.previous_frame_data_entry != self.current_frame_data_entry:
            self.previous_frame_data_entry = self.current_frame_data_entry

            if self.current_punish_window != None:
                self.ClosePunishWindow(PunishWindow.Result.NO_WINDOW, do_close_frame_data_entries=False)

            # if int(self.current_frame_data_entry.currentFrameAdvantage) <= 999999:
            self.current_punish_window = PunishWindow(self.current_frame_data_entry.prefix,
                                                      self.current_frame_data_entry.move_id,
                                                      self.current_frame_data_entry.input,
                                                      int(self.current_frame_data_entry.hitRecovery),
                                                      int(self.current_frame_data_entry.blockRecovery),
                                                      int(self.current_frame_data_entry.activeFrames))
            self.PunishWindows.append(self.current_punish_window)
            self.punish_window_counter = 0



        if self.current_punish_window != None:
            self.punish_window_counter += 1
            #if self.punish_window_counter > self.current_punish_window.size:

            was_block_punish = gameState.DidOppStartGettingPunishedXFramesAgo(1) or gameState.DidOppStartGettingHitXFramesAgo(1)

            if was_block_punish:
                leeway = (gameState.OppFramesUntilRecoveryXFramesAgo(2) - 1)
                LAUNCH_PUNISHIBLE = 15
                BAD_PUNISH_THRESHOLD = 13
                #if leeway == 0:
                    #self.ClosePunishWindow(PunishWindow.Result.PERFECT_PUNISH)
                #else:
                fa = (-1 * self.current_punish_window.get_frame_advantage())
                startup = fa - leeway
                if fa >= LAUNCH_PUNISHIBLE and startup <= BAD_PUNISH_THRESHOLD:
                    self.ClosePunishWindow(PunishWindow.Result.NO_LAUNCH_ON_LAUNCHABLE)
                elif fa >= LAUNCH_PUNISHIBLE:
                    self.ClosePunishWindow(PunishWindow.Result.LAUNCH_ON_LAUNCHABLE)
                else:
                    self.ClosePunishWindow(PunishWindow.Result.JAB_ON_NOT_LAUNCHABLE)

            elif gameState.HasOppReturnedToNeutralFromMoveId(self.current_punish_window.move_id) and self.punish_window_counter >= self.current_punish_window.hit_recovery:
                if self.current_punish_window.get_frame_advantage() <= -10:
                    self.ClosePunishWindow(PunishWindow.Result.NO_PUNISH)
                else:
                    self.ClosePunishWindow(PunishWindow.Result.NO_WINDOW)
            if self.current_punish_window != None:
                self.current_punish_window.adjust_window(gameState.GetOppFramesTillNextMove(), gameState.GetBotFramesTillNextMove())
Esempio n. 8
0
    def Update(self, gameState: TekkenGameState):
        super().Update(gameState)
        
        if self.botCommands.IsAvailable() and gameState.IsForegroundPID():
#            BotMove = gameState.GetCurrentBotMoveName()
#            if BotMove != self.LastBotMoveName:
#                self.LastBotMoveName = BotMove
#                print("Bot Move:" + BotMove)
            
            #if gameState.DidBotStartGettingPunishedXFramesAgo(30):
            #print(gameState.stateLog[-1].bot.hit_outcome)
            #if gameState.GetFramesSinceBotTookDamage() < 15:
            
            if gameState.stateLog[-1].bot.hit_outcome in self.HitList():
                if self.lastMove:
                    print("Punished")
#                    self.NumCorrectPunished = self.NumCorrectPunished + 1
#                    self.Movelist.removeMoveFromGameplan(self.lastMove)
                self.lastMove = None
#                if not self.Movelist.gameplan:
#                    self.exit = True
#                    print("Percentage of punishes: " + str((float(self.NumCorrectPunished) / float(self.CountOfAttempts)) * 100) + "%")
#                    print("Total Punished: " + str(self.NumCorrectPunished))
#                    print("Total Attempts: " + str(self.CountOfAttempts))
            
            BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
            #Check to see if the bot is standing
            if gameState.stateLog[-1].bot.simple_state != (SimpleMoveStates.STANDING):
                self.FrameLastAction = self.frameCounter
                #print(gameState.stateLog[-1].bot.simple_state)
            else:
                if  self.distance > 1500:
                    self.botCommands.AddCommand(self.botCommands.ForwarddashSmall())
                elif self.DetermineIfAction():
                    #print(self.distance)
                    #self.botCommands.AddCommand(random.choice(self.punishableMoves))
                    #print(random.choice(self.punishableMoves))
                    if len(self.queue) == 0:
                        
                        self.lastMove = self.Movelist.getNextGameplanMove()
                        if(self.overlay != None):
                            self.overlay.WriteToOverlay(self.Movelist.getMoveName(self.lastMove) + "\t" + self.Movelist.getMoveOnBlock(self.lastMove))
                            self.FrameLastAction = self.frameCounter

                        self.queue.append(self.lastMove)
                        self.queue.append(self.lastMove)
                        self.queue.append(self.lastMove)
                    else:
                        self.lastMove = self.queue.pop(0)
                        #move = self.Movelist[-1]
                        #command = move.getMoveCommand
                        command = self.Movelist.getMoveCommand(self.lastMove)
                        print("Move: " + self.Movelist.getMoveName(self.lastMove) + "\nID: " + self.Movelist.getMoveId(self.lastMove) + "\n") 
                        #print(ParseMoveList(command))
                        if command is not None:
                            self.botCommands.AddCommand(ParseMoveList(command))
                            self.CountOfAttempts = self.CountOfAttempts + 1
Esempio n. 9
0
    def Update(self, gameState: TekkenGameState):
        #self.UpdateInputDelay(gameState)

        if self.updateFrame > 120 and not self.is_playback_mode:
            self.ClearCommands()

        if gameState.DidBotJustTakeDamage() and not self.is_playback_mode:
            self.ClearCommands()

        self.UpdateCommandBuffer(gameState)
Esempio n. 10
0
 def UpdateInputDelay(self, gameState: TekkenGameState):
     if self.inputDelayCode != None:
         #if any((True for x in self.inputDelayCode if x in botInputState)):
         if gameState.DidBotIdChangeXMovesAgo(1):
             print(self.inputDelay)
             self.inputDelayCode = None
             self.inputDelay = 0
         else:
             self.inputDelay += 1
             if self.inputDelay > 40:
                 self.inputDelayCode = None
                 self.inputDelay = 0
Esempio n. 11
0
class FrameDataLauncher:
    def __init__(self):
        self.gameState = TekkenGameState()
        self.cyclopedia_p2 = TekkenEncyclopedia(False)
        self.cyclopedia_p1 = TekkenEncyclopedia(True)


    def Update(self):
        successfulUpdate = self.gameState.Update()
        if successfulUpdate:
            self.cyclopedia_p1.Update(self.gameState)
            self.cyclopedia_p2.Update(self.gameState)
Esempio n. 12
0
    def Update(self, gameState: TekkenGameState):
        successfulUpdate = super().Update(gameState)
        if(self.recording):
            self.recorder.update_state()
        
        if(self.playback and self.botCommands.IsAvailable() and gameState.IsForegroundPID()):
#            if  self.distance > 1500:
#                self.botCommands.AddCommand(self.botCommands.ForwarddashSmall())
#            else:
            self.botCommands.AddCommand(ParseMoveList(self.testCommand))
            self.testCommand = ""
            self.playback = False
Esempio n. 13
0
class FrameDataLauncher:
    def __init__(self, print_extended_frame_data=False):
        self.gameState = TekkenGameState()
        self.cyclopedia_p2 = TekkenEncyclopedia(False,
                                                print_extended_frame_data)
        self.cyclopedia_p1 = TekkenEncyclopedia(True,
                                                print_extended_frame_data)

    def Update(self):
        successfulUpdate = self.gameState.Update()
        if successfulUpdate:
            self.cyclopedia_p1.Update(self.gameState)
            self.cyclopedia_p2.Update(self.gameState)
Esempio n. 14
0
    def Update(self, gameState: TekkenGameState):
        successfulUpdate = gameState.Update()
        if gameState.IsGameHappening():
			#debugging
#            if(self.botSimpleState != gameState.stateLog[-1].bot.simple_state.name):
#                self.botSimpleState = gameState.stateLog[-1].bot.simple_state.name
            #print("Bot Simple State: " + gameState.stateLog[-1].bot.simple_state.name)
            self.overlay.WriteToOverlay("Bot Simple State: " + gameState.stateLog[-1].bot.simple_state.name)
        
        BotBehaviors.Basic(gameState, self.botCommands)

        if gameState.WasFightReset():
            self.botCommands.ClearCommands()
            self.gameplan = None

        if self.gameplan == None :
            char_id = gameState.GetBotCharId()
            if char_id != None:
                self.gameplan = GetGameplan(char_id)
        
        if self.botCommands.IsAvailable():            
            BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
Esempio n. 15
0
    def Update(self, gameState: TekkenGameState):

        self.enemyCyclopedia.Update(gameState)

        if gameState.WasFightReset():
            self.botCommands.ClearCommands()
            self.gameplan = None

        if self.gameplan == None:
            char_id = gameState.GetBotCharId()
            if char_id != None:
                self.gameplan = GetGameplan(char_id)

        if self.gameplan != None:
            BotBehaviors.Basic(gameState, self.botCommands)
            if self.botCommands.IsAvailable():
                BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
                frameAdvantage = None
                if gameState.IsBotBlocking():
                    frameAdvantage = self.enemyCyclopedia.GetFrameAdvantage(
                        gameState.GetOppMoveId())
                elif gameState.IsBotGettingHit():
                    frameAdvantage = self.enemyCyclopedia.GetFrameAdvantage(
                        gameState.GetOppMoveId(), isOnBlock=False)

                try:
                    frameAdvantage = int(frameAdvantage) * -1
                except:
                    frameAdvantage = None

                if frameAdvantage != None:
                    if frameAdvantage >= 10:
                        if gameState.IsBotWhileStanding():
                            punish = self.gameplan.GetMoveByFrame(
                                ResponseTypes.ws_punishes, frameAdvantage)
                        else:
                            punish = self.gameplan.GetMoveByFrame(
                                ResponseTypes.st_punishes, frameAdvantage)
                        if punish != None:
                            self.botCommands.AddCommand(punish)
Esempio n. 16
0
    def Update(self, gameState: TekkenGameState):
        successfulUpdate = gameState.Update()

        #if successfulUpdate:
        #    self.cyclopedia_p1.Update(self.gameState)
        #    self.cyclopedia_p2.Update(self.gameState)

        #print(gameState.GetCurrentBotMoveName())
        #debugging

        if not self.recorder == None:
            self.recorder.Update(gameState)

        BotBehaviors.Basic(gameState, self.botCommands)
        if self.gameplan == None:
            char_id = gameState.GetBotCharId()
            print("Testing Char ID: " + str(char_id))
            if char_id != None:
                self.gameplan = GetGameplan(char_id)
                self.Movelist = MoveList(char_id)
                self.useMoves = self.Movelist.allMoves
                self.Movelist.getGameplan(1)

        if gameState.WasFightReset():
            self.botCommands.ClearCommands()
            self.gameplan = None

        if gameState.IsGameHappening():
            self.frameCounter += 1
            self.distance = gameState.GetDist()
            self.BotMove = gameState.GetCurrentBotMoveName()
            Stance = self.Movelist.GetStanceFromGameMove(self.BotMove)
            if (Stance != None):
                self.Stance = Stance

#        if self.botCommands.IsAvailable():

        return successfulUpdate
Esempio n. 17
0
    def Update(self, gameState: TekkenGameState):
        BotBehaviors.Basic(gameState, self.botCommands)
        if self.gameplan == None:
            char_id = gameState.GetBotCharId()
            print("Testing Char ID: " + str(char_id))
            if char_id != None:
                self.gameplan = GetGameplan(char_id)
                self.Movelist = MoveList(char_id)
                self.useMoves = self.Movelist.allMoves
                self.Movelist.getGameplan(1)
                self.OppMovelist = MoveList(gameState.stateLog[-1].opp.char_id)

        if gameState.WasFightReset():
            self.botCommands.ClearCommands()

        if gameState.IsGameHappening():
            self.frameCounter += 1
            self.distance = gameState.GetDist()
            self.BotMove = gameState.GetCurrentBotMoveName()
            self.AppendBotMove(gameState.GetCurrentOppMoveName())
            Stance = self.Movelist.GetStanceFromGameMove(self.BotMove)
            if (Stance != None):
                self.Stance = Stance
Esempio n. 18
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. 19
0
 def Update(self, gameState: TekkenGameState):
     self.recorder.Update(gameState)
     if gameState.WasFightReset():
         self.recorder.PrintInputLog("test.txt")
         self.recorder = MatchRecorder()
Esempio n. 20
0
 def __init__(self, print_extended_frame_data=False):
     self.gameState = TekkenGameState()
     self.cyclopedia_p2 = TekkenEncyclopedia(False,
                                             print_extended_frame_data)
     self.cyclopedia_p1 = TekkenEncyclopedia(True,
                                             print_extended_frame_data)
Esempio n. 21
0
 def __init__(self):
     self.gameState = TekkenGameState()
     self.cyclopedia_p2 = TekkenEncyclopedia(False)
     self.cyclopedia_p1 = TekkenEncyclopedia(True)
Esempio n. 22
0
class BotRecorder():
    def __init__(self):
        self.toplevel = Tk()
        self.recorder = MatchRecorder()
        self.game_state = TekkenGameState()

        self.playback_going = False
        self.is_recording = False  #set this to true to record some matches
        self.is_playback_mode = True

    def update_launcher(self):

        time1 = time.time()

        buffer = 4

        successful = self.game_state.Update(buffer)
        if successful and self.game_state.IsGameHappening():

            if self.game_state.WasTimerReset():
                print("timer reset")
                if self.is_recording:
                    self.recorder.PrintInputLog()
                self.playback_going = False

            if self.game_state.DidTimerStartTicking(buffer + 60):
                self.playback("2017_Jul_20_22.15.36S_ALISAvKING")
                print("ticking begins")
                if self.is_recording:
                    self.recorder = MatchRecorder()
                self.playback_going = True

            if len(self.game_state.stateLog) > 2:
                self.recorder.Update(self.game_state)

            if self.playback_going and self.is_playback_mode:
                self.p1_controller.Update(self.game_state.IsForegroundPID(),
                                          self.game_state.IsBotOnLeft())
                self.p2_controller.Update(self.game_state.IsForegroundPID(),
                                          not self.game_state.IsBotOnLeft())

                self.p1_bot.Update(self.game_state)
                self.p2_bot.Update(self.game_state)

        time2 = time.time()
        elapsed_time = 1000 * (time2 - time1)
        self.toplevel.after(max(2, 8 - int(round(elapsed_time))),
                            self.update_launcher)

    def playback(self, filename):
        p1_controller = GameControllerInputter(False)
        p2_controller = GameControllerInputter(True)

        p1_bot = BotCommands(p1_controller, True)
        p2_bot = BotCommands(p2_controller, True)

        with open("TekkenData/Replays/" + filename) as fr:
            p1_commands = fr.readline().strip()
            p2_commands = fr.readline().strip()

        p1_bot.AddCommand([(Command.ReleaseAll, 0), (Command.Wait, 1)] +
                          ParseMoveList(p1_commands) +
                          [(Command.ReleaseAll, 1)])
        p2_bot.AddCommand([(Command.ReleaseAll, 0), (Command.Wait, 1)] +
                          ParseMoveList(p2_commands) +
                          [(Command.ReleaseAll, 1)])

        self.p1_controller = p1_controller
        self.p2_controller = p2_controller

        self.p1_bot = p1_bot
        self.p2_bot = p2_bot
Esempio n. 23
0
from MatchRecorder import MatchRecorder
from TekkenGameState import TekkenGameState
from TekkenGameState import TekkenGameReader
from time import sleep
m = MatchRecorder()
g = TekkenGameState()
g.Update()
sleep(5)
#gr = TekkenGameReader()

#gr.GetUpdatedState()
#gr.WriteMovelistsToFile(gr.p1_movelist, 'test')

for i in range(100):
    g.Update()
    m.Update(g)
    sleep(0.05)

m.PrintInputLog()
Esempio n. 24
0
    def ProcessCommand(self, command, gameState: TekkenGameState):
        self.CheckForInputDelay(command)

        if command == Command.TapForward:
            self.inputController.TapForward()
        if command == Command.TapBack:
            self.inputController.TapBack()
        if command == Command.TapUp:
            self.inputController.TapUp()
        if command == Command.TapDown:
            self.inputController.TapDown()
        if command == Command.TapRight:
            self.inputController.TapRight()
        if command == Command.TapLeft:
            self.inputController.TapLeft()
        if command == Command.Tap1:
            self.inputController.Tap1()
        if command == Command.Tap2:
            self.inputController.Tap2()
        if command == Command.Tap3:
            self.inputController.Tap3()
        if command == Command.Tap4:
            self.inputController.Tap4()

        if command == Command.Accept:
            self.inputController.TapAccept()
        if command == Command.ResetPractice:
            self.inputController.TapAccept()
            self.inputController.TapSelect()

        if command == Command.HoldBack:
            self.inputController.HoldBack()
        if command == Command.ReleaseBack:
            self.inputController.TapBack()
        if command == Command.HoldForward:
            self.inputController.HoldForward()
        if command == Command.ReleaseForward:
            self.inputController.ReleaseForward()
        if command == Command.HoldDown:
            self.inputController.HoldDown()
        if command == Command.ReleaseDown:
            self.inputController.ReleaseDown()
        if command == Command.HoldUp:
            self.inputController.HoldUp()
        if command == Command.ReleaseUp:
            self.inputController.ReleaseUp()

        if command == Command.Hold1:
            self.inputController.Hold1()
        if command == Command.Hold2:
            self.inputController.Hold2()
        if command == Command.Hold3:
            self.inputController.Hold3()
        if command == Command.Hold4:
            self.inputController.Hold4()

        if command == Command.Release1:
            self.inputController.Release1()
        if command == Command.Release2:
            self.inputController.Release2()
        if command == Command.Release3:
            self.inputController.Release3()
        if command == Command.Release4:
            self.inputController.Release4()

        if command == Command.HoldRage:
            self.inputController.HoldRage()
        if command == Command.ReleaseRage:
            self.inputController.ReleaseRage()

        if command == Command.HoldDownBack:
            self.inputController.HoldBack()
            self.inputController.HoldDown()
        if command == Command.ReleaseDownBack:
            self.inputController.ReleaseBack()
            self.inputController.ReleaseDown()

        if command == Command.ReleaseAll:
            self.inputController.Release()

        if command == Command.PunishConfirm:
            if gameState.DidBotRecentlyDoMove():
                pass
            else:
                self.commandIndex = 0

        if command == Command.HitConfirm:
            if gameState.DidBotRecentlyDoDamage:
                pass
            else:
                self.ClearCommands()

        if command == Command.Nextmove:
            if gameState.IsBotMoveChanged() or gameState.IsBotAttackStarting():
                #print(gameState.GetBotJustMoveID())
                #print(gameState.stateLog[-1].bot.move_id)
                pass
            else:
                self.commandIndex -= 1
                self.commandBuffer[self.commandIndex] = (Command.Nextmove, 1)

        if command == Command.Startupmove:
            self.commandIndex -= 1
            #print(gameState.GetBotTimeUntilImpact())
            self.commandBuffer[self.commandIndex] = (
                Command.Wait, gameState.GetBotTimeUntilImpact() * -1)

        if command == Command.Recovery:
            self.commandIndex -= 1
            inputDelay = 0
            self.commandBuffer[self.commandIndex] = (
                Command.Wait,
                max(0,
                    gameState.GetBotFramesUntilRecoveryEnds() - 6 -
                    inputDelay))

        if command == Command.FullRecovery:

            if gameState.GetBotRecovery() - gameState.GetBotMoveTimer() < 6:
                pass
            else:
                self.commandIndex -= 1
                self.commandBuffer[self.commandIndex] = (Command.FullRecovery,
                                                         1)
Esempio n. 25
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. 26
0
 def UnblockIncomingAttacks(self, gameState: TekkenGameState):
     if gameState.IsOppAttacking():
         self.botCommands.WalkForward(
             max(0, gameState.GetOppTimeUntilImpact()))
Esempio n. 27
0
    def Update(self, gameState: TekkenGameState):
        successfulUpdate = gameState.Update()
        if gameState.IsGameHappening():
            self.frameCounter += 1
            self.distance = gameState.GetDist()

        if not self.recorder == None:
            self.recorder.Update(gameState)

        BotBehaviors.Basic(gameState, self.botCommands)

        if gameState.WasFightReset():
            self.botCommands.ClearCommands()
            self.gameplan = None

        if self.gameplan == None:
            char_id = gameState.GetBotCharId()
            if char_id != None:
                self.gameplan = GetGameplan(char_id)
                #self.punishableMoves = self.gameplan.GetPunishableMoves()
                #self.allMoves = getMoves(char_id)
                #self.useMoves = getPunishableMoves(self.allMoves)
                self.allMoves = MoveList(char_id)
                self.useMoves = self.allMoves.allMoves
                self.allMoves.getGameplan(1)
                self.allMoves.shuffleGameplan()

        if self.botCommands.IsAvailable():
            #if gameState.DidBotStartGettingPunishedXFramesAgo(30):
            #gameState.IsOppAbleToAct()
            if gameState.stateLog[-1].bot.IsPunish(
            ) or gameState.stateLog[-1].bot.IsBeingJuggled():
                #if gameState.GetFramesSinceBotTookDamage() < 30:
                if self.lastMove:
                    print("Punished")
                    self.NumCorrectPunished = self.NumCorrectPunished + 1
                    self.allMoves.removeMoveFromGameplan(self.lastMove)
                self.lastMove = None
                if not self.allMoves.gameplan:
                    self.exit = True
                    print("Percentage of punishes: " +
                          str((float(self.NumCorrectPunished) /
                               float(self.CountOfAttempts)) * 100) + "%")
                    print("Total Punished: " + str(self.NumCorrectPunished))
                    print("Total Attempts: " + str(self.CountOfAttempts))

            BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
            #Check to see if the bot is standing
            if gameState.stateLog[-1].bot.simple_state != (
                    SimpleMoveStates.STANDING):
                self.FrameLastAction = self.frameCounter
                #print(gameState.stateLog[-1].bot.simple_state)
            else:
                if self.distance > 1500:
                    self.botCommands.AddCommand(
                        self.botCommands.ForwarddashSmall())
                elif self.DetermineIfAction():
                    #print(self.distance)
                    #self.botCommands.AddCommand(random.choice(self.punishableMoves))
                    #print(random.choice(self.punishableMoves))
                    if len(self.queue) == 0:
                        self.lastMove = self.allMoves.getNextGameplanMove()
                        #move = self.allMoves.getMoveById(18)
                        #self.queue.append(move)
                        #self.queue.append(move)
                    else:
                        self.lastMove = self.queue.pop(0)
                    #move = self.allMoves[-1]
                    #command = move.getMoveCommand
                    command = self.allMoves.getMoveCommand(self.lastMove, 0)
                    print("Move: " + self.allMoves.getMoveName(self.lastMove) +
                          "\nID: " + self.allMoves.getMoveId(self.lastMove) +
                          "\n")
                    #print(ParseMoveList(command))
                    if command is not None:
                        self.botCommands.AddCommand(ParseMoveList(command))
                        self.CountOfAttempts = self.CountOfAttempts + 1
Esempio n. 28
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
Esempio n. 29
0
    def Update(self, gameState: TekkenGameState):
        if self.isPlayerOne:
            gameState.FlipMirror()
            #gameState.stateLog[-1].opp.PrintYInfo()
            #print(gameState.GetOppTechnicalStates())
            #print(gameState.stateLog[-1].opp.simple_state)
            #print(gameState.stateLog[-1].opp.complex_state)
            #print(gameState.stateLog[-1].bot.move_timer)
            #print(gameState.stateLog[-1].bot.recovery)

            if len(gameState.stateLog) > 2:
                if gameState.stateLog[
                        -1].opp.complex_state != gameState.stateLog[
                            -2].opp.complex_state:
                    pass
                    #print(gameState.stateLog[-1].opp.complex_state)
                if gameState.stateLog[
                        -1].opp.simple_state != gameState.stateLog[
                            -2].opp.simple_state:
                    #print(gameState.stateLog[-1].opp.simple_state)
                    pass
                if gameState.stateLog[-1].bot.move_id != gameState.stateLog[
                        -2].bot.move_id:
                    #print(gameState.stateLog[-1].bot.move_id)
                    pass
                if gameState.stateLog[-1].opp.move_id != gameState.stateLog[
                        -2].opp.move_id:
                    #print(gameState.stateLog[-1].opp.move_id)
                    pass
                if gameState.stateLog[-1].opp.throw_tech != gameState.stateLog[
                        -2].opp.throw_tech:
                    pass
                    #print(gameState.stateLog[-1].opp.throw_tech)
                if gameState.stateLog[-1].bot.stun_state != gameState.stateLog[
                        -2].bot.stun_state:
                    pass
                    #print(gameState.stateLog[-1].bot.stun_state)
                if gameState.stateLog[
                        -1].bot.mystery_state != gameState.stateLog[
                            -2].bot.mystery_state:
                    pass
                    #print(gameState.stateLog[-1].opp.mystery_state)
                    #print('b{}'.format(gameState.stateLog[-1].bot.mystery_state))
                if gameState.stateLog[
                        -1].opp.mystery_state != gameState.stateLog[
                            -2].opp.mystery_state:
                    pass
                    #print(gameState.stateLog[-1].opp.mystery_state)
                if gameState.stateLog[-1].bot.stun_state != gameState.stateLog[
                        -2].bot.stun_state:
                    pass
                    #print('{}'.format(gameState.stateLog[-1].bot.stun_state))
                if gameState.stateLog[-1].opp.active_xyz != gameState.stateLog[
                        -2].opp.active_xyz:
                    pass
                    #print(gameState.stateLog[-1].opp.active_xyz)
                #for i, (h1, h2) in enumerate(zip(gameState.stateLog[-1].opp.hitboxes, gameState.stateLog[-2].opp.hitboxes)):
                #    if h1 != h2:
                #        for j, (b1, b2) in enumerate(zip(h1, h2)):
                #            if b1 != b2:
                #                print('{}, {}: {}'.format(j, i, b1))
                #        print('------')

        #self.CheckJumpFrameDataFallback(gameState)

        self.DetermineFrameData(gameState)

        #self.DetermineGameStats(gameState)

        if self.isPlayerOne:
            gameState.FlipMirror()