pnxenopoulos / awpy

Python library to parse, analyze and visualize Counter-Strike 2 data
http://www.awpycs.com
MIT License
391 stars 58 forks source link

Bot players causing player_stats() to not work #176

Closed matth2k closed 2 years ago

matth2k commented 2 years ago

111_kappa_matt.zip

Describe the bug I am testing the basic analysis notebook from the repo and I am getting the following error in my terminal. Running parse on a 1 vs bots demo causes parsing error for me. Running parse on an esea demo runs fine for me. I'm hoping the library could gracefully ignore stats affect by bots rather than error'ing out.

  File ".../easylan.py", line 239, in analyzeDemos
    player_stats_json = player_stats(data["gameRounds"])
  File ".../site-packages/awpy/analytics/stats.py", line 156, in player_stats
    player_statistics[k["victimSteamID"]]["firstDeaths"] += 1
KeyError: 0

Include Information to Reproduce Here is the code snippet

            parser = DemoParser(
                demofile=fname,
                demo_id=str(match.getMatchId()) + "_" + match.getHashName(),
                parse_frames=False,
            )
            # Parse the demofile, output results to a dictionary of dataframes.
            print("Parsing " + fname)
            data = parser.parse()
            player_stats_json = player_stats(data["gameRounds"])
$ go version
go version go1.18.3 linux/amd64
$ python3 --version
Python 3.8.10
$ pip show awpy
Name: awpy
Version: 1.1.7

Additional context A demo file is attached above which is causing the issue for me. I think the fact that I am playing against a bot is causing the issue. 111_kappa_matt.zip

JanEricNitschke commented 2 years ago

Just needs a check for k["victimSteamID"] and k["victimSteamID"] in player_statistics.keys() here just like it is done here

pnxenopoulos commented 2 years ago

Thanks guys, updated in 1.1.8. Check out #179 and Discord