Lachlan's misadventures in games programming

Showing posts with label Level design. Show all posts
Showing posts with label Level design. Show all posts

Monday, 26 September 2016

Golf, The RPG: Procedurally Generating a Golf Course

9/26/2016 09:46:00 pm Posted by Lachlan , , No comments

Introduction

So – I’ve been working on a game in spare time for a while, that (as always) may or may not end up amounting to much. But, I’ve done some interesting work that I’d really like to share – such that anybody with an interest in procedural generation or programming might be able to glean some insights.

The game I’ve been working on has (thus far) been called Golf, The RPG. It is intended on being a top down, roguelike inspired, procedural , Golf RPG with interactive fiction elements. The idea is that I want a golf game where the shots are chosen by the player,  but the success the shot is determined by the skill of the golfer as opposed to a player-dexterity game like most conventional golf video games. The second idea is that when I personally golf, I care more about the time I spend talking to the people I’m playing with then the golfing itself – and I wanted to try to incorporate that into a game.

The part that this series of articles is going to be about is the process of procedurally generating a golf course. Bit of the approach might change and be refined as the game is developed - but you can see some of the thinking of how it happened.

This is the first of what will be hopefully 5 articles, appearing sporadically throughout the next fortnight.


Procedural generation - A Brief Introduction

So - what exactly is Procedural generation? If you've already got a good idea, this is the chunk to skip.

Procedural generation is getting the computer to do some of the creative work that a human would normally do in a conventional game. Sometimes, procedural generation is used for small bits of a game - such as some of the textures, or some of the sound. Sometimes it is used for level design. Sometimes, it's used as the basis of the entire game (such as No Man's Sky - which recently brought procedural generation to the limelight).

Rogue: The classic game, with procedural dungeons
My interest in procedural generation started with ADOM - a Roguelike game. Roguelikes are a genre of game, usually defined by procedural generation of levels, and permanent death. The procedural generation of levels means the game can stay interesting for a long time - because you can always keep exploring and finding new things, or face new challenges.

Atlas Warriors: My less classic game with procedural dungeons, and procedural fire animations!

Procedural generation generally works as a set of rules that the computer has to follow to generate a level. In Atlas Warriors (above), generally speaking, rooms are placed next to other rooms if they fit, and door ways are randomly added. Groups of enemies are added, in such a quantity to be about as difficult as the player should be able to handle at that level. A couple of enemies are forced to appear - such as the [spoiler] near the end, and finally the [spoiler].

The Chase: My other less classic game with procedural level generation!
In The Chase (above), trees are randomly placed in such a way that a player can always walk past those trees, with a gap guaranteed somewhere near the gap in the previous column of trees. 

Obviously - the universe generation in No Man's Sky is way more complicated, but you can see the basics of how it might work.

Let's Build A Golf Course!

I've taken lots of shortcuts. My golf course generation algorithm in no way replicates the thought process of an actual human golf course designer. Instead, I looked at the output I wanted to get, and thought through the process of how I might get something that was similar.

The end results

So you can see where we're getting to - below are some examples of the kinda of courses that I'm able to generate.

A procedural golf course.


Yup. That's a golf course. Some dangerous water though.

Guess What: It's a golf course!

The Broad Process

Broadly speaking, this is how Golf, The RPG generates a golf course:

  1. Plant some vegetation
  2. Lay the basic shape of some holes over the course
  3. Figure out the order of the holes
  4. Fit some water in, if possible
  5. Do the low level detail of the holes

Step 1. Planting Vegetation

