A deep learning framework for Counter-Strike match data analysis
- Project Overview
- Prediction Tasks
- Quick Start
- Web App Usage
- Web App Features
- Acknowledgements
- Contributors
CS-NET is a Transformer-based deep learning framework for analyzing Counter-Strike 2 match replays (.dem demo files). It parses match recordings, converts game states into token sequences, and uses pre-trained Transformer models for multiple real-time predictions.
In short: given a match replay, the model tells you who will win, who will die, and who is most likely to get the next kill.
| Task | Description | Output |
|---|---|---|
| Win Rate Prediction | Probability of team1 (mapped from CT/T by side) winning the current round | Scalar in [0, 1] |
| Alive Prediction | Per-player probability of surviving the next 5 seconds | One probability per player |
| Next Kill Prediction | Which player is most likely to get the next kill | Probability distribution over 10+1 classes |
| Next Death Prediction | Which player is most likely to die next | Probability distribution over 10+1 classes |
| Duel Prediction | 1v1 win probability for any CT-T player pair | 5x5 probability matrix |
Create a Python environment and install dependencies:
conda create -n cs-net python=3.10
conda activate cs-net
pip install -r requirements.txtDownload all pre-trained models and tokenizers to ./cs-net-models/:
Model weights are also available here: https://huggingface.co/gary2oos/CS-Net-V3
python -m scripts.download_modelProcess a Counter-Strike demo file (.dem) into structured JSON format:
examples/test.dem is intentionally NOT included in this repository because demo files are too large.
You must download a .dem file yourself (for example from HLTV) and replace the input path.
python -m data.process_demo \
-path examples/test.dem \
-interval 0.25 \
-out examples/test.jsonTo reproduce the calibration/evaluation numbers below, download the test shard first:
python -m scripts.download_dataThis script downloads test/shards-00000.tar from Hugging Face and stores it under ./dataset/test/.
You can calibrate the model3.0 heads with:
python -m scripts.train3_t_scaling --dataset_path dataset --device cpuOn the current test shard, the calibration results are:
| Task | T | Before Loss | Before ECE | Before Acc | After Loss | After ECE | After Acc |
|---|---|---|---|---|---|---|---|
| Alive | 1.193158 | 0.431486 | 0.028640 | 0.774641 | 0.429344 | 0.021371 | 0.774641 |
| Duel | 1.146975 | 0.633122 | 0.017835 | 0.632217 | 0.632133 | 0.014517 | 0.632217 |
| Next Death | 1.493995 | 1.785793 | 0.077382 | 0.342485 | 1.741089 | 0.012107 | 0.342485 |
| Next Kill | 1.602551 | 1.801647 | 0.102502 | 0.339024 | 1.736153 | 0.012922 | 0.339024 |
| Win Rate | 1.061342 | 0.467820 | 0.029351 | 0.754566 | 0.467459 | 0.029516 | 0.754566 |
CS-NET now includes an interactive web app for demo analysis and LLM-based post-game summary.
Attribution Notice The built-in 2D viewer is a modified integration of
sparkoo/csgo-2d-demo-viewer. We use the upstream project under the MIT License and adapt it for CS-NET's Flask routes and model-prediction overlays.
python -m demo_analysis.web_appThen open:
http://127.0.0.1:7860
- Upload a .dem file.
- Select the model root directory (normally
cs-net-models/). The web app loads all five prediction heads (alive,nxt_kill,nxt_death,win_rate,duel) from their subdirectories in one go. - Select device (cpu / cuda).
- Click Start Analysis.
- Fill API Key, model name, and Base URL (OpenAI-compatible).
- Choose app language (Chinese / English).
- Click Generate AI Review.
- Bilingual UI and bilingual LLM output (Chinese / English).
- Round-by-round win-rate curve with kill markers.
- Hover-to-inspect player contribution at each timeline point.
- Live 2D radar that syncs with the win-rate curve — player positions, team colour, alive/dead state, and "recently flashed" flag are drawn on the real minimap overview for every tick the cursor touches.
- Per-tick metric panels driven by all four prediction heads: 5-second survival probability, next-kill distribution, next-death distribution, and the full 5×5 CT-vs-T duel matrix.
- Advanced metrics table aggregated across the whole match: per-player average kill/death/survival probability, hard-duel win rate (fights the model thought they would lose), easy-duel win rate (fights they were favoured in), highlight rate, plus a |swing|-sorted ranking of the most impactful kills.
- One-click 2D replay viewer — launches a bundled build of
sparkoo/csgo-2d-demo-viewerin a new tab with the same demo, adding smoke/flash/grenade trajectories and an in-page timeline overlaid with CS-NET's predictions. - Current round final contribution table + full match average contribution table.
- MVP and SVP badges.
- LLM summary supports streaming output and Markdown rendering.
- Auto-save user settings in browser local storage: API Key, model name, base URL, temperature, device, model path, batch size, language.
- Team-side context for LLM: per-round attack/defense roles, first-half/second-half side assignment and half scores.
The bundled 2D replay viewer under demo_analysis/static/viewer/ is a lightly
modified build of the excellent open-source project
sparkoo/csgo-2d-demo-viewer
by Michal Vala, distributed under the MIT License (© 2023 Michal Vala).
All credit for the viewer's parsing, rendering, and UX belongs to the upstream
authors — CS-NET only rewires its asset paths and feeds in the
per-tick predictions from our models. Huge thanks to Michal and the upstream
contributors for making such a polished tool available to the community.
The original upstream license is reproduced verbatim at
demo_analysis/static/viewer/LICENSE
and applies to every file in that directory. If you reuse or redistribute the
viewer portion of this repository, please preserve that notice.