Calculating Counter-Strike 2 Stats
Awpy can also help calculate basic Counter-Strike statistics, such as average damage per round (ADR), kill-assist-survival-trade (KAST%) or Rating.
[3]:
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()
Average Damage per Round (ADR)
Average Damage per Round (ADR) is a common metric to evaluate Counter-Strike players. It is simply the total damage divided by the number of rounds. We can can calculate ADR in Awpy as follows:
[4]:
from awpy.stats import adr
adr(dem)
[4]:
| name | steamid | side | n_rounds | dmg | adr |
|---|---|---|---|---|---|
| str | u64 | str | u32 | i32 | f64 |
| "w0nderful" | 76561199063068840 | "t" | 12 | 671 | 55.916667 |
| "sh1ro" | 76561198081484775 | "ct" | 12 | 1186 | 98.833333 |
| "jL" | 76561198176878303 | "ct" | 10 | 801 | 80.1 |
| "donk" | 76561198386265483 | "t" | 10 | 946 | 94.6 |
| "sh1ro" | 76561198081484775 | "t" | 10 | 1059 | 105.9 |
| … | … | … | … | … | … |
| "jL" | 76561198176878303 | "all" | 22 | 1885 | 85.681818 |
| "Aleksib" | 76561198013243326 | "all" | 22 | 2232 | 101.454545 |
| "donk" | 76561198386265483 | "all" | 22 | 2647 | 120.318182 |
| "chopper" | 76561198045898864 | "all" | 22 | 1208 | 54.909091 |
| "zont1x" | 76561198995880877 | "all" | 22 | 1714 | 77.909091 |
ADR takes two optional arguments, team_dmg (default False), which removes team damage from the overall damage calculation, and self_dmg (default True), which removes any damage the player did to themselves. It is advised to leave these defaults as is in order to match most websites.
Kill, Assist, Survival and Trade % (KAST%)
Another common Counter-Strike statistic is KAST%, or the % of rounds where a player achieves a kill, assist, survives or trades. We can calculate KAST% in Awpy as follows:
[5]:
from awpy.stats import kast
kast(dem, trade_length_in_seconds=5)
[5]:
| name | steamid | side | kast_rounds | n_rounds | kast |
|---|---|---|---|---|---|
| str | u64 | str | u32 | u32 | f64 |
| "chopper" | 76561198045898864 | "all" | 14 | 22 | 63.636364 |
| "donk" | 76561198386265483 | "all" | 18 | 22 | 81.818182 |
| "w0nderful" | 76561199063068840 | "all" | 18 | 22 | 81.818182 |
| "sh1ro" | 76561198081484775 | "all" | 17 | 22 | 77.272727 |
| "jL" | 76561198176878303 | "all" | 15 | 22 | 68.181818 |
| … | … | … | … | … | … |
| "magixx" | 76561199063238565 | "t" | 8 | 10 | 80.0 |
| "w0nderful" | 76561199063068840 | "t" | 11 | 12 | 91.666667 |
| "jL" | 76561198176878303 | "t" | 9 | 12 | 75.0 |
| "zont1x" | 76561198995880877 | "t" | 6 | 10 | 60.0 |
| "chopper" | 76561198045898864 | "t" | 6 | 10 | 60.0 |
KAST takes one argument, trade_length_in_seconds, which specifies the length of a trade time in seconds. The default is 5 seconds.
Rating
HLTV developed Rating and Rating 2.0, which are well-described here and an example is reverse-engineered here. We provide a rating-esque statistic in awpy.stats.rating. You can calculate rating in Awpy as follows:
[6]:
from awpy.stats import rating
rating(dem)
[6]:
| name | steamid | side | n_rounds | impact | rating |
|---|---|---|---|---|---|
| str | u64 | str | u32 | f64 | f64 |
| "chopper" | 76561198045898864 | "all" | 22 | 0.556818 | 0.66615 |
| "donk" | 76561198386265483 | "all" | 22 | 1.931364 | 1.562747 |
| "jL" | 76561198176878303 | "all" | 22 | 1.526364 | 1.231553 |
| "magixx" | 76561199063238565 | "all" | 22 | 1.001364 | 1.185146 |
| "sh1ro" | 76561198081484775 | "all" | 22 | 1.912273 | 1.587677 |
| … | … | … | … | … | … |
| "chopper" | 76561198045898864 | "t" | 10 | 0.568 | 0.7551796 |
| "jL" | 76561198176878303 | "t" | 12 | 1.72 | 1.273859 |
| "iM" | 76561198050250233 | "t" | 12 | 0.51 | 0.51913 |
| "zont1x" | 76561198995880877 | "t" | 10 | 0.397 | 0.5996484 |
| "w0nderful" | 76561199063068840 | "t" | 12 | 0.5475 | 0.7978 |
You can control the individual coefficients as arguments, via kast_coef=..., kills_coef=... and so on.