Repton 2 tool-assisted speedruns

reminisce about classic bbc micro and acorn electron games here
Related forum: adventures


Post Reply
gfoot
Posts: 134
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Repton 2 tool-assisted speedruns

Post by gfoot »

Last week when I disassembled Repton 2, my main goal was to modify it to support replaying stored control inputs, so that I could make a tool-assisted speedrun. It's gone quite well and I'm pretty happy with the result!

The full 57:07 speedrun is here: https://youtu.be/IVAONhO2jTA

I also uploaded an accelerated version using beebjit's "-fast" option, that's under 20 minutes long but still slow enough that you can mostly see what's going on: https://youtu.be/DCTOojD8AUs

And here's a stupidly fast one using beebjit's Alt-F mode, which compresses the hour-long speedrun into about 45 seconds! https://youtu.be/GJnOMbBNwkI

I tried to be as efficient as I could most of the time, but there are certainly mistakes, and there's always the luck of the draw with the monsters and meteors! If anyone is interested in having a go at making your own speedrun, please let me know and I can share the scripts I used, or at least the modified Repton 2 binary so you can make your own scripts. I'd love to see the inevitable improvements!

Every move is hand-authored apart from copy-and-paste and some cases where I used a function to invert a route so Repton would go there and back automatically. Some of the routes are only really suitable for a TAS like this, and it was interesting experimenting with those; while others are the same routes I use when playing by hand.

To make this work, I had to disassemble (using py8dis) and modify the game code (using vim and xa) to support replaying stored inputs. I also had to make the random number generation more consistent as it was based on 6522 timers. A key constraint I wanted to apply there is that the random seed is reset on each level change, so I can swap levels around without breaking the solution for each level.

The input data is stored in sideways ROM, similar to how I did it last week for Repton 3, but for Repton 2 I've only implemented playback support, not recording; and I used a Python script on a PC to generate the ROM image based on long strings of direction data for each level.

Has anyone applied this technique to other BBC games? It'd be great to hear about. I'm considering whether to do something else next - I thought of Thrust, Exile, or Elite for example.
iainfm
Posts: 461
Joined: Thu Jan 02, 2020 8:31 pm
Location: Dumbarton
Contact:

Re: Repton 2 tool-assisted speedruns

Post by iainfm »

Nice! Love me a speed run! :mrgreen:
User avatar
Diminished
Posts: 755
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 2 tool-assisted speedruns

Post by Diminished »

