fork/slippc
git clone https://git.julia.blue/fork/slippc
30c55ad
0.6.1
1#include "analyzer.h" 2 3//Debug output convenience macros 4#define DOUT1 (s ) if (_debug >= 1) { std::cout << s; } 5#define DOUT2 (s ) if (_debug >= 2) { std::cout << s; } 6 7namespace slip { 8 9Analyzer ::Analyzer (int debug_level ) { 10_debug = debug_level ; 11} 12 13Analyzer ::~Analyzer () { 14//Nothing to do yet 15} 16 17bool Analyzer ::get1v1Ports (const SlippiReplay & s ,Analysis * a )const { 18unsigned num_players = 0 ; 19for (uint8_t i = 0 ;i < 4 ;++ i ) { 20if (s .player [i ].player_type != 3 ) { 21if (num_players == 2 ) { 22return false; 23 } 24a -> ap [num_players ++ ].port = i ; 25 } 26if (i == 3 && num_players != 2 ) { 27return false; 28 } 29 } 30DOUT1 ("Players found on ports " <<a -> ap [0 ].port <<" and " <<a -> ap [1 ].port << std::endl ); 31return true; 32} 33 34void Analyzer ::computeAirtime (const SlippiReplay & s ,Analysis * a )const { 35for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 36SlippiPlayer p = s .player [a -> ap [pi ].port ]; 37unsigned airframes = 0 ; 38for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 39airframes += p .frame [f ].airborne ; 40 } 41 42a -> ap [pi ].air_frames = airframes ; 43// float aircount = 100*((float)airframes / s.last_frame); 44// std::cout << " Airborne for " << aircount << "% of match" << std::endl; 45 } 46} 47 48void Analyzer ::getBasicGameInfo (const SlippiReplay & s ,Analysis * a )const { 49a -> slippi_version = s .slippi_version ; 50a -> parser_version = s .parser_version ; 51a -> analyzer_version = ANALYZER_VERSION ; 52a -> game_time = s .start_time ; 53a -> game_length = s .frame_count ; 54a -> ap [0 ].tag_player = s .player [a -> ap [0 ].port ].tag ; 55a -> ap [1 ].tag_player = s .player [a -> ap [1 ].port ].tag ; 56a -> ap [0 ].tag_css = s .player [a -> ap [0 ].port ].tag_css ; 57a -> ap [1 ].tag_css = s .player [a -> ap [1 ].port ].tag_css ; 58a -> ap [0 ].tag_code = s .player [a -> ap [0 ].port ].tag_code ; 59a -> ap [1 ].tag_code = s .player [a -> ap [1 ].port ].tag_code ; 60 61a -> ap [0 ].start_stocks = s .player [a -> ap [0 ].port ].start_stocks ; 62a -> ap [1 ].start_stocks = s .player [a -> ap [1 ].port ].start_stocks ; 63a -> ap [0 ].color = s .player [a -> ap [0 ].port ].color ; 64a -> ap [1 ].color = s .player [a -> ap [1 ].port ].color ; 65a -> ap [0 ].team_id = s .player [a -> ap [0 ].port ].team_id ; 66a -> ap [1 ].team_id = s .player [a -> ap [1 ].port ].team_id ; 67a -> ap [0 ].player_type = s .player [a -> ap [0 ].port ].player_type ; 68a -> ap [1 ].player_type = s .player [a -> ap [1 ].port ].player_type ; 69a -> ap [0 ].cpu_level = s .player [a -> ap [0 ].port ].cpu_level ; 70a -> ap [1 ].cpu_level = s .player [a -> ap [1 ].port ].cpu_level ; 71 72a -> ap [0 ].end_stocks = s .player [a -> ap [0 ].port ].end_stocks ; 73a -> ap [1 ].end_stocks = s .player [a -> ap [1 ].port ].end_stocks ; 74a -> ap [0 ].end_pct = s .player [a -> ap [0 ].port ].frame [s .frame_count - 1 ].percent_pre ; 75a -> ap [1 ].end_pct = s .player [a -> ap [1 ].port ].frame [s .frame_count - 1 ].percent_pre ; 76a -> ap [0 ].char_id = s .player [a -> ap [0 ].port ].ext_char_id ; 77a -> ap [1 ].char_id = s .player [a -> ap [1 ].port ].ext_char_id ; 78a -> stage_id = s .stage ; 79a -> ap [0 ].char_name = CharExt ::name [a -> ap [0 ].char_id ]; 80a -> ap [1 ].char_name = CharExt ::name [a -> ap [1 ].char_id ]; 81a -> stage_name = Stage ::name [s .stage ]; 82a -> winner_port = s .winner_id ; 83} 84 85void Analyzer ::summarizeInteractions (const SlippiReplay & s ,Analysis * a )const { 86// std::cout << " Summarizing player interactions" << std::endl; 87for (unsigned f = (PLAYABLE_FRAME - LOAD_FRAME );f < s .frame_count ;++ f ) { 88unsigned d = a -> dynamics [f ]; 89++ (a -> ap [0 ].dyn_counts [d ]);//Increase the counter for dynamics across all frames 90if (d > Dynamic ::DEFENSIVE && d < Dynamic ::OFFENSIVE ) { 91//Index is the same for the 2nd player for neutral dynamics 92++ (a -> ap [1 ].dyn_counts [d ]); 93 }else { 94//Index is inverted for the 2nd player for non-neutral dynamics 95++ (a -> ap [1 ].dyn_counts [Dynamic ::__LAST - d ]); 96 } 97 } 98// std::cout << std::fixed; //Show floats in fixed representation 99// for (unsigned p = 0; p < 2; ++p) { 100// // std::cout << " From the perspective of port " << int(a->ap[p].port+1) << " (" << a->ap[p].char_name << "):" << std::endl; 101// for (unsigned i = 0; i < Dynamic::__LAST; ++i) { 102// std::string n = std::to_string(a->ap[p].dyn_counts[i]); 103// std::string pct = std::to_string((100*float(a->ap[p].dyn_counts[i])/s.frame_count)).substr(0,5); 104// std::cout << " " << SPACE[6-n.length()] << n << " frames (" << pct 105// << "% of game) spent in " << Dynamic::name[i] << std::endl; 106// } 107// } 108} 109 110void Analyzer ::countLCancels (const SlippiReplay & s ,Analysis * a )const { 111for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 112SlippiPlayer p = s .player [a -> ap [pi ].port ]; 113unsigned cancels_hit = 0 ; 114unsigned cancels_miss = 0 ; 115unsigned last_state = 0 ; 116for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 117if (last_state == 0 ) { 118if (p .frame [f ].l_cancel == 1 ) { 119cancels_hit += 1 ; 120 }else if (p .frame [f ].l_cancel == 2 ) { 121cancels_miss += 1 ; 122 } 123 } 124last_state = p .frame [f ].l_cancel ; 125 } 126 127a -> ap [pi ].l_cancels_hit = cancels_hit ; 128a -> ap [pi ].l_cancels_missed = cancels_miss ; 129float cancels_pct = 100 * ((float )cancels_hit / (cancels_hit + cancels_miss )); 130// std::cout << " Hit " << cancels_hit << "/" << cancels_hit+cancels_miss << " l cancels (" << cancels_pct << "%)" << std::endl; 131 } 132} 133 134void Analyzer ::countButtons (const SlippiReplay & s ,Analysis * a )const { 135for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 136SlippiPlayer p = s .player [a -> ap [pi ].port ]; 137uint16_t last_buttons = 0 ; 138float last_ax = 0 ; 139float last_ay = 0 ; 140float last_cx = 0 ; 141float last_cy = 0 ; 142for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 143// Add buttons pressed this frame to button count 144uint16_t cur_buttons = p .frame [f ].buttons ; 145uint16_t new_buttons = cur_buttons & (cur_buttons ^last_buttons ); 146new_buttons &=0x0F70 ;//Mask out unused bits 147a -> ap [pi ].button_count += countBits (new_buttons ); 148last_buttons = cur_buttons ; 149 150// Check analog stick for movement 151float cur_ax = p .frame [f ].joy_x ; 152float cur_ay = p .frame [f ].joy_y ; 153a -> ap [pi ].astick_count += checkStickMovement (cur_ax ,cur_ay ,last_ax ,last_ay ); 154last_ax = cur_ax ; 155last_ay = cur_ay ; 156 157// Check C stick for movement 158float cur_cx = p .frame [f ].c_x ; 159float cur_cy = p .frame [f ].c_y ; 160a -> ap [pi ].cstick_count += checkStickMovement (cur_cx ,cur_cy ,last_cx ,last_cy ); 161last_cx = cur_cx ; 162last_cy = cur_cy ; 163 } 164 } 165} 166 167void Analyzer ::countTechs (const SlippiReplay & s ,Analysis * a )const { 168for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 169SlippiPlayer p = s .player [a -> ap [pi ].port ]; 170unsigned techs_hit = 0 ; 171unsigned walltechs_hit = 0 ;//And ceiling techs 172unsigned walljumps_hit = 0 ; 173unsigned walljumptechs_hit = 0 ; 174unsigned techs_missed = 0 ; 175bool teching = false; 176 177for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 178if (inTechState (p .frame [f ])) { 179if (notteching ) { 180teching = true; 181if (p .frame [f ].action_pre <=Action ::DownSpotD ) { 182++ techs_missed ; 183 }else if (p .frame [f ].action_pre <=Action ::PassiveStandB ) { 184++ techs_hit ; 185 }else if (p .frame [f ].action_pre == Action ::PassiveWallJump ) { 186if (inDamagedState (p .frame [f - 1 ])|| inTumble (p .frame [f - 1 ])) { 187++ walljumptechs_hit ; 188 }else { 189++ walljumps_hit ; 190 } 191 }else { 192++ walltechs_hit ;//Or ceiling techs 193 } 194 } 195 }else { 196teching = false; 197 } 198 } 199 200a -> ap [pi ].techs = techs_hit ; 201a -> ap [pi ].walltechs = walltechs_hit ; 202a -> ap [pi ].walljumps = walljumps_hit ; 203a -> ap [pi ].walltechjumps = walljumptechs_hit ; 204a -> ap [pi ].missed_techs = techs_missed ; 205 206// std::cout << " Hit " << techs_hit << " grounded techs" << std::endl; 207// std::cout << " Hit " << walltechs_hit << " wall techs" << std::endl; 208// std::cout << " Hit " << walljumps_hit << " wall jumps" << std::endl; 209// std::cout << " Hit " << walljumptechs_hit << " wall jump techs" << std::endl; 210// std::cout << " Missed " << techs_missed << " techs" << std::endl; 211 } 212} 213 214void Analyzer ::countDashdances (const SlippiReplay & s ,Analysis * a )const { 215for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 216SlippiPlayer p = s .player [a -> ap [pi ].port ]; 217unsigned dashdances = 0 ; 218for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 219if (isDashdancing (p ,f )) { 220++ dashdances ; 221 } 222 } 223 224a -> ap [pi ].dashdances = dashdances ; 225// std::cout << " Dashdanced " << dashdances << " times" << std::endl; 226 } 227} 228 229//Code adapted from Fizzi's 230void Analyzer ::countAirdodgesAndWavelands (const SlippiReplay & s ,Analysis * a )const { 231for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 232SlippiPlayer p = s .player [a -> ap [pi ].port ]; 233unsigned airdodges = 0 ; 234unsigned wavelands = 0 ; 235unsigned wavedashes = 0 ; 236bool airdodging = false; 237for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 238if (maybeWavelanding (p ,f )) {//Waveland detection by Fizzi 239//Look at the last 8 frames (including this one) re Fizzi 240bool foundAirdodge = false; 241bool foundJumpsquat = false; 242bool foundOther = false; 243for (unsigned i = 1 ;i < 8 ;++ i ) { 244if (isAirdodging (p .frame [f - i ])) { 245foundAirdodge = true; 246 }else if (isInJumpsquat (p .frame [f - i ])) { 247foundJumpsquat = true; 248break ; 249 }else { 250foundOther = true; 251 } 252 } 253if (foundAirdodge ) { 254if ((notfoundJumpsquat )&& (notfoundOther )) { 255continue ;//If the airdodge is the only animation we found, proceed 256 }else { 257-- airdodges ;//Otherwise, subtract it from our airdodge count and keep checkings 258 } 259 } 260if (foundJumpsquat ) {//If we were in jumpsquat at all recently, we're wavedashing 261++ wavedashes ; 262 }else if (foundOther ) {//If we were in any other animation besides airdodge, it's a waveland 263++ wavelands ; 264 }//Otherwise, nothing special happened 265 }else if (isAirdodging (p .frame [f ])) { 266if (notairdodging ) { 267++ airdodges ; 268airdodging = true; 269 } 270 }else { 271airdodging = false; 272 } 273 } 274 275a -> ap [pi ].airdodges = airdodges ; 276a -> ap [pi ].wavelands = wavelands ; 277a -> ap [pi ].wavedashes = wavedashes ; 278// std::cout << " Airdodged " << airdodges << " times" << std::endl; 279// std::cout << " Wavelanded " << wavelands << " times" << std::endl; 280// std::cout << " Wavedashed " << wavedashes << " times" << std::endl; 281 } 282} 283 284void Analyzer ::analyzeInteractions (const SlippiReplay & s ,Analysis * a )const { 285// std::cout << " Analyzing player interactions" << std::endl; 286const SlippiPlayer * p = & (s .player [a -> ap [0 ].port ]); 287const SlippiPlayer * o = & (s .player [a -> ap [1 ].port ]); 288 289unsigned cur_dynamic = Dynamic ::POSITIONING ;// Current dynamic in effect 290 291unsigned oLastInHitsun = 0 ;//Last frame opponent was stuck in hitstun 292unsigned pLastInHitsun = 0 ;//Last frame we were stuck in hitstun 293unsigned oLastGrounded = 0 ;//Last frame opponent touched solid ground 294unsigned pLastGrounded = 0 ;//Last frame we touched solid ground' 295bool oHitThisFrame = false; 296bool pHitThisFrame = false; 297bool oHitLastFrame = false; 298bool pHitLastFrame = false; 299 300//All interactions analyzed from perspective of p (lower port player) 301for (unsigned f = (PLAYABLE_FRAME - LOAD_FRAME );f < s .frame_count ;++ f ) { 302//Important variables for each frame 303SlippiFrame of = o -> frame [f ]; 304SlippiFrame pf = p -> frame [f ]; 305oHitLastFrame = oHitThisFrame ; 306oHitThisFrame = false; 307bool oInHitstun = isInHitstun (of ); 308if (oInHitstun ) { 309oLastInHitsun = f ; 310if (of .percent_post > o -> frame [f - 1 ].percent_post ) { 311oHitThisFrame = true;//Check if opponent was hit this frame by looking at % last frame 312 } 313 } 314pHitLastFrame = pHitThisFrame ; 315pHitThisFrame = false; 316bool pInHitstun = isInHitstun (pf ); 317if (pInHitstun ) { 318pLastInHitsun = f ; 319if (pf .percent_post > p -> frame [f - 1 ].percent_post ) { 320pHitThisFrame = true;//Check if we were hit this frame by looking at % last frame 321 } 322 } 323bool oAirborne = isAirborne (of ); 324if (notoAirborne ) {oLastGrounded = f ; } 325bool pAirborne = isAirborne (pf ); 326if (notpAirborne ) {pLastGrounded = f ; } 327bool oIsGrabbed = isGrabbed (of ); 328bool pIsGrabbed = isGrabbed (pf ); 329bool oOnLedge = isOnLedge (of ); 330bool pOnLedge = isOnLedge (pf ); 331bool oShielding = isShielding (of ); 332bool pShielding = isShielding (pf ); 333bool oInShieldstun = isInShieldstun (of ); 334bool pInShieldstun = isInShieldstun (pf ); 335bool oTeching = inFloorTechState (of ); 336bool pTeching = inFloorTechState (pf ); 337bool oThrown = isThrown (of ); 338bool pThrown = isThrown (pf ); 339bool oHitOffStage = isOffStage (s ,of )&& oInHitstun ;//Check if opponent is in hitstun offstage 340bool pHitOffStage = isOffStage (s ,pf )&& pInHitstun ;//Check if we are in hitstun offstage 341bool oPoked = ((f - oLastInHitsun )< POKE_THRES );//Check if opponent has been poked recently 342bool pPoked = ((f - pLastInHitsun )< POKE_THRES );//Check if we have been poked recently 343 344//If we're airborne and haven't touched the ground since last entering hitstun, we're being punished 345bool oBeingPunished = oAirborne && (oLastGrounded < oLastInHitsun ); 346bool pBeingPunished = pAirborne && (pLastGrounded < pLastInHitsun ); 347 348//If we also haven't been in hitstun for at least SHARK_THRES frames, we're being sharked 349bool oBeingSharked = oBeingPunished && ((f - oLastInHitsun )> SHARK_THRES ); 350bool pBeingSharked = pBeingPunished && ((f - pLastInHitsun )> SHARK_THRES ); 351 352//Determine whether neutral would be considered footsies or positioning 353// unsigned neut_dyn = ( oPoked || pPoked ) ? Dynamic::POKING 354// : ((playerDistance(pf,of) > FOOTSIE_THRES) ? Dynamic::POSITIONING : Dynamic::FOOTSIES); 355unsigned neut_dyn = ((playerDistance (pf ,of )> FOOTSIE_THRES ) ?Dynamic ::POSITIONING :Dynamic ::FOOTSIES ); 356 357//First few checks are largely agnostic to cur_dynamic 358if (isDead (of )|| isDead (pf )) { 359cur_dynamic = Dynamic ::POSITIONING ; 360 }else if (oHitOffStage && cur_dynamic != Dynamic ::RECOVERING ) {//If the opponent is offstage and in hitstun, they're being [possibly reverse] edgeguarded 361cur_dynamic = Dynamic ::EDGEGUARDING ; 362 }else if (pHitOffStage && cur_dynamic != Dynamic ::EDGEGUARDING ) {//If we're offstage and in hitstun, we're being [possibly reverse] edgeguarded 363cur_dynamic = Dynamic ::RECOVERING ; 364 }else if (oIsGrabbed ) {//If we grab the opponent in neutral, it's pressure; on offense, it's a techchase 365if (cur_dynamic != Dynamic ::PRESSURING ) {//Need this to prevent grabs from overwriting themselves 366cur_dynamic = (cur_dynamic >=Dynamic ::OFFENSIVE ) ?Dynamic ::TECHCHASING :Dynamic ::PRESSURING ; 367 } 368 }else if (pIsGrabbed ) {//If we are grabbed by the opponent in neutral, we're pressured; on defense, we're techchased 369if (cur_dynamic != Dynamic ::PRESSURED ) {//Need this to prevent grabs from overwriting themselves 370cur_dynamic = (cur_dynamic <=Dynamic ::DEFENSIVE ) ?Dynamic ::ESCAPING :Dynamic ::PRESSURED ; 371 } 372 }else if (oInShieldstun ) {//If our opponent is in shieldstun, we are pressureing 373cur_dynamic = Dynamic ::PRESSURING ; 374 }else if (pInShieldstun ) {//If we are in shieldstun, we are pressured 375cur_dynamic = Dynamic ::PRESSURED ; 376 }else if (oTeching ) {//If opponent is teching, we are techchasing 377cur_dynamic = Dynamic ::TECHCHASING ; 378 }else if (pTeching ) {//If we are teching, we are escaping a techchase 379cur_dynamic = Dynamic ::ESCAPING ; 380 }else if (oInHitstun && pInHitstun ) {//If we're both in hitstun and neither of us are offstage, it's a trade 381// cur_dynamic = Dynamic::TRADING; 382cur_dynamic = Dynamic ::POKING ;//Update 2019-11-05: trading is no longer a used dynamic; now just poking 383 }else {//Everything else depends on the cur_dynamic 384switch (cur_dynamic ) { 385case Dynamic ::PRESSURING : 386if (oHitLastFrame && notoIsGrabbed ) {//If opponent was actually hit last frame by a non pummel, we're punishing 387cur_dynamic = Dynamic ::PUNISHING ; 388 }else if (oThrown ) {//If the opponent is being thrown, this is a techchase opportunity 389cur_dynamic = Dynamic ::TECHCHASING ; 390 }else if ((notoInHitstun )&& (notoShielding )&& (notoOnLedge )&& (notoAirborne )) {//If the opponent touches the ground w/o shielding, we're back to neutral 391cur_dynamic = neut_dyn ; 392 } 393break ; 394case Dynamic ::PRESSURED : 395if (pHitLastFrame && notpIsGrabbed ) {//If we were actually hit last frame by a non pummel, we're being punishied 396cur_dynamic = Dynamic ::PUNISHED ; 397 }else if (pThrown ) {//If we are being thrown, opponent has a techchase opportunity 398cur_dynamic = Dynamic ::ESCAPING ; 399 }else if ((notpInHitstun )&& (notpShielding )&& (notpOnLedge )&& (notpAirborne )) {//If we touch the ground w/o shielding, we're back to neutral 400cur_dynamic = neut_dyn ; 401 } 402break ; 403case Dynamic ::EDGEGUARDING : 404if (oOnLedge || (notoAirborne && notoPoked )) {//If they make it back, we're back to neutral 405cur_dynamic = neut_dyn ; 406 } 407break ; 408case Dynamic ::RECOVERING : 409if (pOnLedge || (notpAirborne && notpPoked )) {//If we make it back, we're back to neutral 410cur_dynamic = neut_dyn ; 411 } 412break ; 413case Dynamic ::TECHCHASING : 414if (oHitLastFrame && (notoTeching )&& oAirborne ) { 415cur_dynamic = Dynamic ::PUNISHING ;//If we started comboing an opponent after the techchase, it's a punish 416 }else if ((notoInHitstun )&& (notoIsGrabbed )&& (notoThrown )&& (notoTeching )&& (notoShielding )) { 417cur_dynamic = oAirborne ?Dynamic ::SHARKING :neut_dyn ;//If the opponent escaped our tech chase, back to neutral it is 418 } 419break ; 420case Dynamic ::ESCAPING : 421if (pHitLastFrame && (notpTeching )&& pAirborne ) { 422cur_dynamic = Dynamic ::PUNISHED ;//If we started comboing an opponent after the techchase, it's a punish 423 }else if ((notpInHitstun )&& (notpIsGrabbed )&& (notpThrown )&& (notpTeching )&& (notpShielding )) { 424cur_dynamic = pAirborne ?Dynamic ::GROUNDING :neut_dyn ;//If we escaped our opponent's tech chase, back to neutral it is 425 } 426break ; 427case Dynamic ::PUNISHING : 428if (oBeingSharked ) {//If we let too much hitstun elapse, but our opponent is still airborne, we're sharking 429cur_dynamic = Dynamic ::SHARKING ; 430 }else if ((notoAirborne )&& (notoPoked )) {//If our opponent has outright landed, we're back to neutral 431cur_dynamic = neut_dyn ; 432 } 433break ; 434case Dynamic ::PUNISHED : 435if (pBeingSharked ) {//If we survive punishes long enough, but are still airborne, we're being sharked 436cur_dynamic = Dynamic ::GROUNDING ; 437 }else if ((notpAirborne )&& (notpPoked )) {//If we have outright landed, we're back to neutral 438cur_dynamic = neut_dyn ; 439 } 440break ; 441case Dynamic ::SHARKING : 442if (oHitLastFrame ) { 443cur_dynamic = Dynamic ::PUNISHING ;//If we hit our opponent LAST frame, we're comboing again 444 }else if (pInHitstun ) {//If our opponent hits us while sharking, we're back to poking 445cur_dynamic = Dynamic ::POKING ; 446 }else if (notoAirborne ) {//If our opponent has outright landed, we're back to neutral 447cur_dynamic = neut_dyn ; 448 } 449break ; 450case Dynamic ::GROUNDING : 451if (pHitLastFrame ) { 452cur_dynamic = Dynamic ::PUNISHED ;//If our opponent hit us LAST frame, we're being comboed again 453 }else if (oInHitstun ) {//If we hit our opponent while grounding, we're back to poking 454cur_dynamic = Dynamic ::POKING ; 455 }else if (notpAirborne ) {//If we have outright landed, we're back to neutral 456cur_dynamic = neut_dyn ; 457 } 458break ; 459case Dynamic ::POKING : 460if (oPoked && oHitThisFrame ) { 461cur_dynamic = Dynamic ::PUNISHING ;//If we have poked our opponent recently and hit them again, we're punishing 462 }else if (pPoked && pHitThisFrame ) { 463cur_dynamic = Dynamic ::PUNISHED ;//If we have been poked recently and got hit again, we're being punished 464 }else if (oBeingSharked && notpPoked ) { 465cur_dynamic = Dynamic ::SHARKING ;//If we'd otherwise be considered as punishing, we're sharking 466 }else if (pBeingSharked && notoPoked ) { 467cur_dynamic = Dynamic ::GROUNDING ;//If we'd otherwise be considered as being punished, we're being sharked 468 }else { 469cur_dynamic = (oPoked || pPoked ) ?Dynamic ::POKING :neut_dyn ;//We're in neutral if nobody has been hit recently 470 } 471break ; 472case Dynamic ::POSITIONING : 473case Dynamic ::FOOTSIES : 474case Dynamic ::TRADING : 475if (oBeingSharked ) { 476cur_dynamic = Dynamic ::SHARKING ;//If we are sharking, update accordingly 477 }else if (pBeingSharked ) { 478cur_dynamic = Dynamic ::GROUNDING ;//If we are being sharked, update accordingly 479 }else { 480cur_dynamic = (oPoked || pPoked ) ?Dynamic ::POKING :neut_dyn ;//If we were trading before, we're in neutral now that we're no longer trading 481 } 482break ; 483default : 484break ; 485 } 486 } 487 488//Aggregate results 489a -> dynamics [f ]= cur_dynamic ;//Set the dynamic for this frame to the current dynamic computed 490DOUT1 (" " <<f <<" (" <<frameAsTimer (f ,s .timer ) <<") P1 " 491 <<Dynamic ::name [cur_dynamic ] <<" " 492 << std::endl ); 493 } 494 495} 496 497void Analyzer ::analyzePunishes (const SlippiReplay & s ,Analysis * a )const { 498const SlippiPlayer * p = & (s .player [a -> ap [0 ].port ]); 499const SlippiPlayer * o = & (s .player [a -> ap [1 ].port ]); 500unsigned pa = 0 ;//Running tally of player attacks 501unsigned oa = 0 ;//Running tally of opponent attacks 502unsigned pn = 0 ;//Running tally of player punishes 503unsigned on = 0 ;//Running tally of opponent punishes 504unsigned oLastInHitsun = 0 ; 505unsigned pLastInHitsun = 0 ; 506unsigned cur_dyn = a -> dynamics [FIRST_FRAME ]; 507unsigned last_dyn = a -> dynamics [FIRST_FRAME ]; 508Punish * pPunishes = a -> ap [0 ].punishes ; 509Punish * oPunishes = a -> ap [1 ].punishes ; 510Attack * pAttacks = a -> ap [0 ].attacks ; 511Attack * oAttacks = a -> ap [1 ].attacks ; 512 513for (unsigned f = FIRST_FRAME ;f < s .frame_count ;++ f ) { 514SlippiFrame pf = p -> frame [f ]; 515SlippiFrame of = o -> frame [f ]; 516cur_dyn = a -> dynamics [f ]; 517 518oLastInHitsun = isInHitstun (o -> frame [f ]) ?f :oLastInHitsun ; 519pLastInHitsun = isInHitstun (p -> frame [f ]) ?f :pLastInHitsun ; 520bool oPoked = ((f - oLastInHitsun )< POKE_THRES );//Check if opponent has been poked recently 521bool pPoked = ((f - pLastInHitsun )< POKE_THRES );//Check if we have been poked recently 522 523//Check if we counter-attacked (switched from defense to offense or vice versa) 524if (cur_dyn <=Dynamic ::DEFENSIVE && last_dyn >=Dynamic ::OFFENSIVE ) { 525++ a -> ap [1 ].counters ;//If we went from offense to defense, we were countered 526 }else if (cur_dyn >=Dynamic ::OFFENSIVE && last_dyn <=Dynamic ::DEFENSIVE ) { 527++ a -> ap [0 ].counters ;//If we went from defense to offense, we countered 528 } 529 530//Check if either player lost a stock 531if (pf .stocks < p -> frame [f - 1 ].stocks ) { 532unsigned ddir = deathDirection (* p ,f ); 533if (oa > 0 ) { 534oAttacks [oa - 1 ].kill_dir = ddir ; 535 } 536if (oPunishes [on ].num_moves > 0 ) { 537oPunishes [on ].kill_dir = ddir ;//TODO: filter out self-destructs somehow 538 }else if (on > 0 ) { 539oPunishes [on - 1 ].kill_dir = ddir ; 540 } 541if (cur_dyn == Dynamic ::EDGEGUARDING ) { 542++ (a -> ap [1 ].reverse_edgeguards ); 543 }else if (cur_dyn != Dynamic ::RECOVERING && ddir != Dir ::UP ) { 544++ (a -> ap [0 ].self_destructs ); 545 } 546 } 547if (of .stocks < o -> frame [f - 1 ].stocks ) { 548unsigned ddir = deathDirection (* o ,f ); 549if (pa > 0 ) { 550pAttacks [pa - 1 ].kill_dir = ddir ; 551 } 552if (pPunishes [pn ].num_moves > 0 ) { 553pPunishes [pn ].kill_dir = ddir ; 554 }else if (pn > 0 ) { 555pPunishes [pn - 1 ].kill_dir = ddir ; 556 } 557if (cur_dyn == Dynamic ::RECOVERING ) { 558++ (a -> ap [0 ].reverse_edgeguards ); 559 }else if (cur_dyn != Dynamic ::EDGEGUARDING && ddir != Dir ::UP ) { 560++ (a -> ap [1 ].self_destructs ); 561 } 562 } 563 564//Check if either player has dropped a punish off an opening 565bool pPunishEnd = false; 566bool oPunishEnd = false; 567if (f == s .frame_count - 1 ) { 568pPunishEnd = true; 569oPunishEnd = true; 570 }else if (cur_dyn != Dynamic ::POKING ) { 571if (cur_dyn > Dynamic ::DEFENSIVE && notpPoked ) { 572//If the opponent had a punish going and they are no longer on offense, end their punish 573oPunishEnd = true; 574 } 575if (cur_dyn < Dynamic ::OFFENSIVE && notoPoked ) { 576//If we had a punish going and we are no longer on offense, end our punish 577pPunishEnd = true; 578 } 579 } 580 581//Update punish counter for ended punishes 582if (pPunishEnd && pa > 0 ) { 583if (pPunishes [pn ].num_moves > 0 ) { 584pPunishes [pn ].end_frame = f ; 585pPunishes [pn ].end_pct = of .percent_pre ; 586pPunishes [pn ].last_move_id = pf .hit_with ; 587if (pPunishes [pn ].num_moves > pAttacks [pa - 1 ].hit_id ) { 588a -> ap [0 ].neutral_wins += 1 ; 589 }else { 590a -> ap [0 ].pokes += 1 ; 591 } 592++ pn ; 593 } 594 } 595if (oPunishEnd && oa > 0 ) { 596if (oPunishes [on ].num_moves > 0 ) { 597oPunishes [on ].end_frame = f ; 598oPunishes [on ].end_pct = pf .percent_pre ; 599oPunishes [on ].last_move_id = of .hit_with ; 600if (oPunishes [on ].num_moves > oAttacks [oa - 1 ].hit_id ) { 601a -> ap [1 ].neutral_wins += 1 ; 602 }else { 603a -> ap [1 ].pokes += 1 ; 604 } 605++ on ; 606 } 607 } 608 609//If the opponent just took damage 610float o_damage_taken = of .percent_pre - o -> frame [f - 1 ].percent_pre ; 611if (o_damage_taken > 0 ) { 612//Check for bubble damage 613pAttacks [pa ].move_id = (isOffscreen (of )&& o_damage_taken == 1 ) ?Move ::BUBBLE :pf .hit_with ; 614//Last frame we actually took damage; frame before that gives us the animation frame our move hit 615pAttacks [pa ].anim_frame = p -> frame [f - 2 ].action_fc ; 616pAttacks [pa ].punish_id = pn ; 617if (//Check if this is a consecutive hit from a multihit move 618pa > 0 && //If this isn't our first move 619pAttacks [pa ].move_id == pAttacks [pa - 1 ].move_id && //If the last move we hit with had the same id 620pAttacks [pa ].anim_frame > pAttacks [pa - 1 ].anim_frame && //If the action frame counter is higher 621//If the gap between animation and game frames is less than max hitlag for the move 622//Formula: https://www.ssbwiki.com/Freeze_frame 623 (f - pAttacks [pa ].anim_frame <= (pAttacks [pa - 1 ].frame - pAttacks [pa - 1 ].anim_frame + (pAttacks [pa - 1 ].damage /3 + 3 )))) { 624pAttacks [pa ].hit_id = pAttacks [pa - 1 ].hit_id + 1 ; 625 }else { 626pAttacks [pa ].hit_id = 1 ; 627 } 628pAttacks [pa ].frame = f ; 629pAttacks [pa ].damage = o_damage_taken ; 630a -> ap [0 ].dyn_damage [cur_dyn ]+= o_damage_taken ;//Dynamic is normal for player 631pAttacks [pa ].opening = cur_dyn ;//Dynamic is normal for player 632pAttacks [pa ].kill_dir = Dir ::NEUT ; 633++ pa ; 634//If this is the start of a combo 635if (pPunishes [pn ].num_moves == 0 ) { 636pPunishes [pn ].start_frame = f ; 637pPunishes [pn ].start_pct = o -> frame [f - 1 ].percent_pre ; 638pPunishes [pn ].kill_dir = Dir ::NEUT ; 639 } 640a -> ap [0 ].damage_dealt += o_damage_taken ; 641pPunishes [pn ].end_frame = f ; 642pPunishes [pn ].end_pct = of .percent_pre ; 643pPunishes [pn ].last_move_id = pf .hit_with ; 644pPunishes [pn ].num_moves += 1 ; 645++ (a -> ap [0 ].move_counts [pf .hit_with ]); 646 } 647 648//If we just took damage 649float p_damage_taken = pf .percent_pre - p -> frame [f - 1 ].percent_pre ; 650if (p_damage_taken > 0 ) { 651//Check for bubble damage 652oAttacks [oa ].move_id = (isOffscreen (pf )&& p_damage_taken == 1 ) ?Move ::BUBBLE :of .hit_with ; 653//Last frame we actually took damage; frame before that gives us the animation frame our move hit 654oAttacks [oa ].anim_frame = o -> frame [f - 2 ].action_fc ; 655oAttacks [oa ].punish_id = on ; 656if (//Check if this is a consecutive hit from a multihit move 657oa > 0 && //If this isn't our first move 658oAttacks [oa ].move_id == oAttacks [oa - 1 ].move_id && //If the last move we hit with had the same id 659oAttacks [oa ].anim_frame > oAttacks [oa - 1 ].anim_frame && //If the action frame counter is higher 660//If the gap between animation and game frames is less than max hitlag for the move 661 (f - oAttacks [oa ].anim_frame <= (oAttacks [oa - 1 ].frame - oAttacks [oa - 1 ].anim_frame + (oAttacks [oa - 1 ].damage /3 + 3 )))) { 662oAttacks [oa ].hit_id = oAttacks [oa - 1 ].hit_id + 1 ; 663 }else { 664oAttacks [oa ].hit_id = 1 ; 665 } 666oAttacks [oa ].frame = f ; 667oAttacks [oa ].damage = p_damage_taken ; 668//Dynamic needs to be flipped around for opponent 669int oDynamic = (cur_dyn > Dynamic ::OFFENSIVE || cur_dyn < Dynamic ::DEFENSIVE ) ?Dynamic ::__LAST - cur_dyn :cur_dyn ; 670a -> ap [1 ].dyn_damage [oDynamic ]+= p_damage_taken ;//Dynamic needs to be flipped around for opponent 671oAttacks [oa ].opening = oDynamic ; 672oAttacks [oa ].kill_dir = Dir ::NEUT ; 673++ oa ; 674//If this is the start of a combo 675if (oPunishes [on ].num_moves == 0 ) { 676oPunishes [on ].start_frame = f ; 677oPunishes [on ].start_pct = p -> frame [f - 1 ].percent_pre ; 678oPunishes [on ].kill_dir = Dir ::NEUT ; 679 } 680a -> ap [1 ].damage_dealt += p_damage_taken ; 681oPunishes [on ].end_frame = f ; 682oPunishes [on ].end_pct = pf .percent_pre ; 683oPunishes [on ].last_move_id = of .hit_with ; 684oPunishes [on ].num_moves += 1 ; 685++ (a -> ap [1 ].move_counts [of .hit_with ]); 686 } 687 688last_dyn = cur_dyn ;//Update the last dynamic 689 } 690} 691 692void Analyzer ::analyzeCancels (const SlippiReplay & s ,Analysis * a )const { 693for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 694const SlippiPlayer * p = & (s .player [a -> ap [pi ].port ]); 695Attack * attacks = a -> ap [pi ].attacks ; 696for (unsigned i = 0 ;attacks [i ].frame > 0 ;++ i ) { 697unsigned f = attacks [i ].frame ; 698if (attacks [i ].move_id >=Move ::NAIR && attacks [i ].move_id <=Move ::DAIR ) { 699unsigned last_frame = attacks [i ].frame + 60 ; 700if (last_frame > s .frame_count ) { 701last_frame = s .frame_count ; 702 } 703for (unsigned f = attacks [i ].frame ;f < last_frame ;++ f ) { 704//Check if we had the opportunity to edge cancel 705if (didEdgeCancelAerial (p -> frame [f ])) { 706attacks [i ].cancel_type = Cancel ::EDGE ; 707break ; 708 } 709//Check if we had the opportunity to teeter cancel 710if (didTeeterCancelAerial (p -> frame [f ])) { 711attacks [i ].cancel_type = Cancel ::TEETER ; 712break ; 713 } 714//Check if we had the opportunity to autocancel 715if (didAutoCancelAerial (p -> frame [f ])) { 716attacks [i ].cancel_type = Cancel ::AUTO ; 717break ; 718 } 719//Check if we had the opportunity to L cancel 720if (p -> frame [f ].l_cancel > 0 ) { 721if (p -> frame [f ].l_cancel == 1 ) { 722attacks [i ].cancel_type = Cancel ::L ; 723 } 724break ; 725 } 726 } 727 } 728 } 729 } 730} 731 732void Analyzer ::analyzeShield (const SlippiReplay & s ,Analysis * a )const { 733for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 734const SlippiPlayer * p = & (s .player [a -> ap [pi ].port ]); 735for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 736float shield_damage = (p -> frame [f ].shield - p -> frame [f - 1 ].shield ); 737if (shield_damage > 0 ) { 738a -> ap [pi ].shield_time += 1 ; 739a -> ap [pi ].shield_damage += shield_damage ; 740if (p -> frame [f ].shield < a -> ap [pi ].shield_lowest ) { 741a -> ap [pi ].shield_lowest = p -> frame [f ].shield ; 742 } 743 } 744 } 745 } 746} 747 748unsigned Analyzer ::countTransitions (const SlippiReplay & s ,Analysis * a ,unsigned pnum ,bool (* cb )(const SlippiFrame & ))const { 749SlippiPlayer p = s .player [a -> ap [pnum ].port ]; 750unsigned counter = 0 ; 751bool active = false; 752for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 753if (cb (p .frame [f ])) { 754if (notactive ) { 755++ counter ; 756active = true; 757 } 758 }else { 759active = false; 760 } 761 } 762return counter ; 763} 764 765unsigned Analyzer ::countTransitions (const SlippiReplay & s ,Analysis * a ,unsigned pnum ,bool (* cb )(const SlippiPlayer & ,const unsigned ))const { 766SlippiPlayer p = s .player [a -> ap [pnum ].port ]; 767unsigned counter = 0 ; 768bool active = false; 769for (unsigned f = (- LOAD_FRAME );f < s .frame_count ;++ f ) { 770if (cb (p ,f )) { 771if (notactive ) { 772++ counter ; 773active = true; 774 } 775 }else { 776active = false; 777 } 778 } 779return counter ; 780} 781 782void Analyzer ::countBasicAnimations (const SlippiReplay & s ,Analysis * a )const { 783for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 784a -> ap [pi ].state_changes = countTransitions (s ,a ,pi ,didActionStateChange ); 785 786a -> ap [pi ].ledge_grabs = countTransitions (s ,a ,pi ,isOnLedge ); 787a -> ap [pi ].rolls = countTransitions (s ,a ,pi ,isRolling ); 788a -> ap [pi ].spotdodges = countTransitions (s ,a ,pi ,isSpotdodging ); 789a -> ap [pi ].powershields = countTransitions (s ,a ,pi ,didPowerShield ); 790a -> ap [pi ].grabs = countTransitions (s ,a ,pi ,isGrabbing ); 791a -> ap [pi ].taunts = countTransitions (s ,a ,pi ,isTaunting ); 792a -> ap [pi ].meteor_cancels = countTransitions (s ,a ,pi ,didMeteorCancel ); 793a -> ap [pi ].hits_blocked = countTransitions (s ,a ,pi ,isInShieldstun ); 794a -> ap [pi ].edge_cancel_aerials = countTransitions (s ,a ,pi ,didEdgeCancelAerial ); 795a -> ap [pi ].edge_cancel_specials = countTransitions (s ,a ,pi ,didEdgeCancelSpecial ); 796a -> ap [pi ].teeter_cancel_aerials = countTransitions (s ,a ,pi ,didTeeterCancelAerial ); 797a -> ap [pi ].teeter_cancel_specials = countTransitions (s ,a ,pi ,didTeeterCancelSpecial ); 798a -> ap [pi ].no_impact_lands = countTransitions (s ,a ,pi ,didNoImpactLand ); 799a -> ap [pi ].shield_drops = countTransitions (s ,a ,pi ,didShieldDrop ); 800a -> ap [pi ].pivots = countTransitions (s ,a ,pi ,didPivot ); 801a -> ap [pi ].short_hops = countTransitions (s ,a ,pi ,didShortHop ); 802a -> ap [pi ].full_hops = countTransitions (s ,a ,pi ,didHop )- a -> ap [pi ].short_hops ; 803 804a -> ap [pi ].shield_breaks = countTransitions (s ,a ,1 - pi ,isShieldBroken ); 805a -> ap [pi ].grab_escapes = countTransitions (s ,a ,1 - pi ,isReleasing ); 806a -> ap [pi ].shield_stabs = countTransitions (s ,a ,1 - pi ,wasShieldStabbed ); 807a -> ap [pi ].stage_spikes = countTransitions (s ,a ,1 - pi ,wasStageSpiked ); 808 } 809} 810 811void Analyzer ::showActionStates (const SlippiReplay & s ,Analysis * a )const { 812const SlippiPlayer * p = & (s .player [a -> ap [0 ].port ]); 813const SlippiPlayer * o = & (s .player [a -> ap [1 ].port ]); 814for (unsigned f = FIRST_FRAME ;f < s .frame_count ;++ f ) { 815SlippiFrame pf = p -> frame [f ]; 816DOUT2 (" " <<f <<" (" <<frameAsTimer (f ,s .timer ) <<") P1 " 817 <<Action ::name [pf .action_pre ] <<" " 818 <<" -> " 819 <<" " <<Action ::name [pf .action_post ] 820 << std::endl ); 821SlippiFrame of = o -> frame [f ]; 822DOUT2 (" " <<f <<" (" <<frameAsTimer (f ,s .timer ) <<") P2 " 823 <<Action ::name [of .action_pre ] <<" " 824 <<" -> " 825 <<" " <<Action ::name [of .action_post ] 826 << std::endl ); 827 } 828} 829 830void Analyzer ::countPhantoms (const SlippiReplay & s ,Analysis * a )const { 831const SlippiPlayer * p = & (s .player [a -> ap [0 ].port ]); 832const SlippiPlayer * o = & (s .player [a -> ap [1 ].port ]); 833for (unsigned f = FIRST_FRAME ;f < s .frame_count ;++ f ) { 834if (wasHitByPhantom (* p ,* o ,f )) { 835++ (a -> ap [1 ].phantom_hits ); 836 } 837if (wasHitByPhantom (* o ,* p ,f )) { 838++ (a -> ap [0 ].phantom_hits ); 839 } 840 } 841} 842 843void Analyzer ::analyzeLedgedashes (const SlippiReplay & s ,Analysis * a )const { 844for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 845const SlippiPlayer * p = & (s .player [a -> ap [pi ].port ]); 846unsigned galint = 0 ; 847bool offledge = false; 848for (unsigned f = FIRST_FRAME ;f < s .frame_count ;++ f ) { 849if (galint > 0 ) { 850-- galint ; 851if (notoffledge ) { 852offledge = didReleaseLedge (* p ,f ); 853continue ; 854 } 855SlippiFrame pf = p -> frame [f ]; 856bool landed = isLanding (p -> frame [f - 1 ])&& (notisLanding (pf ))&& (notisAirborne (pf )); 857if ((didNoImpactLand (pf )|| landed )&& (notisInHitlag (pf ))&& (notisInHitstun (pf ))) { 858if (a -> ap [pi ].max_galint < galint ) { 859a -> ap [pi ].max_galint = galint ; 860 } 861a -> ap [pi ].galint_ledgedashes += 1 ; 862a -> ap [pi ].mean_galint += galint ; 863f += galint ; 864galint = 0 ; 865offledge = false; 866 } 867 } 868if (didCliffCatchEnd (* p ,f )) { 869galint = 30 ; 870if (didReleaseLedge (* p ,f )) { 871offledge = true; 872 } 873 } 874 } 875if (a -> ap [pi ].galint_ledgedashes > 0 ) { 876a -> ap [pi ].mean_galint /=a -> ap [pi ].galint_ledgedashes ; 877 } 878 } 879} 880 881void Analyzer ::computeTrivialInfo (const SlippiReplay & s ,Analysis * a )const { 882for (unsigned pi = 0 ;pi < 2 ;++ pi ) { 883a -> ap [pi ].total_openings = a -> ap [pi ].neutral_wins + a -> ap [pi ].pokes + a -> ap [pi ].counters ; 884if (a -> ap [pi ].total_openings > 0 ) { 885a -> ap [pi ].mean_opening_percent = a -> ap [pi ].damage_dealt /a -> ap [pi ].total_openings ; 886 } 887 888unsigned o_stocks_lost = a -> ap [1 - pi ].start_stocks - a -> ap [1 - pi ].end_stocks ; 889if (o_stocks_lost > 0 ) { 890a -> ap [pi ].mean_kill_openings = float (a -> ap [pi ].total_openings ) /o_stocks_lost ; 891a -> ap [pi ].mean_kill_percent = a -> ap [pi ].damage_dealt /o_stocks_lost ; 892 } 893 894// Get actions per minute 895unsigned total_actions = 896a -> ap [pi ].button_count + a -> ap [pi ].cstick_count + a -> ap [pi ].astick_count ; 897a -> ap [pi ].apm = total_actions * (3600.0f /a -> game_length ); 898// Get action states per minute 899a -> ap [pi ].aspm = a -> ap [pi ].state_changes * (3600.0f /a -> game_length ); 900 } 901} 902 903Analysis * Analyzer ::analyze (const SlippiReplay & s ) { 904DOUT1 ("Analyzing replay" << std::endl ); 905 906Analysis * a = new Analysis (s .frame_count );//Structure for holding the analysis so far 907 908//Verify this is a 1 v 1 match; can't analyze otherwise 909if (notget1v1Ports (s ,a )) { 910 std::cerr <<" Not a two player match; refusing to analyze further" << std::endl ; 911a -> success = false; 912return a ; 913 } 914 915DOUT1 (" Analyzing basic game info" << std::endl ); 916getBasicGameInfo (s ,a ); 917 918//Interaction-level stats 919DOUT1 (" Analyzing player interactions" << std::endl ); 920analyzeInteractions (s ,a ); 921DOUT1 (" Summarizing player interactions" << std::endl ); 922summarizeInteractions (s ,a ); 923DOUT1 (" Analyzing players' punishes" << std::endl ); 924analyzePunishes (s ,a ); 925DOUT1 (" Analyzing players' cancelling techniques" << std::endl ); 926analyzeCancels (s ,a ); 927DOUT1 (" Analyzing players' shielding" << std::endl ); 928analyzeShield (s ,a ); 929DOUT1 (" Analyzing ledgedashes" << std::endl ); 930analyzeLedgedashes (s ,a ); 931 932//Player-level stats 933DOUT1 (" Computing statistics based on animations" << std::endl ); 934countBasicAnimations (s ,a ); 935DOUT1 (" Computing air / ground time for each player" << std::endl ); 936computeAirtime (s ,a ); 937DOUT1 (" Counting l cancels" << std::endl ); 938countLCancels (s ,a ); 939DOUT1 (" Counting techs" << std::endl ); 940countTechs (s ,a ); 941DOUT1 (" Counting dashdances" << std::endl ); 942countDashdances (s ,a ); 943DOUT1 (" Counting airdodges, wavelands, and wavedashes" << std::endl ); 944countAirdodgesAndWavelands (s ,a ); 945DOUT1 (" Counting phantom hits" << std::endl ); 946countPhantoms (s ,a ); 947DOUT1 (" Counting button pushes" << std::endl ); 948countButtons (s ,a ); 949 950DOUT1 (" Computing trivial match info" << std::endl ); 951computeTrivialInfo (s ,a ); 952 953//Debug stuff 954if (_debug >=2 ) { 955DOUT2 (" Showing action states" << std::endl ); 956showActionStates (s ,a ); 957 } 958 959a -> success = true; 960DOUT1 ("Successfully analyzed replay!" << std::endl ); 961return a ; 962} 963 964}