Advertisement
Guest User

Spirit Barrage

a guest
Feb 25th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. '''
  2. Spirit Barrage Playstyle: Frame Sniping
  3. Delay Optimization
  4. by MarioVX
  5. '''
  6. from math import ceil
  7.  
  8.  
  9. def average_ticks_per_frame(fpa, delay):
  10.     '''
  11.    Calculate average ticks per frame.
  12.  
  13.    Args:
  14.        fpa (int): Frames per Attack of Spirit Barrage
  15.        delay (int): The number of frames you wait after finishing
  16.            the 3rd use of Spirit Barrage before starting the next.
  17.  
  18.    Returns:
  19.        float: average ticks per frame.
  20.  
  21.    '''
  22.     # total duration is 3 times FPA and the delay you wait thereafter
  23.     duration = 3*fpa + delay
  24.     # ticks: ticks_1 + ticks_2 + ticks_3, for each phantasm:
  25.     # a phantasms ticks is its lifetime divided by 30 frames, rounded up,
  26.     # but caps at 10.
  27.     ticks = min(ceil(duration/30),10)
  28.     return ticks/duration
  29.  
  30.  
  31. def optimal_delay(fpa):
  32.     '''
  33.    Find the optimal delay for a given FPA.
  34.  
  35.    Args:
  36.        fpa (int): Frames per Attack of Spirit Barrage
  37.  
  38.    Returns:
  39.        tuple: (optimal delay, average ticks per frame at that delay)
  40.            In case of tie, use longer delay to conserve Mana.
  41.    '''
  42.     # Generate tuples for all conceivable delays.
  43.     # max delay is up to the last tick of the third phantasm
  44.     all = [(i, average_ticks_per_frame(fpa, i)) for i in range(271-fpa)]
  45.     # sort the tuples in the desired order, return only its first.
  46.     return sorted(all, key=lambda x: (-x[1],-x[0]))[0]
  47.  
  48.  
  49. # generate a map: fpa -> optimal_delay(fpa) for FPA from 1 to 48.
  50. optimals = dict((i,optimal_delay(i)) for i in range(1,49))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement