Thursday, April 21, 2011

Level Gen

Update's not ready, because I'm redoing level generation. Why? Well, I keep ending up with isolated rooms, and that can't happen unintentionally because then you could end up stuck. My old method was just to toss the old level and gen another when that happens. But something I've done with my code rewrites has caused that to happen infinitely.

So, I'm changing how I generate levels. Instead of digging rooms at random and then getting stuck with isolated rooms when a corridor can't be connected to it, I'm going to gen up a definitely-connected line of rooms, and then go back over it with the random corridor code. This should end up with at least one door per room connecting a batch of them, and then extra corridors that connect random rooms.

I'm also learning TADS, and also Inform. Both interactive fiction software. I am done with this semester of classes, though. Since I've learned C# with Adventurer, it is now simply a hobby for me - I'm not getting a vast amount of pageviews or money off of it ($10 so far). If other things interest me, I'm going to do those. If there's a skill I want to learn, like IF writing, I'll do that. But, I still have the "I like making a roguelike" motivation. So I'll keep working on it in my free time. I'm taking the time between updates to rewrite my code to be more rational to work with, rather than kludging everything together into some self-imposed deadline. If you happen to be one of the few people reading this while it's relevant- I know what it's like to see projects peter to a halt and die. Not what's going on here. I'm just shifting to a slower update schedule. Still not going to be the "once every several months" thing I've seen elsewhere. It'll just be on my whim. If you want to help out, you can grab the source code - show me some improved code blocks and I'll incorporate it into the "official" release if you want and I think it looks good. Do keep in mind that I rewrote a lot already. Update should be out soon. And by soon, I mean "about a week".

5 comments:

  1. Under which scenario are you unable to connect two rooms?

    ReplyDelete
  2. The level gen I did before was just "Place x rooms randomly, then corridors randomly between random rooms in random places until everything has at least one corridor attached to it. Whoops, we've tried over 9000 times and it's still not all connected? Toss the whole level and start over." When I did the rewrite, I broke something in my kludged level gen code, and now I'm getting isolated rooms somehow happening endlessly. Because it is possible to stick a room somewhere where the criteria for successful corridor creation just can't connect the odd placement of a room.

    So, in addition to the rewrites of everything else, I'm rewriting level gen. It's so obvious I can't believe I didn't think of it the first time: check for connectability before making the room.

    ReplyDelete
  3. You could start corridor from some point in an existing room and then add room at end of corridor. If overlapping rooms is no problem to you level generator I think that's easiest way.

    ReplyDelete
  4. *If corridors overlapping rooms is not problem...

    ReplyDelete
  5. I tried starting in the middle of the room in my earlier level gen code - the thing is, it ends up "spiderwebbing". You know, like Dwarf Fortress web patterns. It doesn't look very good and causes corridors and rooms to clip together in odd ways. And now that I'm doing doors, it pretty much knocks out that concept.

    What I'm working on now is picking a random room edge, picking a random point in that direction, and making a room there - if it will clash with existing layout, I try another start and end point. That will keep things connected without getting into infinite loops.

    ReplyDelete