Giter Site home page Giter Site logo

py-slippi's Introduction

py-slippi

Py-slippi is a Python parser for .slp game replay files for Super Smash Brothers Melee for the Nintendo GameCube. These replays are generated by Jas Laferriere's Slippi recording code, which runs on a Wii or the Dolphin emulator.

Installation

Requires Python >= 3.7. To install, run the following command (optionally inside a virtual environment):

pip install py-slippi

API Docs

See the Module Index for detailed API docs, starting with slippi.game.

Usage

py-slippi supports both event-based and object-based parsing. Object-based parsing is generally easier, but event-based parsing is more efficient and supports reading partial or in-progress games.

Object-based parsing:

>>> from slippi import Game
>>> Game('test/replays/game.slp')
Game(
    end=End(
        lras_initiator=None,
        method=Method.CONCLUSIVE),
    frames=[...](5209),
    metadata=Metadata(
        console_name=None,
        date=2018-06-22 07:52:59+00:00,
        duration=5209,
        platform=Platform.DOLPHIN,
        players=(
            Player(
                characters={InGameCharacter.MARTH: 5209},
                netplay_name=None),
            Player(
                characters={InGameCharacter.FOX: 5209},
                netplay_name=None),
            None,
            None)),
    start=Start(
        is_frozen_ps=None,
        is_pal=None,
        is_teams=False,
        players=(
            Player(
                character=CSSCharacter.MARTH,
                costume=3,
                stocks=4,
                tag=,
                team=None,
                type=Type.HUMAN,
                ucf=UCF(
                    dash_back=DashBack.OFF,
                    shield_drop=ShieldDrop.OFF)),
            Player(
                character=CSSCharacter.FOX,
                costume=0,
                stocks=4,
                tag=,
                team=None,
                type=Type.CPU,
                ucf=UCF(
                    dash_back=DashBack.OFF,
                    shield_drop=ShieldDrop.OFF)),
            None,
            None),
        random_seed=3803194226,
        slippi=Slippi(
            version=1.0.0),
        stage=Stage.YOSHIS_STORY))

Frame data is elided when you print games, but you can inspect a sample frame with e.g. game.frames[0].

Optionally skip frame parsing for a signficant speedup:

>>> from slippi import Game
>>> Game('test/replays/game.slp', skip_frames=True)

Event-driven API:

>>> from slippi.parse import parse
>>> from slippi.parse import ParseEvent
>>> handlers = {ParseEvent.METADATA: print}
>>> parse('test/replays/game.slp', handlers)
Metadata(
    console_name=None,
    date=2018-06-22 07:52:59+00:00,
    duration=5209,
    platform=Platform.DOLPHIN,
    players=(
        Player(
            characters={InGameCharacter.MARTH: 5209},
            netplay_name=None),
        Player(
            characters={InGameCharacter.FOX: 5209},
            netplay_name=None),
        None,
        None))

๐Ÿ‘‰ You can pass a stream to parse, such as sys.stdin.buffer! This is useful for e.g. decompressing with gunzip, or reading from an in-progress replay via tail -c+1 -f.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.