RunMap generation algorithm #31

Merged
ian merged 2 commits from run-map-generation-algorithm into main 2026-10-06 22:19:28 -07:00
Owner

The current run map generation algorithm is:
Take a grid of a set length and width
Make a "source" at row -1, and a "sink" at row gridHeight + 1. These are the start and end points of a map
Begin a configurable number of random walks at row 0. Each random walk increases its row index by 1, and either moves left, stays in the same column, or moves right. Every place this walk touches is a room.
A single walk never branches, but you can get a situation like this that looks branch-y:

- - - * - * - - -
       \ /
- - - - * - - - -
       / \
- - - * - * - - -
     /     \
- - * - - - * - -

The branches both lead to the same room, and there is no notion of "walk A's version of the room and walk B's version of the room."

Random decisions are made with a seed. We should use the same seed for everything having to do with randomness, to make it possible to debug problems more easily.

Right now, the map is visualized with an ASCII debug readout. I will make it viewable in game now that I feel like I understand the algorithm a bit and have the underlying algorithm seemingly working. Next steps are that visualization in-game and also adding different types of rooms, rather than just "room or not room".

The current run map generation algorithm is: Take a grid of a set length and width Make a "source" at row -1, and a "sink" at row gridHeight + 1. These are the start and end points of a map Begin a configurable number of random walks at row 0. Each random walk increases its row index by 1, and either moves left, stays in the same column, or moves right. Every place this walk touches is a room. A single walk never branches, but you can get a situation like this that looks branch-y: ``` - - - * - * - - - \ / - - - - * - - - - / \ - - - * - * - - - / \ - - * - - - * - - ``` The branches both lead to the same room, and there is no notion of "walk A's version of the room and walk B's version of the room." Random decisions are made with a seed. We should use the same seed for _everything_ having to do with randomness, to make it possible to debug problems more easily. Right now, the map is visualized with an ASCII debug readout. I will make it viewable in game now that I feel like I understand the algorithm a bit and have the underlying algorithm seemingly working. Next steps are that visualization in-game and also adding different types of rooms, rather than just "room or not room".
ian force-pushed run-map-generation-algorithm from a5129bc5eb to d70c4b3bd0 2026-10-06 22:19:17 -07:00 Compare
ian merged commit c376c90515 into main 2026-10-06 22:19:28 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
yeahweregames/UnityTowerDefense!31
No description provided.