Stunts Forum

Stunts - the Game => Stunts Related Programs => Topic started by: dreadnaut on May 30, 2014, 11:42:01 AM

Title: Automatic replay analysis
Post by: dreadnaut on May 30, 2014, 11:42:01 AM
Dstien's rpldump gives us the car coordinates; Duplode's annotation language makes it possible to set up section boundaries.

What are we missing? Just something that scans a replay dump and tells us when the car crosses a section line?

Title: Re: Automatic replay analysis
Post by: Duplode on May 31, 2014, 09:45:28 PM
Quote from: dreadnaut on May 30, 2014, 11:42:01 AM
What are we missing? Just something that scans a replay dump and tells us when the car crosses a section line?

Pretty much so. In fact, it would be easy to implement that within Cartography. The lap trace data is ready at hand (https://bitbucket.org/duplode/stunts-cartography/src/ca2637a92ecf6c160931969f81d06e4e3f9047fe/src/Annotation/LapTrace.hs?at=default#cl-35), so all it would take is reading the split specs and writing a [[Split]] -> [TracePoint] -> [FrameIndex] unfold function which runs through the trace and uses a little analytic geometry to detect crossing points (it would take a [[Split]] rather than a [Split] just in case we want to have multi-part splits in tracks with long dual-way sections).
Title: Re: Automatic replay analysis
Post by: dstien on June 01, 2014, 04:59:46 AM
Quote from: dreadnaut on May 30, 2014, 11:42:01 AM
What are we missing? Just something that scans a replay dump and tells us when the car crosses a section line?

For the last section, the most accurate way to determine the finish point is probably to read Stunts' finish frame number at offset 0x146 in the gamestate. I've attached a simple (and barely tested) program that reads the last gamestate entry from a repldump file and prints details similar to those in the highscore screen. Turns out the gamestate provides all we need to return penalty time and finish state (crossed finish line/crashed/aborted) without having to worry about the extra post-finish frames.

$ ./replinfo TST0001.BIN
Driving time : 1:30.80
Penalty time : 0:00.00
Total time   : DNF (crashed)
Avg speed    :  56.45 mph,  90.85 km/h
Top speed    :  77.23 mph, 124.30 km/h
Impact speed :  63.77 mph, 102.62 km/h
Jumps        : 4

$ ./replinfo TST0002.BIN
Driving time : 0:53.75
Penalty time : 3:00.00
Total time   : 3:53.75
Avg speed    :  48.30 mph,  77.73 km/h
Top speed    :  79.86 mph, 128.52 km/h
Jumps        : 0