Procedural Generation

Page last edited 3,805 days ago
From Web Of Lives
Jump to navigation Jump to search

Each Labyrinth in Web of Lives is generated through a set of procedural generation algorithms.

Base Definition

Labyrinths have an upper bounds for the number of possible tiles within non-hallway spaces. Each level shall increase the upper bound linearly until the number of tiles per level is twice that of the first. Once the limit of tiles is reached the number of available tiles will not increase. Execution of the algorithm shall be as follows:

Place Entry RoomGenerate RoomsCreate HallwaysDetermine Floor ExitPopulate RoomsSpawn ItemsSpawn Monsters

Tiles

One atomic tile measures 32x32 pixels. Each tile has at least one corresponding sprite. The corresponding sprite is determined by a tileset which is a sprite sheet. Tilesets should be associated at the time of level generation and should be used for labyrinth theming.

Place Entry Room

The entry room must be placed at the start of the level generation process. Its exact location in the grid space is to be randomly determined. Placing the Entry Room first will always ensure a valid entry point for each Labyrinth floor.

For Entry Room specification see Entry Room

Generate Rooms

Rooms may be no more than 30x30 tiles, but no less than 3x3 tiles. Every room is bordered by a one tile perimeter zone where walls and exits will be placed. At this phase in the generation rooms are only placed, not populated.

Create Hallways

At this time rooms shall be given at most one exit per 10 tiles. As such one room may have at most 8 exits.

Exits

  • An exit may be up to TWO(2) tiles in width.
  • Exits exist solely in the perimeter area of the room.
  • Exit come in two varieties:
  1. Open
    1. An open exit has no impedance to vision or movement and leads directly to a hallway.
  2. Closed
    1. A closed exit may have either a door or some other obstacle that impedes motion and or sight.
  • Each exit is flagged as Open or Closed at this phase.

Hallways

Hallways shall contain no obstacles for the sake of reducing complexity in the procedural algorithm. The Hallways might hold mazes if four or more rooms are near by to the current exit. Nearby here suggests a range of distance, where the range might be of 15 to 20 tiles. Note:This maze structure is provided for enhancing the thrill of the gameplay, where by player's spatial skills can be tested.

Hallways will be created with an implementation of A*:

  • The search space for the algorithm consists of all room exits.
    • The first element in the search space must ALWAYS be the Entry Room exit.
  • Exits on the same room must be weighted such that the A* algorithm will prefer exits associated with other rooms.
  • If an odd number of exits exist the final exit shall be destroyed.

Determine Floor Exit

Basic exit room.
Basic exit room.
  • The exit shall be placed in the center of the room linearly farthest from the Entry Room.
  • A Floor Exit will take up no less than Two(2) tiles horizontally adjacent.
  • Entering the Floor Exit will bring the player to the next floor.

Populate Rooms

Each room is populated based upon the combination of entrances and number of tiles that comprise the room.

See Labyrinths for more information on the existent room archetypes.

Spawn Items

For each populated room randomly spawn items in any item spawner location.

See Items for item spawn rates and generation procedures.

Spawn Monsters

For each populated room randomly spawn monsters in any monster spawner locations.

See Monsters for item spawn rates and generation procedures.