Пример #1
0
 def __init__(self, view, extended_print=False):
     self.view = view
     self.extended_print = extended_print
     self.initialized = False
     self.publisher = Publisher(Launcher.Event)
     self.game_state = TekkenGameState()
     self.cyclopedia_p1 = TekkenEncyclopedia(
         True, print_extended_frame_data=self.extended_print
     )
     self.cyclopedia_p2 = TekkenEncyclopedia(
         False, print_extended_frame_data=self.extended_print
     )
Пример #2
0
class Launcher:
    """
    """
    class Event(enum.IntEnum):
        INITIALIZED = enum.auto()
        UPDATED = enum.auto()
        CLOSED = enum.auto()

    INITIAL_SHORT_DELAY = 2
    INITIAL_LONG_DELAY = 8

    def __init__(self, view, extended_print=False):
        self.view = view
        self.extended_print = extended_print
        self.initialized = False
        self.publisher = Publisher(Launcher.Event)
        self.game_state = TekkenGameState()
        self.cyclopedia_p1 = TekkenEncyclopedia(
            True, print_extended_frame_data=self.extended_print
        )
        self.cyclopedia_p2 = TekkenEncyclopedia(
            False, print_extended_frame_data=self.extended_print
        )

    def start(self):
        self.__update_launcher()

    def __update_launcher(self):
        start = os_time.now(resolution=os_time.Resolution.MILLI)
        sucessful = self.game_state.update()
        if sucessful:
            self.cyclopedia_p1.update(self.game_state)
            self.cyclopedia_p2.update(self.game_state)
        end = os_time.now(resolution=os_time.Resolution.MILLI)
        elapsed_time = (end - start)
        if self.game_state.is_pid_valid():
            if not self.initialized:
                self.initialized = True
                self.publisher.dispatch(Launcher.Event.INITIALIZED)
            else:
                self.publisher.dispatch(Launcher.Event.UPDATED, sucessful)
            self.view.after(
                max(
                    Launcher.INITIAL_SHORT_DELAY,
                    round(Launcher.INITIAL_LONG_DELAY - elapsed_time)
                ),
                self.__update_launcher
            )
        else:
            if self.initialized:
                self.initialized = False
                self.publisher.dispatch(Launcher.Event.CLOSED)
            self.view.after(1000, self.__update_launcher)
Пример #3
0
 def __init__(self, botCommands):
     super().__init__(botCommands)
     self.queue = []
     self.lastMove = None
     self.NumCorrectPunished = 0
     self.CountOfAttempts = 0
     self.exit = False
     self.LastBotMoveName = None
     self.LastPlayerMoveName = None
     
     self.cyclopedia_p2 = TekkenEncyclopedia(False, False)
     self.cyclopedia_p1 = TekkenEncyclopedia(True, False)
Пример #4
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)
Пример #5
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)
Пример #6
0
class BotPunisher(Bot):
    def __init__(self, botCommands):
        super().__init__(botCommands)
        self.gameplan = None
        self.enemyCyclopedia = TekkenEncyclopedia(False)

    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)
Пример #7
0
 def update(launcher_queue):
     if not self.game_state:
         game_state = TekkenGameState()
     if not self.cyclopedia_p1:
         cyclopedia_p1 = TekkenEncyclopedia(
             True, print_extended_frame_data=self.extended_print
         )
     if not self.cyclopedia_p2:
         cyclopedia_p2 = TekkenEncyclopedia(
             False, print_extended_frame_data=self.extended_print
         )
     while self.__run:
         start = time.time()
         sucessful = game_state.update()
         if sucessful:
             cyclopedia_p1.update(game_state)
             cyclopedia_p2.update(game_state)
         launcher_queue.put(
             {
                 'sucessful': sucessful,
                 'game_state': game_state,
                 'p1': cyclopedia_p1,
                 'p2': cyclopedia_p2
             }
         )
         end = time.time()
         elapsed_time = end - start
         if game_state.get_reader().is_pid_valid():
             time.sleep(
                 max(
                     Launcher.INITIAL_SHORT_DELAY / 1000,
                     Launcher.INITIAL_LONG_DELAY / 1000 - elapsed_time
                 )
             )
         else:
             if self.initialized:
                 launcher_queue.put(False)
             time.sleep(1)
Пример #8
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)
Пример #9
0
 def __init__(self, botCommands):
     super().__init__(botCommands)
     self.gameplan = None
     self.enemyCyclopedia = TekkenEncyclopedia(False)
Пример #10
0
 def __init__(self):
     self.gameState = TekkenGameState()
     self.cyclopedia_p2 = TekkenEncyclopedia(False)
     self.cyclopedia_p1 = TekkenEncyclopedia(True)