Skip to content

Commit

Permalink
* adding startup calculation to improve startup display for moves tha…
Browse files Browse the repository at this point in the history
…t 'skip' frames

* frame bot tweaks to give a cleaner qcf motion
  • Loading branch information
roguelike2d committed Jul 9, 2017
1 parent c24ad7b commit aabf365
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 24 deletions.
6 changes: 3 additions & 3 deletions BotData.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def TechCombos(gameState, botCommands):
def BlockAllAttacks(gameState: TekkenGameState, botCommands:BotCommands):
if gameState.IsOppAttacking():
if gameState.IsOppAttackLow():
botCommands.BlockLowFull(max(0, gameState.GetOppTimeUntilImpact() + gameState.GetOppActiveFrames()))
botCommands.BlockLowFull(max(0, gameState.GetOppTimeUntilImpact()))
else:
botCommands.BlockMidFull(max(0, gameState.GetOppTimeUntilImpact() + gameState.GetOppActiveFrames()))
botCommands.BlockMidFull(max(0, gameState.GetOppTimeUntilImpact()))

def UnblockIncomingAttacks(self, gameState: TekkenGameState):
if gameState.IsOppAttacking():
self.botCommands.WalkForward(max(0, gameState.GetOppTimeUntilImpact() + gameState.GetOppActiveFrames()))
self.botCommands.WalkForward(max(0, gameState.GetOppTimeUntilImpact()))
6 changes: 6 additions & 0 deletions MoveDataReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def process_list(self, true_false_list):
def is_present(self):
return len(self.start_stop_pairs) > 0

def total_present(self):
total = 0
for pair in self.start_stop_pairs:
total += pair[1] - pair[0] + 1
return total


def __repr__(self):
repr = self.name + ": "
Expand Down
4 changes: 2 additions & 2 deletions NotationParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def ConvertNotationToCommands(notation:str, timingOccurances:int):
commands += attackCommands
commands.append((Command.ReleaseBack, 2))
elif 'qcf' in notation:
commands.append((Command.HoldDown, 2))
commands.append((Command.HoldForward, 2))
commands.append((Command.HoldDown, 1))
commands.append((Command.HoldForward, 1))
commands.append((Command.ReleaseDown, 1))
commands += attackCommands
commands.append((Command.ReleaseForward, 2))
Expand Down
48 changes: 31 additions & 17 deletions TekkenEncyclopedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from TekkenGameState import TekkenGameState
import sys


class TekkenEncyclopedia:
def __init__(self, isPlayerOne = False, print_extended_frame_data = False):
self.FrameData = {}
Expand All @@ -22,6 +23,8 @@ def __init__(self, isPlayerOne = False, print_extended_frame_data = False):
self.stored_bot_recovery = 0




def GetFrameAdvantage(self, moveId, isOnBlock = True):
if moveId in self.FrameData:
if isOnBlock:
Expand All @@ -45,6 +48,8 @@ def Update(self, gameState: TekkenGameState):
#print(gameState.GetOppTechnicalStates())
#print(gameState.stateLog[-1].opp.simple_state)
#print(gameState.stateLog[-1].opp.complex_state)


if len(gameState.stateLog) > 2:
if gameState.stateLog[-1].bot.complex_state != gameState.stateLog[-2].bot.complex_state:
pass
Expand All @@ -53,8 +58,13 @@ def Update(self, gameState: TekkenGameState):
#print(gameState.stateLog[-1].opp.simple_state)
pass
if gameState.stateLog[-1].opp.move_id != gameState.stateLog[-2].opp.move_id:
#print(self.move_data_reader.get_data(gameState.stateLog[-1].opp.move_id)[2])
#print(gameState.stateLog[-1].opp.move_id)
pass
if gameState.stateLog[-1].opp.move_timer != gameState.stateLog[-2].opp.move_timer + 1:
pass
#print( '{} -> {}'.format(gameState.stateLog[-2].opp.move_timer, gameState.stateLog[-1].opp.move_timer))




Expand Down Expand Up @@ -86,9 +96,10 @@ def Update(self, gameState: TekkenGameState):
self.second_opinion_timer = 0


if (gameState.IsOppWhiffingXFramesAgo(self.active_frame_wait + 1)) and (gameState.IsBotBlocking() or gameState.IsBotGettingHit() or gameState.IsBotBeingThrown() or gameState.IsBotStartedBeingJuggled() or gameState.IsBotBeingKnockedDown() or gameState.IsBotJustGrounded()):
if (gameState.IsOppWhiffingXFramesAgo(self.active_frame_wait + 1)) 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 gameState.DidOppIdChangeXMovesAgo(self.active_frame_wait):
if gameState.DidBotIdChangeXMovesAgo(self.active_frame_wait) or gameState.DidBotTimerReduceXMovesAgo(self.active_frame_wait): #or gameState.DidOppIdChangeXMovesAgo(self.active_frame_wait):
gameState.BackToTheFuture(self.active_frame_wait)

if not self.active_frame_wait >= gameState.GetOppActiveFrames() + 1:
Expand Down Expand Up @@ -126,21 +137,18 @@ def Update(self, gameState: TekkenGameState):
frameDataEntry.startup = gameState.GetBotElapsedFramesOfRageMove(frameDataEntry.startup)

frameDataEntry.recovery = gameState.GetOppRecovery()

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

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

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

gameState.ReturnToPresent()



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

#print(gameState.IsOppAbleToAct())
#if gameState.IsOppAbleToAct():
# time_till_recovery_opp = 0

