Advertisement
Faschz

Z64 - Setup Simulator

Nov 18th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.06 KB | None | 0 0
  1. """
  2. This script is just a hacky way to simulate setups. Keep in mind the actions
  3. list is very specific to the specific angle we used in the Majora's Mask moon
  4. warp setup using the owl statue. There are probably better ways to write an
  5. algorithm for this, but it gets the job done. - @Faschz
  6. """
  7.  
  8. actions = [(0,0, "NULL"),
  9.            (0.51708984375, -1.9093915224075317, "ZORA B"),
  10.            (29.566650390625, -19.113862991333008, "ZORA B (HOLD R or Z)"),
  11.            (32.0498046875, -21.834140777587891, "ZORA FORWARD B WITH FINS PUT AWAY (HOLD R or Z)"),
  12.            (39.729248046875, -26.933433532714844, "ZORA ROLL"),
  13.            (104.2890625, -70.700263977050781, "ZORA FULL ROLL then R"),
  14.            (63.939697265625, -43.34600830078125, "ZORA JUMPSLASH (same with R)"),
  15.            (72.320068359375, -49.027290344238281, "ZORA JUMPSLASH + HOLD UP + HOLD R"),
  16.            (-88.149169921875, 59.758556365966797, "ZORA FULL BACKFLIP"),
  17.            (117.267822265625, -79.49853515625, "ZORA JUMPSLASH + B (Zora clipping)"),
  18.            (2369.546875, -48.70623779296875, "ZORA DOUBLE B ATTACK"),
  19.            (2362.59130859375, -41.502281188964844, "ZORA DOUBLE B ATTACK then R"),
  20.            (59.13330078125, -38.227725982666016, "ZORA DOUBLE B then R (or double B with Z)"),
  21.            (61.63427734375, -43.341995239257813, "ZORA TRIPLE B"),
  22.            (48.341552734375, -34.330516815185547, "ZORA TRIPLE B+R"),
  23.            (14.091796875, -11.111648559570313, "ZORA HOLD B TO HOLD FINS"),
  24.            (4.96630859375, -3.3666796684265137, "ZORA/HUMAN SHIELD SCOOT"),
  25.            (3.994140625, -3.1140971183776855, "HUMAN B"),
  26.            (4.8935546875, -5.4199552536010742, "HUMAN B then R"),
  27.            (7.796630859375, -2.2444829940795898, "HUMAN HOLD Z, PRESS B (same with R)"),
  28.            (39.729248046875, -26.933433532714844, "HUMAN ROLL"),
  29.            (96.83984375, -65.650260925292969, "HUMAN FULL ROLL then R"),
  30.            (31.693115234375, -21.243093490600586, "HUMAN JUMPSLASH + RELEASE Z"),
  31.            (36.907470703125, -24.778099060058594, "HUMAN JUMPSLASH + HOLD UP + RELEASE Z"),
  32.            (46.02294921875, -31.215547561645508, "HUMAN JUMPSLASH + (R or Z)"),
  33.            (51.2373046875, -34.750553131103516, "HUMAN JUMPSLASH + HOLD UP + (R or Z)"),
  34.            (-82.561767578125, 55.971050262451172, "HUMAN FULL BACKFLIP"),
  35.            (4.34326171875, -3.7413227558135986, "HUMAN SPIN ATTACK"),
  36.            (4.5703125, -3.3949298858642578, "HUMAN SPIN ATTACK+R"),
  37.            (22.76904296875, -14.419496536254883, "HUMAN FORWARD B"),
  38.            (24.748779296875, -16.699634552001953, "HUMAN FORWARD B (untarget)"),
  39.            (0.87158203125, 1.308686375617981, "HUMAN DIAGONAL SLASH (release Z)"),
  40.            (4.781005859375, -2.5297741889953613, "HUMAN DIAGONAL SLASH"),
  41.            (124.126953125, -84.1488037109375, "DEKU FORWARD SPIN + R"),
  42.            ]
  43.  
  44. best_dist = 2**32
  45. best_actions = []
  46. def get_permutations(x, z, action=0, prev_dist=2**32, action_list=[]):
  47.     """
  48.    @param x: The X coordinate of Link.
  49.    @param z: The Z coordinate of Link.
  50.    @param action: The index of the action being performed in the table.
  51.    @param prev_dist: The previous square distance to the destination.
  52.    @param action_list: The current list of actions on the given branch
  53.    """
  54.    
  55.     global best_dist
  56.     global best_actions
  57.  
  58.     # This limits the depth of the search by preventing too many actions
  59.     if (len(action_list) > 7):
  60.         return False
  61.    
  62.     # Perform the action that was received.
  63.     x += actions[action][0]
  64.     z += actions[action][1]
  65.     action_list.append(action)
  66.  
  67.     # This is the square distance to the destination point.
  68.     dist = (x - 2605.066786875)**2 + (z - -168.244163818)**2
  69.  
  70.     # This cuts the branch short incase you move further away from the target
  71.     # destination. As a result, backflips typically are just tossed using this.
  72.     # Removing this check will result in a longer simulation time, but might
  73.     # give a better result if setups moving further away from the destination
  74.     # for an action do yield closer results.
  75.     if (dist >= prev_dist):
  76.         return False
  77.  
  78.     # Recursively test all of the other actions
  79.     for a in range(action, len(actions)):
  80.         copy_actions = action_list[:]
  81.  
  82.         # Check if we reached the end of the branch, if so the distance needs
  83.         # to be compared against our best.
  84.         if (get_permutations(x, z, a, dist, copy_actions) == False):
  85.             if (dist < best_dist):
  86.                 print(action_list)
  87.                 best_dist = dist
  88.                 best_actions = action_list[1:]
  89.  
  90. # The starting point of our simulation
  91. x = 2329.29028320313
  92. z = -8.10069179534912
  93.  
  94. # Simulate all permutations
  95. get_permutations(x, z)
  96.  
  97. # Now that we have found the best setup, let's go ahead and calculate what the
  98. # resulting (x, z) coordinates would be. Also while going through the actions,
  99. # print out what the steps would be. Reminder: These steps can be performed in
  100. # any order
  101. for a in best_actions:
  102.     x += actions[a][0]
  103.     z += actions[a][1]
  104.     print(actions[a][2])
  105.  
  106. print(x,z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement