1 of 14

Slide Notes

DownloadGo Live

Truly Random Generation

Published on Nov 18, 2015

No Description

PRESENTATION OUTLINE

Random

Generation for the 2D Platformer

Houston, we have a problem

Playing through our current random generation was super sucky

It wasn't where we NOR our community wanted it to be

Untitled Slide

Friedrich Hayek's famous quote might also be applicable to game design.

We spent some serious time hashing out what we wanted.

Premise
Map
Rooms
Tiles
Blocks

We listed:
a solid foundation that can easily be built upon

smart map layout and generation

different rooms needed to be generated on the map

the tiles in the room couldn't look the same each time (i've seen room 5 2000x times now)

Blocks of varition would be nice.

Darius Kazemi



@tinysubversions

We spent an equal amount of time on research.

Chris found an awesome essay from
Darius Kazemi of tiny subversions.com on how Spelunky's random generation could be explained. It was definitely a resource to build off of.

Its VERY Important to note Darius' essay is NOT how the Spelunky team developed the game :) but it is very cool.

Untitled Slide

The basis for Darius' essay and any other randomized program is probability

and probabilities within probabilities.

Map

The basic map was 16 tiles, a 4x4 grid.

This was soooo perfect for me! Unity has Matrix4x4

Little did I know Matrix4x4 is a transformation matrix and NOT a Mathmatical matrix like Ruby has. This limited my use of the matrix to just the map.

The benefits is you can access an individual point using the row and column for coordinates YES!

Matrix.zero easily sets up a 4x4 of zeros

Now I can generate a "golden path" that works best for the player.

Rules of Movement

  • 1,2 move LEFT
  • 3,4 move RIGHT
  • 5 move DOWN
  • Exit Room
  • Zeros are "'filler"
The path had to have movement rules.

Filling the matrix with values was easy with Random.Range.

1 or 2 meant go left
3 or 4 meant go right
5 meant go down

all of this was possible with a switch/case setup

row, column values based on rules of movement

Rooms

  • 10x8 grid
  • Templates
Rooms are made up of 10X8 arrays.

Its true that arrays are really one long thing (thanks C# in Unity), but I set mine up in the editor to look like a matrix.

Make different versions of room types then select from them using Random.Range

Templates: they make it easier to create levels. Open, closed, platforms, high danger, easy etc.

Room Types

  • 1: L,R mix
  • 2: L,R, D mix
  • 3: L,R, T closed
  • 4: L, R, T open
  • 5: open to top, L, R, mix
Photo by ecstaticist

Room Types

  • 0: Filler - yet worth it to explore
  • E: - hard with Exit door
  • Array
  • Represents a tile/block with probabilities
  • 1 = 100%, 2 = 50%, 5 = Ground Block
Photo by Great Beyond

Obstacle Blocks

  • Blocks with more tile probabilities
  • The same room will look different every time
  • 3x5 or 2x4
Obstacle blocks can be ground or air depending on where you place them :D

They allow for you to stack even more probabilities together.

They don't have to be the same for each room.

Some rooms may need a 3x5, but maybe a 2x4 is more appropriate for a

Balance, Spice, Tweak

Now all thats left is to balance the tiles, spice it up a bit with some bad guys, tweak probabilities and PUBLISH!! :D

Thank You!

@holliebuckets
Photo by vgm8383