Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 2.13 KB

README.md

File metadata and controls

47 lines (33 loc) · 2.13 KB

peppi-py

Python bindings for the peppi Slippi replay parser, built using Apache Arrow and PyO3.

Installation

pip install peppi-py

To build from source instead, first install Rust. Then:

pip install maturin
maturin develop

Usage

peppi-py exposes two functions:

  • read_slippi(path, skip_frames=False)
  • read_peppi(path, skip_frames=False)

Both of these parse a replay file (.slp or .slpp respectively) into a Game object.

Frame data is stored as a struct-of-arrays for performance, using Arrow. So to get the value of an attribute "foo.bar" for the nth frame of the game, you'd write game.frames.foo.bar[n] instead of game.frames[n].foo.bar. See the code example below.

You can do many other things with Arrow arrays, such as converting them to numpy arrays. See the pyarrow docs for more, particularly the various primitive array types such as Int8Array.

Also see the Slippi replay spec for detailed information about the available fields and their meanings.

>>> from peppi_py import read_slippi, read_peppi
>>> game = read_slippi('tests/data/game.slp')
>>> game.metadata
{'startAt': '2018-06-22T07:52:59Z', 'lastFrame': 5085, 'players': {'1': {'characters': {'1': 5209}}, '0': {'characters': {'18': 5209}}}, 'playedOn': 'dolphin'}
>>> game.start
Start(slippi=Slippi(version=(1, 0, 0)), ...)
>>> game.end
End(method=<EndMethod.RESOLVED: 3>, lras_initiator=None, players=None)
>>> game.frames.ports[0].leader.post.position.x[0]
<pyarrow.FloatScalar: -42.0>