Hm. Interesting. I have some background in this area, so it's good to see someone taking an interest in running Beeb games.
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
Some of the routes are only really suitable for a TAS like this, and it was interesting experimenting with those
Why was this?
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
I also had to make the random number generation more consistent as it was based on 6522 timers. A key constraint I wanted to apply there is that the random seed is reset on each level change, so I can swap levels around without breaking the solution for each level.
Although modifying games in order to speed run them does have some precedent (in particular I'm thinking of the script that is installed as standard by Quake runners, which IIRC is used to simplify the timing process by automatically counting frames), it is nearly always done in such a way that gameplay isn't affected. There does exist a class of techniques in speed running known as "RNG manipulation", but they involve constraining RNG state purely using in-band input (e.g. by waiting for an in-game event that is triggered by a particular known RNG value, thereby leaking the state), rather than by modifying the game.
gfoot
Posts: 134
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Re: Repton 2 tool-assisted speedruns

Post by gfoot »

Diminished wrote:
Thu Sep 23, 2021 1:08 pm
Hm. Interesting. I have some background in this area, so it's good to see someone taking an interest in running Beeb games.
Oh cool, what sort of things have you done like this?
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
Some of the routes are only really suitable for a TAS like this, and it was interesting experimenting with those
Why was this?
Just because the timing is so tight, e.g. at the start of level 4 here: https://youtu.be/IVAONhO2jTA?t=1380 we go all the way along the top, and just about get there in time to collect the diamond before the spirits arrive. It's a case where a different meteor pattern could make it impossible, so not a reliable route in general. If the random seed was different I might have to go a different way.
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
I also had to make the random number generation more consistent as it was based on 6522 timers. A key constraint I wanted to apply there is that the random seed is reset on each level change, so I can swap levels around without breaking the solution for each level.
Although modifying games in order to speed run them does have some precedent (in particular I'm thinking of the script that is installed as standard by Quake runners, which IIRC is used to simplify the timing process by automatically counting frames), it is nearly always done in such a way that gameplay isn't affected. There does exist a class of techniques in speed running known as "RNG manipulation", but they involve constraining RNG state purely using in-band input (e.g. by waiting for an in-game event that is triggered by a particular known RNG value, thereby leaking the state), rather than by modifying the game.
Repton 2 out of the box didn't support any form of recorded input playback, so it was necessary at least to add that, and it can only work if the RNG produces the same numbers every time. Games like Doom and Quake already had consistent RNGs and a built in input playback system.

You could try to make an AI controller that dynamically adapts to whatever random numbers do occur on its run, but that's quite a different endeavour. I know that's been done for games like Mario, but I don't think it's the norm is it?
6502
Posts: 46
Joined: Sat Mar 17, 2018 1:04 pm
Location: London
Contact:

Re: Repton 2 tool-assisted speedruns

Post by 6502 »

This is interesting. If all randomness was removed from the game, starting from a known state everytime and a counter added to count the number of Repton walk moves, perhaps we could have a forum competition who could finish the game in the least amount of moves possible.
User avatar
Diminished
Posts: 755
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 2 tool-assisted speedruns

Post by Diminished »

gfoot wrote:
Thu Sep 23, 2021 1:55 pm
Diminished wrote:
Thu Sep 23, 2021 1:08 pm
Hm. Interesting. I have some background in this area, so it's good to see someone taking an interest in running Beeb games.
Oh cool, what sort of things have you done like this?
I would prefer to keep quiet about the details -- I don't have any involvement with those communities any more, and I try to compartmentalise my online existences these days. The modern Internet is bonkers.
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
gfoot wrote:
Wed Sep 22, 2021 10:35 pm
I also had to make the random number generation more consistent as it was based on 6522 timers. A key constraint I wanted to apply there is that the random seed is reset on each level change, so I can swap levels around without breaking the solution for each level.
Although modifying games in order to speed run them does have some precedent (in particular I'm thinking of the script that is installed as standard by Quake runners, which IIRC is used to simplify the timing process by automatically counting frames), it is nearly always done in such a way that gameplay isn't affected. There does exist a class of techniques in speed running known as "RNG manipulation", but they involve constraining RNG state purely using in-band input (e.g. by waiting for an in-game event that is triggered by a particular known RNG value, thereby leaking the state), rather than by modifying the game.
Repton 2 out of the box didn't support any form of recorded input playback, so it was necessary at least to add that, and it can only work if the RNG produces the same numbers every time. Games like Doom and Quake already had consistent RNGs and a built in input playback system.

You could try to make an AI controller that dynamically adapts to whatever random numbers do occur on its run, but that's quite a different endeavour. I know that's been done for games like Mario, but I don't think it's the norm is it?
Ah, traditionally, TASes are done at the emulator level -- you have an unmodified game, but use frame-granular input record and playback support in the emulator -- then it just becomes a question of playing back a custom input stream. This is probably a bit more straightforward for the ROM-based console systems. I'm fairly certain none of the Beeb emulators have this capability at this stage, so modding the game to do this was fair enough. I think Chris was talking about adding input record and playback support to beebjit at some point, but I'm not sure.
gfoot
Posts: 134
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Re: Repton 2 tool-assisted speedruns

Post by gfoot »

Diminished wrote:
Thu Sep 23, 2021 5:30 pm
Ah, traditionally, TASes are done at the emulator level -- you have an unmodified game, but use frame-granular input record and playback support in the emulator -- then it just becomes a question of playing back a custom input stream. This is probably a bit more straightforward for the ROM-based console systems. I'm fairly certain none of the Beeb emulators have this capability at this stage, so modding the game to do this was fair enough. I think Chris was talking about adding input record and playback support to beebjit at some point, but I'm not sure.
Ah ok, I was only aware of Doom ones really.

I did consider that kind of thing, but really wanted something that could run on a real Beeb.
User avatar
Diminished
Posts: 755
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 2 tool-assisted speedruns

Post by Diminished »

gfoot wrote:
Thu Sep 23, 2021 5:45 pm
Diminished wrote:
Thu Sep 23, 2021 5:30 pm
Ah, traditionally, TASes are done at the emulator level -- you have an unmodified game, but use frame-granular input record and playback support in the emulator -- then it just becomes a question of playing back a custom input stream. This is probably a bit more straightforward for the ROM-based console systems. I'm fairly certain none of the Beeb emulators have this capability at this stage, so modding the game to do this was fair enough. I think Chris was talking about adding input record and playback support to beebjit at some point, but I'm not sure.
Ah ok, I was only aware of Doom ones really.

I did consider that kind of thing, but really wanted something that could run on a real Beeb.
Well, this has actually been done for the NES!

Little bit more complicated for the Beeb, though ...
tom_seddon
Posts: 486
Joined: Tue Aug 30, 2005 12:42 am
Contact:

Re: Repton 2 tool-assisted speedruns

Post by tom_seddon »

gfoot wrote:
Wed Sep 22, 2021 10:35 pm
Has anyone applied this technique to other BBC games? It'd be great to hear about. I'm considering whether to do something else next - I thought of Thrust, Exile, or Elite for example.
Using an early version of b2's timeline functionality, I came up with this video of a playthrough of Thrust: https://www.youtube.com/watch?v=GlevFyQvD9k (took about an hour as I recall, with much use of save states)

I also tried to produce something similar for Ghouls, but got stuck on one of the later levels. (It was just too hard! I tried my best with b2's input latency, but it still feels like Ghouls really requires real hardware and a CRT display.)

One of my goals with b2 has always been to create something that would facilitate producing a YouTube-friendly video of a full playthrough of something meaty such as Exile, Elite, one of the Reptons, or similar. It still isn't good enough yet - at the very least, it's missing the ability to save timelines and states to disk for later reloading, allowing you to chip away at things over time - but one day I'll get there...

--Tom
User avatar
TobyLobster
Posts: 162
Joined: Sat Aug 31, 2019 7:58 am
Contact:

Re: Repton 2 tool-assisted speedruns

Post by TobyLobster »

Similarly I hacked b2 to play back inputs from a text file to verify that my Jet Set Willy 2021 was completable. https://youtu.be/KHj33IzaPYc
Post Reply

Return to “8-bit acorn software: classic games”