Last active
October 26, 2022 15:33
-
-
Save davisdude/776bf4bfdfa78a12ed65a80dfd556920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires py-slippi to be installed | |
# | |
# Usage: | |
# python airtime.py path/to/file.slp | |
# | |
# Output: | |
# {0: 0, 1: 0, 2: 7403, 3: 5645} | |
# (e.g. player in port 3 was in the air for 7403 frames, player in port 4 | |
# was in the air for 5645 frames) | |
import sys, os | |
from slippi import Game | |
if __name__ == '__main__': | |
filename = sys.argv[1] | |
if not os.path.exists(filename): | |
print(f'Error: file {filename} not found', file=sys.stderr) | |
sys.exit(1) | |
game = Game(filename) | |
air_times = { | |
0: 0, | |
1: 0, | |
2: 0, | |
3: 0, | |
} | |
for current_frame in game.frames: | |
for port_number, port_info in enumerate(current_frame.ports): | |
if port_info is None: | |
continue | |
if port_info.leader.post.airborne: | |
air_times[port_number] += 1 | |
print(air_times) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment