don't click here

Random Levels Project

Discussion in 'Engineering & Reverse Engineering' started by DigitalDuck, Apr 23, 2017.

  1. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    v0.1.1 available, details here

    Original post follows below:

    v0.1: DOWNLOAD
    [youtube]http://www.youtube.com/watch?v=kLrlTXmaoUc[/youtube]

    Controls - as Sonic 1, plus:
    - down+A/B/C while standing: Spindash (Sonic 2)
    - up+A/B/C while standing: Peelout (Sonic CD)
    - up while rolling: unroll
    - down or A/B/C while airborne: curl in air
    - A while paused: regenerate level (only loses progress since last checkpoint)

    ------------

    About S1RL:

    S1RL: Random Levels Project is a hack/mod of Sonic the Hedgehog that allows the game to generate its own levels in real-time. Other changes have been made with this in mind: Sonic's moveset is now tailored for maximum control rather than risk/reward payoffs; acts are much longer than usual; the timer now shows hours, minutes, and seconds, and the time limit has been extended to 24 hours; the life system has been removed entirely, with any death resulting in going back to the previous checkpoint; the camera moves in front of Sonic to reveal more of the level ahead; checkpoints trigger when going past them at any height; and there are multiple palettes to each level that change either with time or with a monitor. There are also numerous other minor cosmetic changes and bugfixes.

    S1RL contains a number of monitors additional or changed from the original game.
    - Static: changes the level palette
    - S: gives both invincibility and speed shoes
    - Eggman: hurts Sonic
    - Sonic: produces a number of rings

    Code added to the game was written in 68k ASM. Data added to the game was first produced by a program written in C#, and then tweaked by hand.

    This is version 0.1. Only Green Hill Zone is playable in this version.

    ------------

    Development backstory:

    The idea for this hack first came about in 2009. I was writing a maze generator and experimenting with tiling patterns and fitting different types of tiles together with different rules, and I wondered if the same could be done with the large chunks in a Sonic game. In 2010 I tried with limited success, getting Sonic 2 generating usually traversable levels in this way in the timespan of ~12 seconds. However, the levels weren't frequently traversable enough, nor was the generation time low enough, for myself to consider it a success. At the time I was also suffering a nasty breakup as well as needing to focus on my Games Computing degree, and the stress of it all left me abandoning it entirely for a while.

    For my Final Year Project I chose to study real-time adaptive track generation in racing games, creating a racing game which dynamically produces a road ahead of the player tailored to their driving style, and writing a dissertation about it, complete with user testing showing its effectiveness. It was successful enough that I was asked to cut down the dissertation into journal paper format and submit it to GAMEON'2012 with help from my supervisor.

    During that time I read a lot about procedural generation, took a thorough look at how other games used it and how well it worked, and began forming new ideas about creating random levels in a Sonic game. Gone was the original tile-based generator, replaced with a strip-based generator instead. Objects could and should be attached to chunks that they're not contained in, and even in entirely different strips, provided it makes sense for them to be there. Strips that are otherwise the same can be duplicated to allow object placements that prevent certain tile placements, making the objects as much part of the level generator as the terrain.

    However, I couldn't work on it in any serious capacity. I was too busy applying for jobs and attending interviews (and not getting the jobs), working with a team and a publisher as my own company to produce a shmup (and getting rejected by the publisher), spiralling into a depression at the first two not going anywhere, getting a new girlfriend, and working on my own mobile games - I still intend to make this professional when I eventually find software I like. I had a few small attempts at it; inspired by Sonic Runners in 2014 I recreated the boss and playstyle, testing the infinite-level concept in S128, along with using strips that were 8 chunks long and tall and attempting to tile them correctly. I also made a quick prototype of S1RL towards the end of 2015 and... it was a massive improvement over my 2010 attempts.

    But after simply not finding any engine up to snuff, I got stuck in a rut again. I still wanted (nay, needed) to code, and the focus shifted back to S1RL. I had no distractions. Studies were over, job well was dry, relationship was stable, and mobile games were going nowhere. So I dug deep into 68k (I'd learned it previously, but only with frequent reference to an instruction list), learnt how the game engine works, which parts needed to change and how, and plugged away at it. I didn't manage to do everything I wanted to, but I'm happy enough with the results to release it now. Of course, I'm going to continue working on it...

    ------------

    How you can help:

    This hack is far from finished, and certainly not bug-free. Reporting anything you feel shouldn't belong is appreciated, even if I've already been made aware of it and it's in the list below. What I find particularly important in this case is identifying any problems with the generated level - perhaps two strips are joined together incorrectly, or perhaps two objects are overlapping when they shouldn't be. Because of the nature of the hack, I will not be able to fix these without a savestate in the affected area and a full description of what's wrong and how it should look.

    Known bugs:
    - Objects respawn after hitting a checkpoint. This is not so much a bug as a workaround; I couldn't figure out the OPL routines, so I chose to have objects consistently respawn rather than unpredictably despawn/respawn/not load in the first place.
    - Checkpoints sometimes load already activated, causing the level beyond to stop loading. I'm not sure what causes this, but regeneration (start+A) usually fixes it.
    - Signposts sometimes load earlier than they should, with corrupted graphics and typically causing death shortly after touching it. Again, I'm not sure what causes this, but regeneration (start+A) usually fixes it.
    - Demo does not lock Sonic's controls and cannot be ended with the start button. (fixed for next release)
    - Dying with speed shoes causes music to stay at the faster speed until more speed shoes are collected.

    ------------

    Credits:

    Original game by SEGA and Sonic Team
    Modified by Digital Duck using the Sonic Retro disassembly with great help from the SCHG How-to guides

    Special thanks to all involved in making the disassembly and guides
     
  2. Devon

    Devon

    Down you're going... down you're going... Tech Member
    1,218
    1,373
    93
    your mom
    After playing for a while, besides the aforementioned bugs, this was the only bug I could find:

     
  3. The Prof

    The Prof

    The Island Professor Member
    107
    0
    16
    Orkney, Scotland
    Sonic 1 Yarmar Edition
    Wow, this is really awesome! I didn't expect object generation to be a part of it, never mind as good as that. The levels generated flowed very nicely, and all the chunks fit together well. I played through it for about 15 minutes and found it to be far better than a novice human's level design, and nearly on par with a journeyman human's level design.

    It wasn't without problems though - there were a lot of bottomless pits where I think an experienced level designer would place an alternate route. I could understand it in a later level, but in the first three levels or so, there ought to be a minimum of (ideally well telegraphed) bottomless pits, in my opinion.

    Certain things tended to repeat quite a lot, for example I ran into a lot of double backwards facing red springs with an upwards facing red spring behind them, and groups of three monitors just sat in the road. I know this is a fairly standard thing with procedural generation, but if it could be minimised it would really help the hack shine.

    The last (and most minor) problem was that object design was occasionally rather unorthodox. I came across quite a few swinging platforms that led to nowhere and ring formations that just didn't belong. This never affected my enjoyment, but made it stick out that the levels were randomly generated.

    Don't let the fact that I've spent longer on cons than pros put you off though. I found this amazing, and one of the best hacks I've played in some time, I just thought you'll appreciate help to improve it more as a dev. If that improvement gets made, then the hack will go from good to great.
     
  4. Brainulator

    Brainulator

    Regular garden-variety member Member
    http://www.youtube.com/watch?v=QBZDeROJEUk

    So far, this looks like an interesting hack. I'll have to try it out.
     
  5. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    Noted, thanks. Normally I'd need a savestate to identify where the problem is, but the breakable wall narrows it down enough for now.

    It's actually very easy to remove bottomless pits; the problem is that it would then reduce the variety of the level even further than it already is.

    Yes, the problem with this is the lack of data. I created 36 acts of Green Hill Zone to use as a basis, but I'd need to do a couple of hundred to get any real variety out of it. I'll see what I can do to solve this problem, though.

    This is something I can fix easily, but it has to be on a case-by-case basis. If you provide savestates of when this happens, I can tweak the data to either remove the swinging platforms or add places for them to go, and fix the ring formations.

    No problem. There's a reason it's only v0.1 :v:
     
  6. steveswede

    steveswede

    Member
    5,032
    1
    16
    Ask my hand
    Fighting against the Unitary State of Europe
    I haven't got anything to say really. Is a thumbs up good enough?

    [​IMG]
     
  7. RetroKoH

    RetroKoH

    Member
    1,662
    22
    18
    Project Sonic 8x16
    I like what I see so far. My biggest takeaway that hasn't been mentioned... you have a nice little thing where the background still goes on while the game is paused. A very small feature, but I like it.
     
  8. The Prof

    The Prof

    The Island Professor Member
    107
    0
    16
    Orkney, Scotland
    Sonic 1 Yarmar Edition
    Presumably the end goal is for the hack to feature 6 zones with three randomly generated acts (if not then feel free to disregard this), so lack of variety won't stand out half as much as it does right now. The original GHZ takes about 2-3 minutes to run through, maybe about 5 if you're quite slow at it. The lack of variety won't stand out in bite-sized chunks like that.

    Speaking of chunks, would making new chunks to allow for new set pieces not be a good way of increasing perceived variety in your level design? The vanilla GHZ chunks are some of the easiest in the game to work with, but they can get repetitive if you're making long levels. It gets a lot worse in zones like Marble and Spring Yard.
     
  9. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    It's a feature the 8-bit version had that I liked. I figured it'd be fun to keep.

    Not quite, but it won't be the same as it is now, no. I'll probably abandon the act system for the most part and just have each zone be one act.

    GHZ has an extra thirty chunks added to it over the original, and I'll be adding more chunks in other zones too.
     
  10. Brainulator

    Brainulator

    Regular garden-variety member Member
    Just a note: once you get into the demos, you won't get out until you reset.
     
  11. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    Huh. You can also partially control Sonic for the brief period he's on-screen, although you can't move him.

    I'll fix that for next time.
     
  12. Brainulator

    Brainulator

    Regular garden-variety member Member
    I did notice that, hehe.

    I have two musical notes (pun not immediately intended, but I'll take it):

    • To make sure, is the invincibility music supposed to be off? I assume yes, but I want to address this elephant in the room.
    • I feel like that with the length of the acts/zones given, it seems to become a very real possibility that you can get tired of the music after a while. Do you think palette changes (time or monitor) could create variation with the music to make the experience less monotone, or perhaps pressing a button while paused can enable or disable music?

    When writing this message, I had a third non-musical note (teehee) in mind, but I forgot it. When I think of it, I'll let you know.

    How come I can't see most images or videos here though?
     
  13. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    Yes and no. It wasn't initially intended, but I kept it in.

    Disabling the music is something I already have planned and half-implemented. I considered the music changing with the time of day, but I don't know how to create music in a format I can use in-game, and it's more effort than I wanted to do for now (my focus was on the level generation). It's something on my to-do list, though.
     
  14. ExecByte

    ExecByte

    Member
    99
    0
    6
    Ohio
    Sonic: The Lost Worlds
    Nice! I remember years ago thinking about randomly generated levels but, never got into 68k asm enough to do it. Also was busy with my hack and haven't had time since. Good to see it being done!
     
  15. If I have to listen to the Green Hill theme again, I'm going to kill myself. I played through the level for 18 straight minutes, with no end in sight. Very interesting concept, but after 18 minutes, it makes me wanna die inside. :v:
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    You could always do what I did for Knuckles' Emerald Hunt: throw in every possible song that fits the level's theme and allow the user to choose between them. You could even take the whole sound system from KEH if you want.

    Besides that, I remember you talking about this back in 2010, and I'm glad to see it being released.
     
  17. So, how much code did it take to put this together? Would it require an entire ROM to itself, or could you potentially create an "Endless Mode" as bonus content in a hack?

    You said that you plan on a later version being put together that does one Act for each Zone. Could you get it to where the player can choose an estimated length for the level? Something like "Normal - 3 min avg, Long - 5 min avg, Very Long - 8 min avg, Extreme - 15 min avg"?

    This is more of a hacking-in-general question, but how many chunks can you have available for a single level to draw from? If creating more chunks would allow more variety in the level, is there any way to make it a group effort, where people can just piece together level chunks (or recreate level chunks from the other games in the correct tileset) and send them to you to insert them? You said that you added thirty new chunks to Green Hill Zone for variety's sake, but having something like fifteen people all compiling level chunks together for you seems like it would drastically speed things up.

    Final question: You said you don't know how to insert music in a format that would let you switch songs mid-level. What about if each palette change warped the current music instead? Like how the speed-up item makes the music play faster, maybe one palette makes the music drop an octave, while another palette slows or speeds the tempo by a certain amount. If the player continuously switches palettes every chance they'd get, they'd eventually get some pretty trippy music.
     
  18. Brainulator

    Brainulator

    Regular garden-variety member Member
    After 50 minutes, I did beat Act 1, if it means anything.
     
  19. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,338
    412
    63
    Lincs, UK
    TurBoa, S1RL
    I'd have to learn how to do that first, but it's an option. I'd prefer to have variations on a theme, but that works too.

    The code for generation itself is fairly short (about 2KB); the data is 24KB for Green Hill Zone alone. So it'll fit comfortably inside a lot of Sonic 1/2 hacks, but you'd struggle to fit it in something like S3K. The other problem is that of RAM. It requires the level and object layout in memory, and some hacks use RAM for other things.

    Already planned. At the moment the three acts are ~30 minutes, 1 hour, and 2 hours (although the endings aren't really the point); I'm keeping these as the upper end and adding options for ~2, 4, 8, and 15 minutes.

    Vanilla Sonic 1 supports 82 chunks; leaving them uncompressed in the ROM frees a lot of RAM and gives you up to 128 chunks. It can probably be easily tweaked to get to 256 chunks but I haven't done that as I haven't needed it. More than 256 chunks would require a pretty significant rewrite.

    Adding new chunks is fairly quick, and making the levels isn't that slow either. The slowest part is piecing the various strips together, which can only be automated so far and then has to be manually checked and fixed.

    I don't know how to do that either. :v:

    I should probably learn the music side of things at some point.
     
  20. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    To be honest, I barely understand how music works either, which is why I had people handle the driver modifications and music making for me.