### Exploring Awpy Data Download Options Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/getting-started/installation.rst Shows the available command-line options for the 'awpy get' command, which is used to download data files like world geometry and parsed navigation files. ```bash awpy get --help ``` -------------------------------- ### Install Awpy using pip (Shell) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/getting-started/faq.rst This command demonstrates how to install the Awpy library using pip, the standard package installer for Python. It fetches the latest version of Awpy from PyPI and installs it into your Python environment. ```Shell pip install awpy ``` -------------------------------- ### Checking Awpy Version Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/getting-started/installation.rst Displays the currently installed version of the Awpy library using the pip show command. ```bash pip show awpy ``` -------------------------------- ### Install Awpy Development Dependencies (uv) Source: https://github.com/pnxenopoulos/awpy/blob/main/CONTRIBUTING.md Use uv to synchronize dependencies across all groups and install project-specific tools, preparing the environment for development. ```shell uv sync --all-groups uv tool install . ``` -------------------------------- ### Installing Awpy with pip Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/getting-started/installation.rst Installs the Awpy Python library using the pip package manager. Requires Python version 3.11 or higher. ```bash pip install awpy ``` -------------------------------- ### Listing Available Awpy Triangle Files (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Imports the TRIS_DIR constant from awpy.data and iterates through its contents, printing each file path. This demonstrates how to locate the map triangle data files after downloading them using `awpy get tris`. ```python from awpy.data import TRIS_DIR # List files in the data directory for file in TRIS_DIR.iterdir(): print(file) ``` -------------------------------- ### Parsing CS2 Demo and Accessing Data with Awpy Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/index.rst This snippet demonstrates the basic usage of the Awpy library to parse a Counter-Strike 2 demo file. It shows how to import the Demo class, create an instance with a demo file path, parse the demo, and then access various attributes which contain demo data as dictionaries or Polars DataFrames. It also includes an example of converting a Polars DataFrame to a Pandas DataFrame. ```python from awpy import Demo # Construct and then parse a demo dem = Demo("natus-vincere-vs-virtus-pro-m1-overpass.dem") dem.parse() # Access various dictionaries & Polars dataframes dem.header dem.rounds dem.grenades dem.kills dem.damages dem.bomb dem.smokes dem.infernos dem.shots dem.ticks # If you need to change to a Pandas dataframe, you can do dem.ticks.to_pandas() ``` -------------------------------- ### Smoke Event Data Structure (awpy) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst This snippet illustrates the structure and example data for the `.smokes` property in awpy, which provides details on smoke grenade events. The table shows key columns including entity ID, start and end ticks, thrower information (position, Steam ID), and the grenade's location (X, Y, Z). The '...' indicates additional columns may be present. ```none ┌───────────┬────────────┬──────────┬──────────────┬───┬───────────────────┬──────────────┬──────────────┬─────────────┐ │ entity_id ┆ start_tick ┆ end_tick ┆ thrower_X ┆ … ┆ thrower_steamid ┆ X ┆ Y ┆ Z │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ i64 ┆ i64 ┆ i64 ┆ f64 ┆ ┆ str ┆ f64 ┆ f64 ┆ f64 │ ╞═══════════╪════════════╪══════════╪══════════════╪═══╪═══════════════════╪══════════════╪══════════════╪═════════════╡ │ 111 ┆ 6585 ┆ null ┆ -603.621338 ┆ … ┆ 76561198068002993 ┆ -1273.158081 ┆ 199.570801 ┆ -166.040344 │ │ 193 ┆ 6753 ┆ null ┆ -1417.788574 ┆ … ┆ 76561197982141573 ┆ -1979.307251 ┆ -325.090729 ┆ -165.96875 │ │ 439 ┆ 9882 ┆ 11294 ┆ -1853.035889 ┆ … ┆ 76561198170631091 ┆ -1437.317139 ┆ 725.867432 ┆ -53.96875 │ │ 450 ┆ 11309 ┆ 12721 ┆ -828.063354 ┆ … ┆ 76561197961491680 ┆ -617.765198 ┆ -875.580383 ┆ -253.96875 │ │ 465 ┆ 12596 ┆ 14008 ┆ -578.492371 ┆ … ┆ 76561198078771373 ┆ -634.322815 ┆ -745.603333 ┆ -264.626923 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 36 ┆ 189136 ┆ 190548 ┆ 773.494446 ┆ … ┆ 76561198144926364 ┆ -512.126648 ┆ -1611.015625 ┆ -37.971172 │ │ 195 ┆ 189220 ┆ 190632 ┆ -805.207947 ┆ … ┆ 76561198080703143 ┆ -633.220032 ┆ -726.947754 ┆ -266.27713 │ │ 173 ┆ 189249 ┆ 190661 ┆ -1026.025146 ┆ … ┆ 76561198074762801 ┆ 254.503632 ┆ -1530.493286 ┆ -173.96875 │ │ 411 ┆ 189259 ┆ 190671 ┆ 530.297791 ┆ … ┆ 76561198144926364 ┆ -808.669983 ┆ -1622.820679 ┆ 18.03125 │ │ 101 ┆ 190612 ┆ 192024 ┆ -1063.140381 ┆ … ┆ 76561198012872053 ┆ -684.59198 ┆ -1636.631226 ┆ -169.96875 │ └───────────┴────────────┴──────────┴──────────────┴───┴───────────────────┴──────────────┴──────────────┴─────────────┘ ``` -------------------------------- ### Calculating Point-to-Point Visibility with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Defines example 3D coordinates for player positions and uses the is_visible method of the VisibilityChecker object to determine if a straight line between the points is unobstructed by map geometry. The results are printed to the console. ```python t_spawn_pos_1 = (-680, 834, 180) t_spawn_pos_2 = (-1349, 814, 180) ct_spawn_pos = (15, 2168, -65) print(f"T spawn 1 is visible from T spawn 2: {vc.is_visible(t_spawn_pos_1, t_spawn_pos_2)}") print(f"T spawn 1 is visible from CT spawn: {vc.is_visible(t_spawn_pos_1, ct_spawn_pos)}") ``` -------------------------------- ### Data Structure for Shots Property (awpy) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst The .shots property contains information on when a player shoots their weapon. This table shows the columns available, their data types, and example data rows. ```none ┌──────────┬────────┬──────────────┬──────────────┬───┬────────────────────────┬─────────────┬───────────────────┬─────────────────────────┐ │ silenced ┆ tick ┆ player_X ┆ player_Y ┆ … ┆ player_last_place_name ┆ player_name ┆ player_steamid ┆ weapon │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ bool ┆ i32 ┆ f32 ┆ f32 ┆ ┆ str ┆ str ┆ str ┆ str │ ╞══════════╪════════╪══════════════╪══════════════╪═══╪════════════════════════╪═════════════╪═══════════════════╪═════════════════════════╡ │ false ┆ 5090 ┆ -1379.150391 ┆ -973.78064 ┆ … ┆ CTSpawn ┆ JDC ┆ 76561198078771373 ┆ weapon_knife_m9_bayonet │ │ false ┆ 5132 ┆ -1323.212036 ┆ -967.742065 ┆ … ┆ CTSpawn ┆ JDC ┆ 76561198078771373 ┆ weapon_knife_m9_bayonet │ │ false ┆ 5231 ┆ -1914.81958 ┆ -323.105957 ┆ … ┆ Shop ┆ hyped ┆ 76561198139604328 ┆ weapon_knife_butterfly │ │ false ┆ 6240 ┆ -161.028076 ┆ 576.19574 ┆ … ┆ BackAlley ┆ HeavyGod ┆ 76561198068002993 ┆ weapon_smokegrenade │ │ false ┆ 6266 ┆ -160.031372 ┆ 887.971619 ┆ … ┆ BackAlley ┆ Snax ┆ 76561197982141573 ┆ weapon_smokegrenade │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ false ┆ 191981 ┆ -1242.619263 ┆ -1435.148438 ┆ … ┆ Jungle ┆ malbsMd ┆ 76561198080703143 ┆ weapon_flashbang │ │ true ┆ 192969 ┆ -758.870544 ┆ -1669.898682 ┆ … ┆ BombsiteA ┆ malbsMd ┆ 76561198080703143 ┆ weapon_m4a1_silencer │ │ true ┆ 192975 ┆ -758.761292 ┆ -1670.187744 ┆ … ┆ BombsiteA ┆ malbsMd ┆ 76561198080703143 ┆ weapon_m4a1_silencer │ │ true ┆ 192982 ┆ -758.760498 ┆ -1669.444092 ┆ … ┆ BombsiteA ┆ malbsMd ┆ 76561198080703143 ┆ weapon_m4a1_silencer │ │ true ┆ 192988 ┆ -758.760498 ┆ -1669.444092 ┆ … ┆ BombsiteA ┆ malbsMd ┆ 76561198080703143 ┆ weapon_m4a1_silencer │ └──────────┴────────┴──────────────┴──────────────┴───┴────────────────────────┴─────────────┴───────────────────┴─────────────────────────┘ ``` -------------------------------- ### Inferno Event Data Structure (awpy) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst This snippet illustrates the structure and example data for the `.infernos` property in awpy, which provides details on molotov and incendiary grenade events. The table shows key columns including entity ID, start and end ticks, thrower information (position, Steam ID), and the grenade's location (X, Y, Z). The '...' indicates additional columns may be present. ```none ┌───────────┬────────────┬──────────┬──────────────┬───┬───────────────────┬──────────────┬──────────────┬────────────┐ │ entity_id ┆ start_tick ┆ end_tick ┆ thrower_X ┆ … ┆ thrower_steamid ┆ X ┆ Y ┆ Z │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ i64 ┆ i64 ┆ i64 ┆ f64 ┆ ┆ str ┆ f64 ┆ f64 ┆ f64 │ ╞═══════════╪════════════╪══════════╪══════════════╪═══╪═══════════════════╪══════════════╪══════════════╪════════════╡ │ 438 ┆ 9479 ┆ 9832 ┆ -749.3255 ┆ … ┆ 76561198144926364 ┆ 249.482285 ┆ -1527.261108 ┆ -173.96875 │ │ 46 ┆ 15699 ┆ 15931 ┆ -762.805664 ┆ … ┆ 76561198144926364 ┆ 227.161819 ┆ -1515.966675 ┆ -173.96875 │ │ 218 ┆ 15990 ┆ 16343 ┆ -1563.132568 ┆ … ┆ 76561198170631091 ┆ -1536.188232 ┆ 712.675232 ┆ -45.96875 │ │ 43 ┆ 16131 ┆ 16228 ┆ -1258.452271 ┆ … ┆ 76561198139604328 ┆ 451.550842 ┆ -629.696655 ┆ -159.96875 │ │ 202 ┆ 18718 ┆ 19071 ┆ -786.658203 ┆ … ┆ 76561197961491680 ┆ -1007.844727 ┆ -601.723022 ┆ -285.96875 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 136 ┆ 188071 ┆ 188425 ┆ -1964.792358 ┆ … ┆ 76561197982141573 ┆ -1220.075073 ┆ 687.893616 ┆ -77.96875 │ │ 171 ┆ 188370 ┆ 188724 ┆ -611.331116 ┆ … ┆ 76561198080703143 ┆ -951.713867 ┆ -276.406525 ┆ -361.96875 │ │ 217 ┆ 189287 ┆ 189736 ┆ 26.230442 ┆ … ┆ 76561197961491680 ┆ 94.700676 ┆ -2335.717041 ┆ -37.96875 │ │ 38 ┆ 190009 ┆ 190458 ┆ -388.368042 ┆ … ┆ 76561198139604328 ┆ -1190.271606 ┆ -1302.557983 ┆ -168.82959 │ │ 240 ┆ 191123 ┆ 191477 ┆ -554.03479 ┆ … ┆ 76561198012872053 ┆ -642.059753 ┆ -2190.879639 ┆ -180.0 │ └───────────┴────────────┴──────────┴──────────────┴───┴───────────────────┴──────────────┴──────────────┴────────────┘ ``` -------------------------------- ### Data Structure for Grenades Property (awpy) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst The .grenades property contains information on when a player throws a grenade. This table shows the columns available, their data types, and example data rows. ```none ┌───────────────────┬──────────┬──────────────┬────────┬───┬─────────────┬────────────┬───────────┬───────────┐ │ thrower_steamid ┆ thrower ┆ grenade_type ┆ tick ┆ … ┆ Y ┆ Z ┆ entity_id ┆ round_num │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ u64 ┆ str ┆ str ┆ i32 ┆ ┆ f32 ┆ f32 ┆ i32 ┆ u32 │ ╞═══════════════════╪══════════╪══════════════╪════════╪═══╪═════════════╪════════════╪═══════════╪═══════════╡ │ 76561198068002993 ┆ HeavyGod ┆ smoke ┆ 6253 ┆ … ┆ 565.6875 ┆ 22.40625 ┆ 111 ┆ 1 │ │ 76561198068002993 ┆ HeavyGod ┆ smoke ┆ 6254 ┆ … ┆ 562.53125 ┆ 28.5 ┆ 111 ┆ 1 │ │ 76561198068002993 ┆ HeavyGod ┆ smoke ┆ 6255 ┆ … ┆ 559.375 ┆ 34.5 ┆ 111 ┆ 1 │ │ 76561198068002993 ┆ HeavyGod ┆ smoke ┆ 6256 ┆ … ┆ 556.21875 ┆ 40.437496 ┆ 111 ┆ 1 │ │ 76561198068002993 ┆ HeavyGod ┆ smoke ┆ 6257 ┆ … ┆ 553.0625 ┆ 46.28125 ┆ 111 ┆ 1 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 76561198080703143 ┆ malbsMd ┆ flashbang ┆ 192087 ┆ … ┆ -1589.6875 ┆ -148.40625 ┆ 249 ┆ 22 │ │ 76561198080703143 ┆ malbsMd ┆ flashbang ┆ 192088 ┆ … ┆ -1591.1875 ┆ -152.875 ┆ 249 ┆ 22 │ │ 76561198080703143 ┆ malbsMd ┆ flashbang ┆ 192089 ┆ … ┆ -1592.6875 ┆ -157.40625 ┆ 249 ┆ 22 │ │ 76561198080703143 ┆ malbsMd ┆ flashbang ┆ 192090 ┆ … ┆ -1594.21875 ┆ -162.0625 ┆ 249 ┆ 22 │ │ 76561198080703143 ┆ malbsMd ┆ flashbang ┆ 192091 ┆ … ┆ -1595.59375 ┆ -165.625 ┆ 249 ┆ 22 │ └───────────────────┴──────────┴──────────────┴────────┴───┴─────────────┴────────────┴───────────┴───────────┘ ``` -------------------------------- ### Viewing Rounds Data Structure (Polars) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst The `.rounds` property is a Polars DataFrame containing information on round phase change events (start, freeze, bomb plant, end, official end) and outcomes. This code block shows a text representation of the DataFrame structure and sample data. ```none ┌───────────┬────────┬────────────┬────────┬───┬────────┬───────────────┬────────────┬─────────────┐ │ round_num ┆ start ┆ freeze_end ┆ end ┆ … ┆ winner ┆ reason ┆ bomb_plant ┆ bomb_site │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ u32 ┆ i32 ┆ i32 ┆ i32 ┆ ┆ str ┆ str ┆ i64 ┆ str │ ╞═══════════╪════════╪════════════╪════════╪═══╪════════╪═══════════════╪════════════╪═════════════╡ │ 1 ┆ 209 ┆ 4806 ┆ 7211 ┆ … ┆ CT ┆ t_killed ┆ null ┆ not_planted │ │ 2 ┆ 7659 ┆ 8939 ┆ 13602 ┆ … ┆ CT ┆ t_killed ┆ null ┆ not_planted │ │ 3 ┆ 14050 ┆ 15330 ┆ 23461 ┆ … ┆ T ┆ bomb_exploded ┆ 20837 ┆ bombsite_b │ │ 4 ┆ 23909 ┆ 25189 ┆ 32702 ┆ … ┆ T ┆ bomb_exploded ┆ 30078 ┆ bombsite_b │ │ 5 ┆ 33150 ┆ 37102 ┆ 40372 ┆ … ┆ T ┆ ct_killed ┆ 39741 ┆ bombsite_b │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 18 ┆ 144112 ┆ 148122 ┆ 155529 ┆ … ┆ T ┆ ct_killed ┆ 154014 ┆ bombsite_b │ │ 19 ┆ 155977 ┆ 157257 ┆ 163644 ┆ … ┆ CT ┆ bomb_defused ┆ 162290 ┆ bombsite_b │ │ 20 ┆ 164092 ┆ 165372 ┆ 173711 ┆ … ┆ T ┆ bomb_exploded ┆ 171087 ┆ bombsite_b │ │ 21 ┆ 174159 ┆ 178124 ┆ 185501 ┆ … ┆ CT ┆ bomb_defused ┆ 184616 ┆ bombsite_b │ │ 22 ┆ 185949 ┆ 187229 ┆ 193492 ┆ … ┆ CT ┆ bomb_defused ┆ 191852 ┆ bombsite_b │ └───────────┴────────┴────────────┴────────┴───┴────────┴───────────────┴────────────┴─────────────┘ ``` -------------------------------- ### Awpy CLI Parsing with Options (Shell) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo_cli.ipynb Demonstrates how to pass specific options to the Awpy parse command, such as selecting player properties to include and enabling verbose output. ```Shell !awpy parse spirit-vs-natus-vincere-m2-dust2.dem --player-props X,Y,Z,health --verbose ``` -------------------------------- ### Initializing Awpy VisibilityChecker (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Demonstrates creating a VisibilityChecker instance using either a file path to a .tri file or a list of Triangle objects read from a file. This is the necessary first step before performing visibility checks. ```python from awpy.visibility import VisibilityChecker de_dust2_tri = TRIS_DIR / "de_dust2.tri" # Create VC object with a file path vc = VisibilityChecker(path=de_dust2_tri) # Create VC object with a list of triangles tris = VisibilityChecker.read_tri_file(de_dust2_tri) vc = VisibilityChecker(triangles=tris) print(vc) ``` -------------------------------- ### Timing Awpy VisibilityChecker Initialization (Mirage) (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Uses the %timeit magic command to measure the time required to create a VisibilityChecker instance by loading the .tri file for the de_mirage map. This demonstrates the overhead associated with building the internal BVH structure. ```python %timeit VisibilityChecker(path=TRIS_DIR / "de_mirage.tri") ``` -------------------------------- ### Initializing and Parsing a CS2 Demo with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/demo_stats.ipynb This snippet demonstrates how to initialize a Demo object from a demo file path and parse its contents using the Awpy library. This step is necessary before calculating statistics. ```python from awpy import Demo # Demo: https://www.hltv.org/matches/2372746/spirit-vs-natus-vincere-blast-premier-spring-final-2024 (de_dust2, Map 2) dem = Demo("spirit-vs-natus-vincere-m2-dust2.dem") dem.parse() ``` -------------------------------- ### Timing Awpy VisibilityChecker Initialization (Inferno) (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Uses the %timeit magic command to measure the time required to create a VisibilityChecker instance by loading the .tri file for the de_inferno map. This provides a performance benchmark for initializing the visibility checker with a larger map's geometry data. ```python %timeit VisibilityChecker(path=TRIS_DIR / "de_inferno.tri") ``` -------------------------------- ### Parsing CS2 Demo with Specific Player Properties (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo.ipynb This snippet shows how to initialize the `Demo` object and then call the `parse()` method, passing a list of desired player properties via the `player_props` argument. This allows for parsing only a subset of available player data, potentially improving performance or reducing memory usage. It then prints the head of the resulting `ticks` dataframe. ```python dem = Demo("spirit-vs-natus-vincere-m2-dust2.dem") dem.parse(player_props=["X", "Y", "Z", "health", "armor_value", "has_helmet", "has_defuser", "inventory"]) print(f"\nTicks: \n{dem.ticks.head(n=3)}") ``` -------------------------------- ### Basic Awpy CLI Demo Parsing (Shell) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo_cli.ipynb Executes the basic Awpy parse command on a demo file. The output is a zipped file containing parsed data in parquet format. ```Shell !awpy parse spirit-vs-natus-vincere-m2-dust2.dem ``` -------------------------------- ### Parsing CS2 Demo and Accessing Default Dataframes (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo.ipynb This snippet demonstrates how to initialize the `Demo` object with a demo file path and `verbose=True`, then call the `parse()` method to extract data. It subsequently prints the header and the first few rows of several default dataframes available on the `dem` object, such as rounds, kills, damages, etc. ```python from awpy import Demo # Demo: https://www.hltv.org/matches/2372746/spirit-vs-natus-vincere-blast-premier-spring-final-2024 (de_dust2, Map 2) dem = Demo("spirit-vs-natus-vincere-m2-dust2.dem", verbose=True) dem.parse() # Available properties (all demos) print(f"\nHeader: \n{dem.header}") print(f"\nRounds: \n{dem.rounds.head(n=3)}") print(f"\nKills: \n{dem.kills.head(n=3)}") print(f"\nDamages: \n{dem.damages.head(n=3)}") print(f"\nWeapon Fires: \n{dem.shots.head(n=3)}") print(f"\nBomb: \n{dem.bomb.head(n=3)}") print(f"\nSmokes: \n{dem.smokes.head(n=3)}") print(f"\nInfernos: \n{dem.infernos.head(n=3)}") print(f"\nGrenades: \n{dem.grenades.head(n=3)}") print(f"\nFootsteps: \n{dem.footsteps.head(n=3)}") print(f"\nTicks: \n{dem.ticks.head(n=3)}") ``` -------------------------------- ### Parsing a CS2 Demo and Accessing Data with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/README.md This snippet demonstrates the basic usage of the Awpy library to parse a Counter-Strike 2 demo file. It shows how to initialize the Demo object, trigger the parsing process, and access the various data attributes which are available as dictionaries and Polars dataframes. ```Python from awpy import Demo # Create and parse demo dem = Demo("g2-vs-navi.dem") dem.parse() # Access various dictionaries & dataframes dem.header dem.rounds dem.grenades dem.kills dem.damages dem.bomb dem.smokes dem.infernos dem.shots dem.footsteps dem.ticks # The dataframes are Polars dataframes # to transform to Pandas, just do .to_pandas() dem.ticks.to_pandas() ``` -------------------------------- ### Parsing a Demo File using Awpy CLI (Bash) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/cli.rst This command demonstrates how to parse a Counter-Strike demo file using the Awpy command-line interface. It specifies the demo file name, selects specific player properties (X, Y, Z) and other game state properties (is_bomb_planted) to extract, and enables verbose output for detailed progress. ```bash awpy parse natus-vincere-vs-virtus-pro-m1-overpass.dem --player-props X,Y,Z --other-props is_bomb_planted --verbose ``` -------------------------------- ### Run Development Checks and Tests (uv) Source: https://github.com/pnxenopoulos/awpy/blob/main/CONTRIBUTING.md Execute pre-commit hooks to check for code style and typos, run Python tests using pytest, and generate a text-based coverage report using uv. ```shell uv run pre-commit run --all-files --show-diff-on-failure # ruff, typos, uv uv run coverage run -m pytest --durations=10 # python tests uv run coverage report -m # produces text-based coverage report ``` -------------------------------- ### Calculating Kill, Assist, Survival, Trade % (KAST) with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/demo_stats.ipynb This snippet demonstrates calculating the KAST% statistic using the awpy.stats.kast function. It requires the parsed demo object and accepts an optional trade_length_in_seconds argument to define the trade window. ```python from awpy.stats import kast kast(dem, trade_length_in_seconds=5) ``` -------------------------------- ### Listing Contents of Zipped Awpy Output (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo_cli.ipynb Defines and uses a Python function to list the names of files contained within the zip file generated by the Awpy CLI parser. ```Python import zipfile def list_zip_contents(zip_path: str) -> list[str]: with zipfile.ZipFile(zip_path, "r") as zip_ref: contents = zip_ref.namelist() return contents zip_path = "spirit-vs-natus-vincere-m2-dust2.zip" contents = list_zip_contents(zip_path) for file_name in contents: print(file_name) ``` -------------------------------- ### Footstep Event Data Structure (awpy) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst This snippet illustrates the beginning of the structure for the `.footsteps` property in awpy, which provides details on player footstep events. The table shows key columns including duration, radius, step type, tick, player health, last known place name, player name, and Steam ID. The '...' indicates additional columns may be present. ```none ┌──────────┬────────┬───────┬────────┬───┬───────────────┬────────────────────────┬─────────────┬───────────────────┐ │ duration ┆ radius ┆ step ┆ tick ┆ … ┆ player_health ┆ player_last_place_name ┆ player_name ┆ player_steamid │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ ``` -------------------------------- ### Timing Awpy Visibility Check (Non-Visible Points) (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Uses the %timeit magic command to measure the execution time of the is_visible method when the two points are not visible to each other. This shows that checks for obstructed views are typically faster due to the BVH optimization. ```python %timeit vc.is_visible(t_spawn_pos_1, ct_spawn_pos) ``` -------------------------------- ### Accessing Demo Header Information (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst The `.header` property contains general information about how the demo was recorded, including map details. It is a Python dictionary. ```python { 'allow_clientside_particles': True, 'demo_version_name': 'valve_demo_2', 'client_name': 'SourceTV Demo', 'allow_clientside_entities': True, 'map_name': 'de_mirage', 'demo_version_guid': '8e9d71ab-04a1-4c01-bb61-acfede27c046', 'fullpackets_version': '2', 'server_name': 'BLAST Bounty CS2 Server', 'game_directory': '/home/dathost/cs2_linux/game/csgo', 'demo_file_stamp': 'PBDEMS2\x00', 'addons': '', 'network_protocol': '14059' } ``` -------------------------------- ### Listing Available Awpy Data Artifacts (Bash) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/data.rst This command lists the data artifacts available for the current Awpy patch. It shows which types of data (like map images, nav meshes, or triangles) can be retrieved. ```bash awpy artifacts ``` -------------------------------- ### Timing Awpy Visibility Check (Visible Points) (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/visibility.ipynb Uses the %timeit magic command (common in Jupyter/IPython) to measure the execution time of the is_visible method when the two points are visible to each other. This highlights the performance characteristics of the visibility calculation. ```python %timeit vc.is_visible(t_spawn_pos_1, t_spawn_pos_2) ``` -------------------------------- ### Calculating Player Rating with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/demo_stats.ipynb This snippet shows how to calculate a rating statistic using the awpy.stats.rating function. It takes the parsed demo object as input. The calculation is based on a rating-esque formula, and individual coefficients can be adjusted via arguments. ```python from awpy.stats import rating rating(dem) ``` -------------------------------- ### Accessing and Inspecting Parsed CS2 Demo Events (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/parse_demo.ipynb After a demo has been parsed, this snippet demonstrates how to access the `.events` property, which is a dictionary containing parsed event dataframes. It iterates through each event in the dictionary, printing the event name and the shape (number of rows and columns) of the corresponding Polars dataframe. ```python for event_name, event in dem.events.items(): print(f"{event_name}: {event.shape[0]} rows x {event.shape[1]} columns") ``` -------------------------------- ### Retrieving Awpy Map Triangles for Current Patch (Bash) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/data.rst This command downloads the map triangle data artifact for the current Awpy patch. It retrieves the data from the remote storage and saves it locally in the Awpy directory. ```bash awpy get tris ``` -------------------------------- ### Calculating Average Damage per Round (ADR) with Awpy (Python) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/examples/demo_stats.ipynb This snippet shows how to calculate the Average Damage per Round (ADR) statistic for the parsed demo using the awpy.stats.adr function. It takes the parsed demo object as input. Optional arguments team_dmg and self_dmg control how team and self damage are handled. ```python from awpy.stats import adr adr(dem) ``` -------------------------------- ### Retrieving Awpy Map Triangles for Specific Patch (Bash) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/data.rst This command downloads the map triangle data artifact for a specific Awpy patch, identified by the provided patch number (e.g., 123456789). It allows users to access data from older game versions. ```bash awpy get tris --patch 123456789 ``` -------------------------------- ### Viewing Bomb Events Data Structure (Polars) Source: https://github.com/pnxenopoulos/awpy/blob/main/docs/modules/parser_output.rst The `.bomb` property is a Polars DataFrame that tracks bomb-related events such as pickup, drop, plant, defuse, and detonation, including location and player information. This code block shows a text representation of the DataFrame structure and sample data. ```none ┌────────┬────────┬──────────────┬──────────────┬─────────────┬───────────────────┬────────┬───────────┐ │ tick ┆ event ┆ X ┆ Y ┆ Z ┆ steamid ┆ name ┆ bombsite │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ i32 ┆ str ┆ f32 ┆ f32 ┆ f32 ┆ str ┆ str ┆ str │ ╞════════╪════════╪══════════════╪══════════════╪═════════════╪═══════════════════╪════════╪═══════════╡ │ 4856 ┆ pickup ┆ 1227.36499 ┆ -162.933472 ┆ -165.088745 ┆ 76561198074762801 ┆ m0NESY ┆ null │ │ 4969 ┆ drop ┆ 1134.897705 ┆ 264.215302 ┆ -110.578125 ┆ 76561198074762801 ┆ m0NESY ┆ null │ │ 5010 ┆ pickup ┆ 1021.556702 ┆ 558.786499 ┆ -261.331665 ┆ 76561197982141573 ┆ Snax ┆ null │ │ 7014 ┆ drop ┆ -1893.958374 ┆ 569.304993 ┆ -167.96875 ┆ 76561197982141573 ┆ Snax ┆ null │ │ 7659 ┆ pickup ┆ -1893.958374 ┆ 569.304993 ┆ -167.96875 ┆ 76561197982141573 ┆ Snax ┆ null │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 185501 ┆ defuse ┆ -2011.643555 ┆ 381.830597 ┆ -159.96875 ┆ 76561198012872053 ┆ huNter ┆ BombsiteB │ │ 185949 ┆ pickup ┆ -1987.032227 ┆ 438.601532 ┆ -159.96875 ┆ 76561197961491680 ┆ tabseN ┆ null │ │ 187297 ┆ drop ┆ 1267.311768 ┆ -559.58905 ┆ -163.96875 ┆ 76561197961491680 ┆ tabseN ┆ null │ └────────┴────────┴──────────────┴──────────────┴─────────────┴───────────────────┴────────┴───────────┘ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.