awpy Documentation

repository·main·Indexed 20 days ago

https://github.com/pnxenopoulos/awpy

A Python library for parsing, analyzing, and visualizing Counter-Strike 2 (CS2) and CSGO demo files. It provides the Demo class for extracting tick-level player data and events into Polars dataframes, calculates advanced statistics like ADR and KAST, and includes a CLI for fetching resources such as map data and nav meshes. Features include support for navigation mesh analysis via the Nav class, player spawn extraction with the Spawns class, and visualization tools for heatmaps and animated round GIFs.

Tokens
16.2K
Snippets
71
Records
90
Agent score
66%

What's inside awpy

  1. Calculate Counter-Strike 2 statistics with awpy.stats

    main

    The awpy.stats module provides functions to calculate specific performance metrics from Counter-Strike 2 demo files. Supported statistics include:

    • ADR (Average Damage per Round)
    • KAST (Kill, Assist, Survival, or Traded)
    • Rating

    These functions are designed to process parsed demo data to derive high-level player and match performance metrics.

  2. Calculate visibility in Counter-Strike 2 demos with awpy.visibility

    main
    The awpy.visibility module provides functions designed to calculate visibility metrics within Counter-Strike 2 (CS2) demo files. This is useful for analyzing player sightlines, field of view, or environmental obstructions during a match.
  3. Access parsed demo properties

    main

    After calling .parse() on a Demo object, several properties are populated containing the extracted data. The available properties include:

    • header: General demo and map information.
    • rounds: Round phase change events.
    • bomb: Bomb-related events (pickup, drop, plant, defuse, detonate).
    • kills: Player kill events.
    • damages: Damage events.
    • shots: Shot events.
    • grenades: Grenade events.
    • infernos: Inferno events.
    • smokes: Smoke events.
    • footsteps: Footstep events.
    • ticks: Tick-based data.

    Note on Data Types: Most of these properties return Polars dataframes. If you prefer to work with Pandas, you can convert them using the .to_pandas() method.

    import polars as pl
    
    # Assuming 'demo' is an instance of the Demo class after calling .parse()
    # Accessing a dataframe property
    rounds_df = demo.rounds
    
    # Converting to Pandas if needed
    pandas_df = demo.rounds.to_pandas()
  4. Limitations of visibility calculations

    main

    The visibility calculation provided by VisibilityChecker is based on static map geometry (triangles). It does not account for dynamic elements such as:

    • Smoke grenades
    • Flashbangs
    • Moving props

    Users should be aware that a True result indicates a clear line of sight through the map geometry, but not necessarily a clear line of sight in active gameplay.

  5. Acquire CS2 map `.tri` files

    main

    Awpy uses .tri files (binary files containing map triangle information) to calculate visibility. You can download the relevant .tri files for your maps to your local awpy data directory by running the following command in your terminal:

    awpy get tris