Procedural Office with Space/Time Anomalies
- bvieriu246
- Nov 9, 2023
- 9 min read
Updated: Jun 2
Technical Game Design Document
(This is a blogpost made to summarize the old ones made in 2022)

Useful Concepts
->Wormholes/Portals (They are planes that show the view of the room from the other portal based on your view, with the intention of making them seamless)
->Manifolds (In mathematics, a manifold is a topological space that locally resembles Euclidean space near each point. - https://en.wikipedia.org/wiki/Manifold - this is just for naming and to keep the concept of actual non-Euclidean geometry separated)
Basic Information
This design document is made to describe the concept of procedural generation for a game level.
->Game Genre: FPS (First Person Shooter)
->Level Location: Anomalous Office Building
->Possible Player Abilities:
basic FPS movement (front, back, strafe left/right, jump, crouch),
primary (shooting),
secondary (grenades, abilities),
use and open map.
(Abilities can be added depending on the story)
Tutorial Generation
If the game has a tutorial level, it can also be procedurally generated, but on a smaller scale and stricter, it will have to follow the flow of a normal tutorial.
Every different special mechanic would need a room, following the suggested abilities, it would be organized like this:
- the basic movement could start with back/front and the strafe movement, followed by jumping and crouching
- the map mechanic is a good follow-up, so you can give good examples of marked objectives and to easily get used to using it for orientation
- the last should be the shooting mechanics, primary and secondary, just for the basic weapons the player's faction would use
Rooms would need to be premade, with only procedural aesthetic changes.
Only gameplay affecting generations would happen with changes in directions, the rooms would have a few sockets and corridors would only have two ends.
The base assumption for this document is that the tutorial room would need to be as realistic as possible.

Starting Point
The base idea is an office building; this means the starting point needs to be related.
Depending on the story, the entrance to the complex can be anywhere from the front building entrance to a back entrance.
The idea of the starting point is that it will be used for either the tutorial, story progression or roguelike introduction, depending on the decisions taken.
Different Starting points
FRONT ENTRANCE
The front entrance will not have many gameplay ways it can be generated; this document will assume that the front entrance would be made from fragments:
-the main entrance
-the front desk
-main lobby
-the actual transition into the generated office.
BACK ENTRANCE
The back entrance route would have even less generation possibilities in the realm of gameplay generation, it would need to be made from:
-a simple backstreet
-an entrance
-an entrance corridor/connection to a front entrance lobby/directly in the office generation

Office Generation
Most of the story would happen in a procedural generated office, which has various kinds of rooms, containing enemies, collectibles and content related directly to the story.
There are different ways to generate an office building with the premise of taking place in a space/time anomaly, but this document will focus on two of them:
-The Grid Method
-The Matrix Method
Before describing the methods, the scales will be related to Unreal units, one of the scales being 1:200 for corridors and the generation matrix and for the actual room generation, the document will use 1:100.

Corridor System
The Corridor System (Cor) can be used for corridor generation in both methods. They work as follows:
-a base generator is tasked with choosing a tag for its corridors and with starting the corridor placement
-a few base corridor types:
>end (CorEnd)
>straight (|)(Cor|)
>corner (L) (CorL) with two pillar variations
>three-way (T) (CorT) with four pillar variations
>four-way (+) (Cor+) with five pillar variations
Their base form is tasked with creating other corridors, after they finish spawning, the corridors are meant to randomly decide if they will go on with the Merging Algorithm.

A base Cor is supposed to check around to not spawn another Cor if it is surrounded. After the first check, the same checking method is used for the Merging Algorithm if the tile randomly decided that it wants to apply it.
The Merging Algorithm is meant to make the basic Cor transform in a variation based on the others around, mostly by adding a pillar if the section next to it is a Cor that randomly decided to not use the Merging Algorithm.
(Ex. Cor is surrounded by three others, it transforms in a variation of CorT / Cor is surrounded, it transforms in a variation of Cor+ )
The idea behind the Merging Algorithm is not only to make the corridors create bigger spaces but also to connect two different generators (with their specified tags being different), this means that an actor would need to check every Cor generated and see if at least one of each is connected to another. (Ex. Generator1, Generator2, Generator3, Generator4)
Those are four generators, the actor would find all the generated Cors, see if at least one with each tag is connected with another.
Basically, Generator1 has a Cor that is connected to Generator2, a connection means either a direct connection [pipe, going in a plus -+] or they are next to each other, meaning this would activate the Merging Algorithm, forcing at least one of the Cors that fit the connected status to have a direct connection, by replacing it with an appropriate Cor type.
If they are not connected at all, the actor would need to take all the CorEnds and replace them with another type of Cor that can spread it, using the same tag.
The actor would then mark Generator1 and Generator2 as connected and they would act like a single generator, chaining all of them together.)
The Grid Method

The Grid Method is very straight forward, the whole area of a level will be incased in a grid, with the rooms and corridor spaces placed in a checker pattern (this could also be combined with a matrix for extra randomness and to give the player less/more of a kind of space, depending on what we choose to make the players feel, longer corridor sections can make the player feel unease, but it could also annoy other kinds of players, also to set locations of story elements).
The Cor generator tag check function will need to be localized to its specific square.
This method would need a way to monitor if all the rooms are connected, because some of them do not have all four connections. (This can be done using a tree array to see if every room is connected in some way)
The Matrix Method
The Matrix Method is straight forward as well, it uses a Matrix for different checks, those being:
-for space, it would need to be used to check if a space is used for a room or if it can be used for a corridor
-for anomalies, those would make specific parts change their aesthetic, not their function
This method will have most, if not all the elements calculated before their actual placement.
This method will mostly start off by using the first room of the level as an anchor. For the sake of explaining I will always place that anchor at [0, 0], with the actual starting room in the negatives, so it does not interfere with the generation.

