Teamfights Extractor¶
Teamfight window detection and per-participant statistics.
gem.extractors.teamfights
¶
Teamfight detection from combat log entries.
Detects teamfights by merging hero death events within a rolling cooldown window, then aggregates per-player stats (damage dealt/taken, healing, gold delta, XP delta, deaths, buybacks, ability/item uses) for each fight.
Algorithm extends the reference implementation with spatial clustering
- A new fight opens on any non-illusion hero death.
start_tick = first_death_tick - cooldown- The fight closes once
cooldownticks elapse with no new hero death, settingend_tick = last_death_tick + cooldown. - When position data is available, concurrent fight windows are tracked.
A new death extends the nearest active window whose centroid is within
_FIGHT_RADIUSworld units; otherwise a new parallel window is opened. This separates simultaneous skirmishes in different parts of the map. - Without position data the algorithm falls back to the original single- window temporal approach (reference-compatible).
- Per-player stats are collected from combat log entries whose tick falls
within
[start_tick, end_tick]. - XP delta is derived from the nearest player snapshots bracketing the window.
No minimum-death filter is applied — all detected fights are returned so that
callers can threshold on Teamfight.deaths or participation count.
refs/parser/src/main/java/opendota/CreateParsedDataBlob.java
processTeamfights() lines 1224–1353
TeamfightPlayer
dataclass
¶
Per-player stats accumulated within one teamfight window.
Attributes:
| Name | Type | Description |
|---|---|---|
player_id |
int
|
Player slot (0–9). |
deaths |
int
|
Hero deaths within the window. |
buybacks |
int
|
Buybacks within the window. |
damage_dealt |
int
|
Damage dealt to enemy heroes (non-illusion). |
damage_taken |
int
|
Damage received from any source within the window. |
healing |
int
|
Healing dealt to allied heroes. |
gold_delta |
int
|
Gold earned within the window. |
xp_delta |
int
|
XP earned within the window (from snapshot diff). |
ability_uses |
dict[str, int]
|
Ability name → use count. |
item_uses |
dict[str, int]
|
Item name → use count. |
Source code in src/gem/extractors/teamfights.py
Teamfight
dataclass
¶
A detected teamfight window with per-player breakdowns.
Attributes:
| Name | Type | Description |
|---|---|---|
start_tick |
int
|
Window open tick (first_death_tick − cooldown). |
end_tick |
int
|
Window close tick (last_death_tick + cooldown). |
last_death_tick |
int
|
Tick of the final hero death in the fight. |
deaths |
int
|
Total hero deaths within the window. |
centroid_x |
float | None
|
Death-count-weighted mean X of all deaths in the window,
or |
centroid_y |
float | None
|
Death-count-weighted mean Y of all deaths in the window,
or |
players |
list[TeamfightPlayer]
|
One |
Source code in src/gem/extractors/teamfights.py
detect_teamfights(combat_log: list[CombatLogEntry], hero_to_slot: dict[str, int] | None = None, player_snapshots: dict[int, list[PlayerStateSnapshot]] | None = None) -> list[Teamfight]
¶
Detect teamfights from a match combat log.
When player_snapshots is provided, spatial clustering is applied in
addition to the temporal cooldown: a death only extends an existing fight
window if it falls within _FIGHT_RADIUS world units of that window's
current centroid. Deaths outside all active windows open a new parallel
window, separating simultaneous skirmishes in different parts of the map.
Without position data the algorithm falls back to the original single- window temporal approach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
combat_log
|
list[CombatLogEntry]
|
All |
required |
hero_to_slot
|
dict[str, int] | None
|
Mapping of NPC hero name → player slot (0–9). Built from
|
None
|
player_snapshots
|
dict[int, list[PlayerStateSnapshot]] | None
|
Optional mapping of |
None
|
Returns:
| Type | Description |
|---|---|
list[Teamfight]
|
List of |
list[Teamfight]
|
filter is applied; callers may filter on |
list[Teamfight]
|
participation count. |
Source code in src/gem/extractors/teamfights.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |