Stunts Forum

Stunts - the Game => Stunts Questions => Topic started by: CTG on February 03, 2005, 03:01:25 AM

Title: Perfect replay editor
Post by: CTG on February 03, 2005, 03:01:25 AM
Once I asked Zak about the possibilty of a program counting the best available replay. He said no - but what if we have the source code? Is there a program being able to produce the perfect replay? Just think it over:

Average length: 80 seconds (1600 units)
3 different buttons can be used in the same time unit (42 combinations)
Possible keyboard combinations in one unit with real meaning: about 20

The program must count 20^1600 possibilities... Okay it is a weak theory with weak maths but I would like to show that it's impossible. Too many possible ways although most of them are nonsense (crashing, driving on the grass, twisting on the road, etc.). Of course we can add some facts to decrease this horrible number (for example rules of useing the transmission, pressing accelerator as long as it's useful, following the road...) but the method seems to me quite impossible.

Do you have any idea? Some of you are really good in maths, programming and informatics - do you think the program can be written and used in reality?
Title: Perfect replay editor
Post by: DieselJoe on February 03, 2005, 01:35:34 PM
Maths? Computer Science? Nothing to do with this! :mrgreen:










:roll:
Title: Perfect replay editor
Post by: zaqrack on February 03, 2005, 01:45:37 PM
since when you are watching a replay, Stunts regenerates the whole physic happenings, collisions, acceleration, jumps, etc, everything, it's impossible to do a separate RPL viewer/editor without the sources of the original stunts physic engine.

if we'd have the sources it'd be not that hard to code an optimized replay searcher/writer, so let's celebrate we dont have the sources.
Title: Perfect replay editor
Post by: HappyWorm on May 08, 2005, 11:40:50 AM
Quote from: "zaqrack"since when you are watching a replay, Stunts regenerates the whole physic happenings, collisions, acceleration, jumps, etc, everything, it's impossible to do a separate RPL viewer/editor without the sources of the original stunts physic engine.

if we'd have the sources it'd be not that hard to code an optimized replay searcher/writer, so let's celebrate we dont have the sources.

well you have at least the possibility to write a wrapper that hooks into the replay-engine  when stunts is loaded to memory and directly passes commands at the engine and fetches the result. of course this would be not very nice but I think it'll work.
second thing would be to reverse-engineer the whole program, first use a decompiler (if I remember correctly stunts was written in Microsoft C 5) and then translate the remaining asm-code per hand - time-consuming but a chance to get the code
Title: Perfect replay editor
Post by: CTG on May 08, 2005, 03:29:37 PM
I'll buy it! ;)
Title: Perfect replay editor
Post by: al il professore on May 08, 2005, 04:34:27 PM
i dont know about you happy worm, who are you? i tried to decompile the sources until it gave asm. its not going anywhere because its compressed. I think you have a lot of good ideas but no pragmatism, like CTG and his stupid replay coding program idea.  :twisted:
Title: Perfect replay editor
Post by: HappyWorm on May 08, 2005, 04:43:36 PM
Quote from: "al il professore"i dont know about you happy worm, who are you?
joined ZakStunts-Competition a few days ago and startet digging through old threads here to get a picture of the community here...

Quote from: "al il professore"i tried to decompile the sources until it gave asm.
in my terms "decompile" means that you reverse the binary back into the plain source-code it was written in - MS-C in this case. Just make asm of it i used to call "disassemble"

Quote from: "al il professore"its not going anywhere because its compressed.
I've just sent any game-executeable through a disasm and it worked without warnings. iirc - it used to complain if code was packed. So either it just missed something or the files are not packed. Could you name the file(s) from which you assume it is packed?

Quote from: "al il professore"CTG and his stupid replay coding program idea.  
what is stupid about that? I would have used an other approach where I don't need the sources but I think in general it should be possible :)
Title: Perfect replay editor
Post by: al il professore on May 08, 2005, 11:28:41 PM
read the code, code yourself, you can create new car shapes modifying any of the .p3s or .pvs files and you can add your own gif animation in any of the opp1 2 3 4 5 6 win lose and pre files. you can also modify the games musics in the .kms files...

but if you can do that you are the stunts messiah.

i think someone with the knowledge could really make useful tools for stunts drivers, but only one with such talent entered the community yet. mark nailwood with trackblaster and carblaster.

then okay, there was alanrotoi with the melange. but the geniuses and even new drivers are so rare those times.
Title: Perfect replay editor
Post by: HappyWorm on May 09, 2005, 12:14:36 AM
I dont't see where talent is needed for to do those things you've described above. The fileformats are all well documented and if they weren't it would just take some hacking to explore them. Afaik in stuntsfiles is nothing encrypted or encoded to complicate reverse-engineering like it was done in Master of Orion 2 for example - I needed nearly a week to completely crack their graphic-libs.

The bot that drives stunts instead of a human being would be surely an interesting project but I'm very short on time these days - so I think I'll have to wait til summer-vacation with that...
Title: Perfect replay editor
Post by: Mingva on May 09, 2005, 09:33:16 AM
I just can say "WOW!"  :)
Title: Re: Perfect replay editor
Post by: Overdrijf on January 24, 2007, 07:03:30 PM
Replay editing... Sounds like it's not going to be the best driver winning...
Title: Re: Perfect replay editor
Post by: Chulk on January 24, 2007, 09:27:15 PM
Quote from: Overdrijf on January 24, 2007, 07:03:30 PM
Replay editing... Sounds like it's not going to be the best driver winning...
I guess you're right. Welcome to the community Overdrijf!
Title: Re: Perfect replay editor
Post by: CTG on January 24, 2007, 10:22:19 PM
And welcome back Chulk! Where were you?
Title: Re: Perfect replay editor
Post by: Krys TOFF on January 24, 2007, 10:32:46 PM
Quote from: CTGAnd welcome back Chulk! Where were you?
He was preparing secretly his asskicking replays for ISM competition and he will send them only the last day of race. :D
Title: Re: Perfect replay editor
Post by: Overdrijf on January 24, 2007, 11:28:17 PM
Quote from: Chulk on January 24, 2007, 09:27:15 PMWelcome to the community Overdrijf!
Thanks for the welcome.
Title: Re: Perfect replay editor
Post by: BonzaiJoe on January 25, 2007, 04:01:01 AM
While replay handling is used all the time, replay editing does not seem to be happening. It's very difficult to use, and there are no clear signs of it happening. But it's not to be excluded...
Title: Re: Perfect replay editor
Post by: CTG on February 20, 2007, 09:09:14 AM
Quote from: BonzaiJoe on January 25, 2007, 04:01:01 AM
While replay handling is used all the time, replay editing does not seem to be happening. It's very difficult to use, and there are no clear signs of it happening. But it's not to be excluded...

I'm working on it for ages... ;D
Title: Re: Perfect replay editor
Post by: Chulk on September 17, 2007, 09:02:27 PM
Maybe CTG finally created replay editor and that's how he won Zakstunts '07  ;D

I'm just kidding, you're a worthy champion!
Title: Re: Perfect replay editor
Post by: CTG on November 27, 2007, 01:42:44 AM
Quote from: Chulk on September 17, 2007, 09:02:27 PM
Maybe CTG finally created replay editor and that's how he won Zakstunts '07  ;D

I'm just kidding, you're a worthy champion!

Sure. ;D
Title: Re: Perfect replay editor
Post by: Chulk on November 27, 2007, 02:45:01 PM
You took some time time to answer that! I think it's due to your very deep analisys of it  ;)
Title: Re: Perfect replay editor
Post by: CTG on November 27, 2007, 02:48:19 PM
Nope but I had to run the perfect answer editor... :D
Title: Re: Perfect replay editor
Post by: Chulk on November 27, 2007, 08:45:30 PM
One thing we know for sure... You created the perfect spamm editor!
Title: Re: Perfect replay editor
Post by: CTG on November 27, 2007, 10:31:48 PM
Quote from: Chulk on November 27, 2007, 08:45:30 PM
One thing we know for sure... You created the perfect spamm editor!

False. I AM the perfect spam editor.
Title: Re: Perfect replay editor
Post by: CTG on December 06, 2012, 01:20:55 AM
Hahaha, Friker made it.
Title: Re: Perfect replay editor
Post by: Friker on December 06, 2012, 01:34:32 AM
Quote from: HappyWorm on May 08, 2005, 11:40:50 AM
Quote from: zaqracksince when you are watching a replay, Stunts regenerates the whole physic happenings, collisions, acceleration, jumps, etc, everything, it's impossible to do a separate RPL viewer/editor without the sources of the original stunts physic engine.

if we'd have the sources it'd be not that hard to code an optimized replay searcher/writer, so let's celebrate we dont have the sources.

well you have at least the possibility to write a wrapper that hooks into the replay-engine  when stunts is loaded to memory and directly passes commands at the engine and fetches the result. of course this would be not very nice but I think it'll work.
second thing would be to reverse-engineer the whole program, first use a decompiler (if I remember correctly stunts was written in Microsoft C 5) and then translate the remaining asm-code per hand - time-consuming but a chance to get the code

ok, you have the code. so what to do now?
replay editor? hex editor is good enough (and still do not make good results)
some tester of bruteforce replays? ha ha
the same but with heuristics? hmm.. these should be really good heuristics to complete a run within a month.
some machine learning? i can imagine to train some situations and then apply it. still it would discard some of the best tricks. but really usable with OWOOT rules! the note: that training has to be huge because of many entrance speeds and many track's pieces combinations to learn.

ok so with the whole engine we could have a machine that makes nearly perfect replays with owoot rules. as long as it does not making money it's good only for ruin a game and probably master thesis. :)

thinking again about the tester with heuristic.. probably, but I don't have any clue.
Title: Re: Perfect replay editor
Post by: BonzaiJoe on December 06, 2012, 02:12:44 AM
How about just simulating all possible keypress sequences and detecting the fastest finished one?

A track of ~1 minute has about 1200 'moments', and about 64 possible keypress combinations for each moment, so that leaves only about 64^1200 possible replays, . So if you pre-set a max-time that you know the perfect replay should be within, you can just run all the simulations, and the perfect replay should be ready an infinite length of time after the end of the universe.
Title: Re: Perfect replay editor
Post by: CTG on December 06, 2012, 02:25:28 AM
Quote from: BonzaiJoe on December 06, 2012, 02:12:44 AM
How about just simulating all possible keypress sequences and detecting the fastest finished one?

A track of ~1 minute has about 1200 'moments', and about 64 possible keypress combinations for each moment, so that leaves only about 64^1200 possible replays, . So if you pre-set a max-time that you know the perfect replay should be within, you can just run all the simulations, and the perfect replay should be ready an infinite length of time after the end of the universe.

Could be simplified a bit: ~20 combinations make sense, usually you press the accelerator and follow the road.

(Even molecule structures can be calculated with a computer - an old DOS game should not mean any problems)
Title: Re: Perfect replay editor
Post by: Friker on December 06, 2012, 02:25:28 AM
Quote from: BonzaiJoe on December 06, 2012, 02:12:44 AM
How about just simulating all possible keypress sequences and detecting the fastest finished one?

A track of ~1 minute has about 1200 'moments', and about 64 possible keypress combinations for each moment, so that leaves only about 64^1200 possible replays, . So if you pre-set a max-time that you know the perfect replay should be within, you can just run all the simulations, and the perfect replay should be ready an infinite length of time after the end of the universe.

Quote from: CTG on February 03, 2005, 03:01:25 AM
Once I asked Zak about the possibilty of a program counting the best available replay. He said no - but what if we have the source code? Is there a program being able to produce the perfect replay? Just think it over:

Average length: 80 seconds (1600 units)
3 different buttons can be used in the same time unit (42 combinations)
Possible keyboard combinations in one unit with real meaning: about 20

The program must count 20^1600 possibilities...

When we are already ensured that a perfect replay is impossible we could start about near-perfect replays. That is what I've done.

Btw player could strike at most 3 keys at a moment but I think all 6 keys could be simulated at once.
Title: Re: Perfect replay editor
Post by: CTG on December 06, 2012, 02:26:43 AM
LOL, our messages were sent in the same second. :D
Title: Re: Perfect replay editor
Post by: Duplode on December 06, 2012, 04:46:50 AM
Quote from: Friker on December 06, 2012, 01:34:32 AM
the same but with heuristics? hmm.. these should be really good heuristics to complete a run within a month.
some machine learning? i can imagine to train some situations and then apply it. still it would discard some of the best tricks. but really usable with OWOOT rules! the note: that training has to be huge because of many entrance speeds and many track's pieces combinations to learn.

ok so with the whole engine we could have a machine that makes nearly perfect replays with owoot rules. as long as it does not making money it's good only for ruin a game and probably master thesis. :)

It boils down to designing a smarter Skid, then. In fact, there is actually some prior art related to that specific issue, though it isn't down the computer science alley (http://www.stunts.hu/stuntsrus/flowersforskid.htm)...
Title: Re: Perfect replay editor
Post by: dstien on December 06, 2012, 10:17:54 AM
Some of the ideas I've had with restunts involves automated replay analysis, which, in addition to aid completely automated competition verification, also could help develop perfect AI using genetic algorithms (http://en.wikipedia.org/wiki/Genetic_algorithm). Unfortunately, none of us have had time to work on restunts in years. :'(
Title: Re: Perfect replay editor
Post by: BonzaiJoe on December 06, 2012, 12:24:18 PM
Quote from: Duplode on December 06, 2012, 04:46:50 AM
Quote from: Friker on December 06, 2012, 01:34:32 AM
the same but with heuristics? hmm.. these should be really good heuristics to complete a run within a month.
some machine learning? i can imagine to train some situations and then apply it. still it would discard some of the best tricks. but really usable with OWOOT rules! the note: that training has to be huge because of many entrance speeds and many track's pieces combinations to learn.

ok so with the whole engine we could have a machine that makes nearly perfect replays with owoot rules. as long as it does not making money it's good only for ruin a game and probably master thesis. :)

It boils down to designing a smarter Skid, then. In fact, there is actually some prior art related to that specific issue, though it isn't down the computer science alley (http://www.stunts.hu/stuntsrus/flowersforskid.htm)...

One of the best events in Stunts culture  ;D
Title: Re: Perfect replay editor
Post by: BonzaiJoe on December 06, 2012, 12:30:32 PM
"but in a nihilist's world there is no "best".  there is only staying home on a cloudy day and lying still on the couch at awkward angles.  in slow motion."

;D
Title: Re: Perfect replay editor
Post by: CTG on December 15, 2012, 10:18:04 AM
Quote from: Friker on December 06, 2012, 02:25:28 AM
Quote from: BonzaiJoe on December 06, 2012, 02:12:44 AM
How about just simulating all possible keypress sequences and detecting the fastest finished one?

A track of ~1 minute has about 1200 'moments', and about 64 possible keypress combinations for each moment, so that leaves only about 64^1200 possible replays, . So if you pre-set a max-time that you know the perfect replay should be within, you can just run all the simulations, and the perfect replay should be ready an infinite length of time after the end of the universe.

Quote from: CTG on February 03, 2005, 03:01:25 AM
Once I asked Zak about the possibilty of a program counting the best available replay. He said no - but what if we have the source code? Is there a program being able to produce the perfect replay? Just think it over:

Average length: 80 seconds (1600 units)
3 different buttons can be used in the same time unit (42 combinations)
Possible keyboard combinations in one unit with real meaning: about 20

The program must count 20^1600 possibilities...

When we are already ensured that a perfect replay is impossible we could start about near-perfect replays. That is what I've done.

Btw player could strike at most 3 keys at a moment but I think all 6 keys could be simulated at once.

Why do I feel that Friker owns that program?
Title: Re: Perfect replay editor
Post by: CTG on November 10, 2014, 09:54:45 AM
The theoretical possibility of creating such a software is a fact. However, the calculation time for a whole replay would be fuckin' long. BUT! What if you take only short, tricky sections to create magic carpets, extreme jumps or simply a perfect 90 degree corner? Usually it's only a 0.5-2 seconds long section and gear switches are quite limited in a certain part of the track (---> less combinations). The buffer parts, such as straight roads do not really require this kind of method - only a few critical sections need that kind of maxout. It would not create a perfect replay, only a perfect trick or corner.

What do we know?
- You know each cars behaviour from .RES files (torque, weight, air drag, etc.).
- You can reproduce your replays in Excel (by knowing the surface parameters) - if you modify some keypress codes in the file, it can regenerate your position on the map. Optimizing requires advanced programming skills.
- You can easily visualize replays, just think on stuntschallenge.

The above mentioned stuff is enough for that - we have some addicts, being able to create something like that. As for me, the software exists. But I don't really care anymore.

(http://2.bp.blogspot.com/-uVqoyM7d0as/UK5o8pbzFOI/AAAAAAAAUEM/KkdYubQ335Y/s320/Don+Quixote+VS+Windmill.jpg)
Title: Re: Perfect replay editor
Post by: Friker on December 17, 2014, 12:40:00 PM
Quote from: CTG on November 10, 2014, 09:54:45 AM
...BUT! What if you take only short, tricky sections to create magic carpets, extreme jumps or simply a perfect 90 degree corner? Usually it's only a 0.5-2 seconds long section and gear switches are quite limited in a certain part of the track (---> less combinations). The buffer parts, such as straight roads do not really require this kind of method - only a few critical sections need that kind of maxout. It would not create a perfect replay, only a perfect trick or corner. ...

This is a way I was thinking about. But you will need a measure which can compare which replay is better than others. And that is quite hard with magic carpets.. Perfectly cut corners/loops could be possible.