new_frame_advantage_calc = time_till_recovery_bot - time_till_recovery_opp

if gameState.IsBotBlocking():
Expand Down Expand Up @@ -178,6 +186,7 @@ def __init__(self, print_extended = False):
self.print_extended = print_extended
self.move_id = '??'
self.startup = '??'
self.calculated_startup = -1
self.hitType = '??'
self.onBlock = '??'
self.onCounterHit = '??'
Expand Down Expand Up @@ -212,22 +221,27 @@ def __repr__(self):

notes = ''

if self.print_extended:
notes += str(self.recovery) + "f "

for report in self.technical_state_reports:
if not self.print_extended:
if 'TC' in report.name and report.is_present():
notes += str(report)
if 'TJ' in report.name and report.is_present():
notes += str(report)

self.calculated_startup = self.startup
for report in self.technical_state_reports:
#if not self.print_extended:
if 'TC' in report.name and report.is_present():
notes += str(report)
elif 'TJ' in report.name and report.is_present():
notes += str(report)
elif 'PC' in report.name and report.is_present():
notes += str(report)
elif 'SKIP' in report.name and report.is_present():
self.calculated_startup = str(self.startup - report.total_present() + 1) + '?'
elif self.print_extended:
if report.is_present():
notes += str(report)
if self.print_extended:
notes += "Total:" + str(self.recovery) + "f "


return "" + str(self.input).rjust(len('input')) + " |" + str(self.hitType)[:7] + "|" + str(self.startup).center(len('startup')) + "|" + str(self.damage).center(len(' damage ')) + "| " + self.WithPlusIfNeeded(self.onBlock).center(len('block')) + "|" \
return "" + str(self.input).rjust(len('input')) + " |" + str(self.hitType)[:7] + "|" + str(self.calculated_startup).center(len('startup')) + "|" + str(self.damage).center(len(' damage ')) + "| " + self.WithPlusIfNeeded(self.onBlock).center(len('block')) + "|" \
+ self.WithPlusIfNeeded(self.onNormalHit) + " |" + (str(self.currentActiveFrame) + "/" + str(self.activeFrames) ).center(len(' active ')) + '| ' + notes \
+ " NOW:" + str(self.currentFrameAdvantage)

Expand Down
19 changes: 17 additions & 2 deletions TekkenGameState.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def GetUpdatedState(self, rollback_frame = 0):
last_eight_frames.append((potential_frame_count, potential_second_address))

if rollback_frame >= len(last_eight_frames):
print("ERROR: reqeusting {} frame of {} long rollback frame".format(rollback_frame, len(last_eight_frames)))
print("ERROR: requesting {} frame of {} long rollback frame".format(rollback_frame, len(last_eight_frames)))
rollback_frame = len(last_eight_frames) - 1

best_frame_count, player_data_second_address = sorted(last_eight_frames, key=lambda x: -x[0])[rollback_frame]
Expand Down Expand Up @@ -400,7 +400,7 @@ def Update(self):

for i in range(min(7, frames_lost)):
#print("RETRIEVING FRAMES")
droppedState = self.gameReader.GetUpdatedState(frames_lost - i)
droppedState = self.gameReader.GetUpdatedState(min(7, frames_lost) - i)
self.AppendGamedata(droppedState)

self.AppendGamedata(gameData)
Expand Down Expand Up @@ -744,7 +744,14 @@ def DidBotJustTakeDamage(self):

def DidBotTimerReduceXMovesAgo(self, framesAgo):
if len(self.stateLog) > framesAgo:
#if self.stateLog[0 - framesAgo].bot.move_id != 32769 or self.stateLog[0 - framesAgo -1].bot.move_id != 32769:
return self.stateLog[0 - framesAgo].bot.move_timer < self.stateLog[0 - framesAgo - 1].bot.move_timer

return False

def DidBotStartGettingHitXMovesAgo(self, framesAgo):
if len(self.stateLog) > framesAgo:
return self.stateLog[0 - framesAgo].bot.IsGettingHit() and not self.stateLog[0 - framesAgo - 1].bot.IsGettingHit()
else:
return False

Expand Down Expand Up @@ -861,10 +868,12 @@ def GetOppTechnicalStates(self, startup):
homing_frames2 = []
parryable_frames1 = []
parryable_frames2 = []
startup_frames = []
#found = False
#for state in reversed(self.stateLog):
#if state.opp.move_id == opp_id and not state.opp.is_bufferable:
#found = True
previous_state = None
for state in reversed(self.stateLog[-startup:]):
tc_frames.append(state.opp.IsTechnicalCrouch())
tj_frames.append(state.opp.IsTechnicalJump())
Expand All @@ -874,6 +883,11 @@ def GetOppTechnicalStates(self, startup):
homing_frames2.append(state.opp.IsHoming2())
parryable_frames1.append(state.opp.IsParryable1())
parryable_frames2.append(state.opp.IsParryable2())
if previous_state != None:
startup_frames.append(state.opp.move_timer != previous_state.opp.move_timer - 1)
else:
startup_frames.append(False)
previous_state = state
#elif found:
# break

Expand All @@ -888,6 +902,7 @@ def GetOppTechnicalStates(self, startup):
MoveDataReport('PC', pc_frames),
MoveDataReport('HOM1', homing_frames1),
MoveDataReport('HOM2', homing_frames2),
MoveDataReport('SKIP', startup_frames),
#parryable1,
#parryable2,
#unparryable
Expand Down

0 comments on commit aabf365

Please sign in to comment.