Planting vegetation is a super simple step. I'm even willing to share the entire source code for it. (But... it should be noted... it's entirely possible I'll share the rest of the source later anyway)


        // Start with rough
        for (int ix = 0; ix < c.Width(); ++ix)
        {
            for (int iy = 0; iy < c.Height(); ++iy)
            {
                c.SetTile(ix, iy, 2);
            }
        }

        // Put some basic fawna around
        // We'll get this into a configuration option
        for (int ix = 0; ix < c.Width(); ++ix)
        {
            for (int iy = 0; iy < c.Height(); ++iy)
            {
                // 50/50 chance of some fawna
                if (randf() < 0.5)
                {
                    char fawna_type = 0;
                    switch (randi(0, 4))
                    {
                    case 0:
                        fawna_type = VEGETATION;
                        break;
                    case 1:
                        fawna_type = ROUGH_SHRUB;
                        break;
                    case 2:
                        fawna_type = ROUGH_TREE;
                        break;
                    case 3:
                        fawna_type = BIG_TREE;
                        break;
                    case 4:
                        fawna_type = SMALL_TREE;
                        break;
                    }
                    c.SetTile(ix, iy, fawna_type);
                }
            }

If you don't read C++, it's pretty simple: Place some rough everywhere, and then randomly place vegetation, shrubs, trees, bigger trees and smaller trees. That's it. We're starting with an unmolested block of empty land: Just a like a real golf course!

So - we've so far got the whole level looking something like:

Next

Next article - I'll be looking at how I do the broad layout of the holes.

Thursday, 8 December 2011

Mighty Ascension of Jack Finished Design?

12/08/2011 12:39:00 am Posted by Lachlan , No comments
I think I've finished the design of the Mighty Ascension of Jack (the final level), though won't know for sure until it is made and playable. Furthermore, this is the last level that I will be designing for now unless any bolts of inspiration hit me, and my efforts now will be focussed on making these levels playable - including sound, graphics and most of all, programming. My design efforts will be largely limited to tweaking the design to better work with the code

The Mighty Ascension finishes now with a squish area with stop signs for timing, a small but elegant teleporter puzzle, a small life and a final subtle teleport. I don't know whether this will be fun or not, but I hope so. The whole bloomin thing, the level that is in scale, about 5 levels worth of level is reprinted below.



Monday, 5 December 2011

The Mighty Ascension of Jack

12/05/2011 11:03:00 pm Posted by Lachlan , No comments
Current status of the Mighty Ascension of Jack (Final Level)
I'm still working on the final level. You can see my latest work sitting on the top above the top red line.

I struggle with puzzle design... Maybe one or two parts to be added - but I do actually like the top bit.

Lets see what happens

Tuesday, 29 November 2011

The Mighty Ascension of Jack

11/29/2011 12:16:00 am Posted by Lachlan , No comments
The Final Level So Far
I'm still working on the final level. I've started working on the next stage. I had a pretty cool idea of what I wanted, but I don't think that I have quite got what I wanted, and that it may not be as much fun as I'd like it to be at the moment.

I think I might need to redo it. I'll see if I can improve it more a bit later.

Sunday, 27 November 2011

The Mighty Ascension of Jack

11/27/2011 02:09:00 am Posted by Lachlan , No comments
Part of (the only designed part of) "The Mighty Ascension of Jack"
I'm playing with the idea of making a big final level for my "Jack is a Fool" thing. Now - it's still my intention that what I release will be only about half an hour long, and only a fairly short game from which I can figure out whether its fun, and probably release it as freeware. It won't have graphics that it would if I turned it into a longer commercial indie game. But anyway. I digress.

Big final level. Portal has a phenomenal final level. In it, you use all the puzzle solving techniques you've used throughout the rest of the game to be able to finish a big epic amalgamation of the puzzles. Something nice and final. I think the idea of ascending to the surface in Portal 2 is brilliant too, and feels good. So - I've been thinking of combining the few styles of puzzles I'm using into one big final level that will have hopefully interlinked puzzles, a couple of checkpoints and something that will hopefully feel like a satisfactory finish even if the game is somewhat short.

So far, I've designed the grand total of what you can see above. In reality, it's about a third of the length as I'd like it to be, and currently has about 3 puzzles in it - linked by the big lift in the middle. I think, once I've finished designing it (at least to some level I'm remotely happy with), I'll call my "designs before programming" a day, and start working towards making them work.

Tuesday, 15 November 2011

Teleporting Levels

11/15/2011 06:54:00 pm Posted by Lachlan No comments
I've been experimenting with an idea for a new mechanic - even though I haven't really done that much with the 'Stop' one. But I got bored with it - so we'll add more as inspiration strikes. My new puzzle mechanic is teleporters. You can see how they will work below:
The idea is that when he's in a teleporter, you'll see a 'ghost' of where he would come out. You push the button, and he will teleport to the other side, in the same direction and speed he went in as if nothing happened - just at a different place. So far, I've designed one Introduction to Mechanic level ("For science. You monster."), one easier puzzle ("Teleprompter") and a very suddenly more difficult level (I think) ("Tower of eternal telefrags"). I may do some more of them.

For science. You monster.

Teleprompter

Tower of eternal telefrags.

A notable limitation is that none of these levels incorporate any of the mechanics (other then being squashed) from earlier levels. I'm going to try to do a couple that particularly combine stop signs and teleporters. I also think that there needs to be a bit gentler of a transition to Tower of eternal telefrags - so adding another level there.

By my (admittedly baseless) estimate, the level designs will have about 21m of Gameplay time. When I actually program them, we'll see whether my estimates are close or way off. I'll probably stop the designing of levels (at least as my primary goal) when I reach about 30m - it should be long enough to discover whether it is fun or not. Either way, I should possibly avoid adding more mechanics, and see if I can make do with the 3 I already have. Though a fourth would be nice....


Count:
9 Actual Puzzles
3 Simple "Introduction to mechanic puzzles"
12 Total
None of them actually work in engine yet - all just designs.


Update 7:48PM
I've come up with a level that is a bit easier, and uses elements from all three groups of level - it's below. It uses bits of other levels just a bit. I think I need a couple more of these

Monday, 14 November 2011

2 New Levels

11/14/2011 07:43:00 pm Posted by Lachlan , No comments
First new level

Second new level
I've got two new level plans done. The first will work, the second may or may not be finishable; I'll verify in the next day or so. Which does mean one thing: I'm back on. Friday featured my last exam for the semester, so now I actually have some time to attempt to get the prototype of Jack out.

So - I'm back to trying to design enough puzzles to make me happy enough to make a prototype. Problem is - I have no idea how hard they will actually be to play. I know I'm struggling designing them as I have no experience in Puzzle design before.

We'll see.

Count:
7 Actual Puzzles
2 Simple "Introduction to mechanic puzzles"
9 Total
None of them actually work in engine yet - all just designs.

Tuesday, 27 September 2011

Super Mario Bros: How Nintendo taught players the mechanics without a tutorial in Worlds 1-1 to 1-3.

9/27/2011 01:55:00 am Posted by Lachlan , , 1 comment

After some excellent company watching Flying High! and MASH (the movie), as well as excellent pizza from Gary at International Pizza in Montmorency, I set my mind at playing some of Super Mario Bros on the NES... or an emulated version thereof at any rate. During which, I learnt a few things:

  1.  Don't try to take screenshots through Nestopia with filters enabled. I had the NTSC filter for some old style scaling and colour bleed, but it ended up really squashed and odd
  2. Nintendo games rightfully deserve their reputation for difficulty. But, I made it to the end of the second world without losing a single life, and to the castle in the third world before losing the game. Fun fact: I've been spoiled by the SNES 'Super Mario Bros All Stars' versions of these games. I was expecting to start at the start of the world. Second Fun Fact: You don't. Also - I think the physics are noticeably different between All Stars and the original.
  3. The first few levels are brilliant game design.
I'm going to focus on Point #2. If what you want is difficulty, look at SMB 'The Lost Levels' or Super Meat Boy - I'm not in the mood to discuss it. And not good enough at platformers to discuss it anyway.

Super Mario Bros. has no tutorial. It has never needed one. I would, of course assume that it came with a manual - but even that (as you will soon bare witness) is not even required. I will clarify that the controls were made more intuitive by the fact that the control consisted solely of a D-Pad (The plus shaped thing with arrows on it for you non-gamer sorts), a select button, a start button, an A button and a B button. Controls weren't difficult to remember or even simply figure out. But they were improved by excellent early level design.

I'm going to demonstrate to you that the game teaches you how to play it, by playing it through the first few levels (particularly just World 1), and expose to you some of the brilliance. I'd like to forewarn that tutorial means teaches you how to play the game - not how to play it well.

World 1-1

This is about the first thing the player sees. He either runs into the Goomba and dies - and learns he can't run into the Goomba, or he successfully jumps over it. He'll usually in the process hit one of the ? blocks, and see coins come out with little numbers. You see the points go up, you see coins go up, you've been rewarded and you know that ? blocks can be rewarding.
So, you move forward, and find another couple of ? blocks, and the first has a Mushroom in it! Note how the location of the pipe means that the mushroom comes back to you, and that you actually require effort to avoid the mushroom. doesn't just fall off the screen. The Mushroom makes you bigger, at you'll probably figure out that you can now break the   Bricks.

You come across more pipes. You may figure out you can go down select pipes, you may not. I don't have a copy of the manual to check whether it hinted it or not. There is no indicator - and the first pipe doesn't let you so... brilliance has its exceptions. Or, we just take it as an old fashioned secret.

More Goomba's after returning from the secret area...

There's a staircase, and the flag. The flag moves to wherever you hit the pole which provides some feedback that higher is better. And the design of the level (staircase) hints that you should try to hit the top too.

World 1-2
A hint that something is different. At least it clearly takes control of Mario from the moment the character appears on screen.

This pair of Goomba's are the first indication that you can jump on two things successively for more points. Most people will do this on their first or second playthrough and learn.


Moving forward somewhat, you get the first clear indication (if you're still lucky/skilled enough to be big) that you can destroy blocks - as you're forced to. You also get the first introduction to turtles, and their mechanic of being able to jump on their shells.
You also get a sighting that there are the things that come out of pipes at a safe enough distance to guarantee survival - and they stop coming if you come too close. It's a good way of introducing the new enemy.


The level then introduces, in a very limited quantity, the first moving platforms. These become particularly important in the next level. You can't avoid them, forcing the player to learn of their safety.

World 1-3
Very brief comments. The world introduces the new platforms gently. Players have already encountered green turtles, but not red turtles - who turn around at the edges of platforms. The game introduces this by putting a turtle that is generally almost close to the end up top very close to the end of its platform (hence making the player feel that the turtle is going to land on the player) before the player sees it turn around. Red Turtles are used extensively in the level to emphasise the gameplay mechanic.

Studios seem to have lost the art of teaching players to play the game without an overly basic, trivial tutorial - or worse uninteractive video's. I might discuss this again. But, there are exceptions.

These problems have been most successfully avoided by Valve. I can list 3 very clear examples where Valve has been able to teach players the mechanics of the game effectively without a tutorial - being Half Life 2, Portal and Team Fortress 2. The latter two are particularly notable as Valve's customer-centric tester-centric approach to game design can most clearly be seen. If you own either game, I highly recommend playing the audio commentaries to understand how the games were designed. I was going to write more about the subject, but it is late and I'm tired. I may discuss it again later.


Lachlan