The algorithm for this method will follow the steps below:
1. Choose variables for the number of rooms of each kind and how many doors the said rooms would have, based on a specified level rule
2. Reserve the space for the End Room in the upper fourth of the matrix (green is wall, red is floor, yellow is the door points)
3. Allocate the space for the other rooms
4. Allocate the space for corridors and their specified type based on their surroundings (only if a matrix-based corridor system is implemented or if you block the Cor system from going in those spots) (corridors are the blue)
Optional:
5. Paint the anomaly map based on a specific way of doing it (only if a matrix-based anomaly painter is used) (red and green spots)
Room Generation
Rooms will have a specific generation based on the methods listed before, this document will describe both.
The Grid Method is very straight forward with how it chooses to generate the rooms, they just spawn in the center of their specific boxes.
The matrix-based method rooms will be surrounded by a green layer, this one is to ensure that the corridors will have space to fit, this layer can be overlayed by another room's green layer.
As stated at the start, all the measurements will be in scale of 1:100 for rooms.
Drawer Room

The Drawer Room is made from:
-Pillars, they will be 1 x 1, and they have specific places where they are used
-Side walls, those are of two kinds, default wall and door slots
-Empty Slot, those are the places where the player can walk
-Drawer, they are a layer above the others, placed as single next to walls and double in
the middle
- Enemy point, they are on the same layer as the drawers
Rules:
-corners always have pillars
-sides of the room will have two door bearing walls followed by a pillar
-top and bottom of the room will have the edges containing three simple walls followed by a pillar, the middle sections will be four door bearing walls followed by a pillar
-the middle will follow the sides, meaning the pillars will follow the wall ones and the double drawers will be on the sides
Drawer Rooms will also need a shift logic, be it to the side or up/down, this is because of the scale shift between the Cor system and the room system
Now to talk about possible enemy placement, there would a lot of logic behind it.
- the enemy spawned will have a chance to barricade itself in the direction of a door (it could be saved as a variable that can remove a special number of single drawers from the units, to add a small amount of environmental storytelling)
- if the enemy is spawned on a drawer unit segment, it will use that drawer unit as a barricade
- depending on the enemy faction, it can have various kinds of barricades, from actual drawers to specific barricades (portable barricades specific to their faction)
- barricades can be applied to melee or very close-range enemies as well.

Small Office

There will be just a single type of Small Office with four variations. Little randomization happening in this room, those being just door and drawer placement.
I chose to split it into four variants but replacing the desks with a desk spawn spot would reduce the number of variations to two.

The Loop

The idea is that this would replace two "CorL"s in a U shape and it would take at least 2 x 2 space (1:200 scale) and it would take place in a Space Anomaly spot.
The 2 x 2 method is a tiny bit harder to make look good, but any bigger would work perfectly, having more space for teleportation to handle.
The teleports would need to be in the middle part of the U, and they would need a tiny bit of logic added.
To set up the collision boxes, the second box (red) would take the player to the illusion space that loops around, and the first box (blue) would take the player back. The player would also need to be tracked to see if they did a complete loop, by checking the ways the player enters and exits the collision boxes.
The Stair Teleporter

The teleportation way is like The Loop, but it will teleport you from the stair going up to the stair going down.
The second collision box (red) teleports you to the other stair and the first collision box (blue) does the reverse.
Two Stair Anomalies

THE PIPE (STAIR|)
It is supposed to replace a Cor| or more likely two CorLs, this would take place in a Space Anomaly spot.
THE U (STAIRU)
It is supposed to replace two CorLs and can be part of rooms.

Boss Generation
Bosses can take place in different ways; I will talk about two types that would fit best:
- Boss Run (Rush)
- Normal Boss Battle
What Boss Run (Rush) refers to is a boss chasing you around corridors and/or rooms, this could work great with a procedural generated path, they would be quite simple, taking place in a warehouse looking environment. (Catwalks and crates/boxes would be great obstacles for an FPS run) (This generation would be like the Tutorial idea I described in the beginning)
Normal Boss Battle refers to a basic room (could be inspired by an actual boss's office or warehouse looking environment, both can be spacious enough for a normal boss battle) with a boss enemy, with a different number of stages.
Those two types can also be combined, making a run stage followed by a normal stage or the other way around or in any other order and way.
The final boss can be anything, this one really depends on the story and ideas the game would use.

End Game
In the End Game section, the generation could be upgraded with extra rules (buff/de-buff, room number changes, Space/Time Anomaly chance increase/decrease, a switch in the anomaly paint map).
Game+ ideas could be implemented in the default story, adding extra story rooms and small-scale quests.
Boss Rush, a run only with the bosses with increasing difficulties.
Extra challenges, with different seeds or just planned loadouts.
Random collectibles across the levels, can add extra depth to the story.
End of Document
Please do not get lost in the office on your way out.
Comments