CoolFace
Apppublic

thenuke02/cs2-analyzer

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
App README

![CI](https://github.com/nukethe02/cs2-analyzer/actions/workflows/ci.yml)

OpenSight

Professional CS2 Analytics Platform — Leetify-quality metrics for every demo type.

OpenSight is a CS2 analytics platform that delivers professional-grade match analysis. Supports Valve MM, FACEIT, ESEA, HLTV, scrims, and POV demos. AI-powered coaching, opponent scouting, and progress tracking.

Features

  • Demo Analysis: Parse CS2 .dem files and extract tick-level game data
  • Share Code Decoding: Decode match share codes to extract metadata
  • Replay Watching: Monitor your replays folder for automatic processing
  • Professional Metrics:
  • Time to Damage (TTD): Latency between spotting an enemy and dealing damage
  • Crosshair Placement (CP): Angular distance between aim and target position
  • Kill/Death statistics, headshot percentage, damage per round

Installation

bash
# Clone the repository
git clone https://github.com/nukethe02/cs2-analyzer.git
cd cs2-analyzer

# Install with pip
pip install -e .

# Or install with development dependencies
pip install -e ".[dev]"

Requirements

  • Python 3.11+
  • demoparser2 - Rust-backed parser for CS2 demos
  • awpy - Geometric calculations (optional, for advanced visibility checks)

Quick Start

Analyze a Demo

bash
# Basic analysis
opensight analyze /path/to/demo.dem

# Filter to specific player
opensight analyze /path/to/demo.dem --player "PlayerName"

# Export results to JSON
opensight analyze /path/to/demo.dem --output results.json

# Calculate specific metrics only
opensight analyze /path/to/demo.dem --metrics ttd

Decode a Share Code

bash
opensight decode "CSGO-xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"

Watch for New Replays

bash
# Watch default CS2 replays folder
opensight watch

# Watch custom folder
opensight watch --folder /path/to/replays

# Watch without auto-analysis
opensight watch --no-analyze

Check Environment

bash
opensight info

Python API

python
from opensight import DemoParser, calculate_ttd, calculate_crosshair_placement

# Parse a demo
parser = DemoParser("/path/to/demo.dem")
data = parser.parse()

print(f"Map: {data.map_name}")
print(f"Duration: {data.duration_seconds:.1f}s")

# Calculate metrics
ttd_results = calculate_ttd(data)
for steam_id, ttd in ttd_results.items():
    print(f"{ttd.player_name}: {ttd.mean_ttd_ms:.0f}ms average TTD")

cp_results = calculate_crosshair_placement(data)
for steam_id, cp in cp_results.items():
    print(f"{cp.player_name}: {cp.placement_score:.1f} placement score")

Watch for Replays Programmatically

python
from opensight import ReplayWatcher, DemoParser

watcher = ReplayWatcher()

@watcher.on_new_demo
def handle_demo(event):
    print(f"New demo: {event.file_path}")
    parser = DemoParser(event.file_path)
    data = parser.parse()
    # Process...

watcher.start(blocking=True)

Decode Share Codes

python
from opensight import decode_sharecode

info = decode_sharecode("CSGO-xxxxx-xxxxx-xxxxx-xxxxx-xxxxx")
print(f"Match ID: {info.match_id}")
print(f"Outcome ID: {info.outcome_id}")

Architecture

src/opensight/
├── api/              # FastAPI web app (13 files: 11 route modules + shared.py + __init__.py)
├── analysis/         # Metrics engine (17 files: analytics.py, models.py, compute_*.py, hltv_rating.py, ...)
├── pipeline/         # Demo orchestration (orchestrator.py, stat_serializer.py, team_resolver.py)
├── core/             # Parser, constants, utils, map zones
├── ai/               # Claude-powered coaching, strategy, scouting (11 modules)
├── auth/             # JWT + Steam OpenID authentication
├── scouting/         # Opponent scouting engine
├── infra/            # Cache, database, job store
├── visualization/    # Heatmaps, exports, replay, share cards
├── domains/          # Combat, economy, synergy, utility analytics
├── integrations/     # HLTV, Steam, feedback
├── static/           # Web UI (4 HTML, 20 CSS, 27 JS files)
├── cli.py            # Typer CLI
└── server.py         # Uvicorn entry point

98 API endpoints + 5 HTML page routes = 103 total. 1,673 tests, 0 failures.

Metrics Explained

Time to Damage (TTD)

Measures the latency between first seeing an enemy and dealing damage. Lower values indicate faster reactions and better aim.

Calculation: For each damage event, trace back through tick data to find when the attacker first had line-of-sight to the victim, then compute the time difference.

Crosshair Placement (CP)

Measures how well a player keeps their crosshair positioned near potential enemy locations. Lower angles indicate better placement.

Calculation: At regular intervals, compute the angle between the player's view direction and the direction to the nearest visible enemy. The placement score is derived from the mean angle using exponential decay.

Development

bash
# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check src/

# Type checking
mypy src/

How It Works

OpenSight supports all CS2 demo types:

  1. 1.Universal Demo Support: Valve MM, FACEIT, ESEA, HLTV, scrims, and POV demos — no API restrictions.
  1. 1.AI Coaching: Claude-powered round-by-round coaching, tactical analysis, and opponent scouting.
  1. 1.Full Metric Suite: HLTV 2.0 Rating, TTD, Crosshair Placement, KAST, trades, clutches, utility rating, and more.

License

Proprietary - All Rights Reserved. See LICENSE for details.

Acknowledgments