Skip to content

Instantly share code, notes, and snippets.

@davisdude
Last active October 26, 2022 15:33
Show Gist options
  • Save davisdude/776bf4bfdfa78a12ed65a80dfd556920 to your computer and use it in GitHub Desktop.
Save davisdude/776bf4bfdfa78a12ed65a80dfd556920 to your computer and use it in GitHub Desktop.
# 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