Skip to content

Core Concepts: Weighting

What is Weighting?

Throughout DunGen, you'll encounter settings related to Weight. Simply put, weight controls likelihood. When DunGen has to choose one item from a list (like picking which Tile to place next, or which Prop variant to keep), items with a higher weight are more likely to be chosen.

Key Principle: Weights are relative.

  • If Tile A has a weight of 1 and Tile B has a weight of 1, they have an equal chance of being chosen.
  • If Tile A has a weight of 2 and Tile B has a weight of 1, Tile A is twice as likely to be chosen as Tile B.
  • If Tile A has a weight of 0.5 and Tile B has a weight of 0.5, they still have an equal chance (same as 1 vs 1).
  • If an item has a weight of 0, it will never be chosen under those conditions.

You'll find weight settings primarily in:

  • Tile Sets: Controlling the chance of each Tile prefab being selected.
  • Prop Components (Local Prop Set, Random Prefab, Global Prop): Controlling the chance of props spawning or specific prefabs being chosen.
  • Doorway Component (Connectors/Blockers): Controlling the chance of specific connector/blocker prefabs being chosen.

Components of a DunGen Weight

Tile Weights

Weight used by a Tile Set

A full weight configuration in DunGen (like those found on Tiles within a Tile Set) has three main parts:

  1. Main Path Weight: The base likelihood of this item being chosen when DunGen is building the main path (the critical route from the start to the goal).
  2. Branch Path Weight: The base likelihood of this item being chosen when DunGen is building an optional branch path.
    • Why two base weights? This lets you make certain tiles or props common on the main path but rare in branches, or vice-versa. For example, maybe key quest rooms only appear on the main path (Main Path Weight > 0, Branch Path Weight = 0).
  3. Depth Scale (Curve): This is a powerful modifier that allows the item's likelihood to change based on how deep into the path it's being placed.

    • How it works: The curve graph adjusts the effective weight.
      • The X-axis represents the normalized depth (0 = start of the path, 1 = end of the path).
      • The Y-axis represents a multiplier (0 = zero chance, 1 = use the base weight exactly, 2 = double the base weight, etc.).
    • DunGen calculates the current depth (0-1), finds the corresponding multiplier value on the Y-axis of the curve, and multiplies the appropriate base weight (Main or Branch) by this value.

    • Example:

      • Imagine a curve that starts low (Y=0.1) at the beginning (X=0) and ramps up high (Y=2.0) at the end (X=1).
      • An item with this curve would be unlikely to appear near the start of the dungeon path (base weight * 0.1) but very likely (base weight * 2.0) to appear near the end.

Putting it Together

The final chance of an item being chosen at any given point is calculated roughly like this:

Effective Weight = Base Weight (for current path type) * Depth Scale Multiplier (at current depth)

DunGen then compares the Effective Weight of all possible choices at that moment to determine the probabilities.


Practical Examples

  • Common Room: Main Path Weight = 1, Branch Path Weight = 1, Depth Scale = Flat line at Y=1. (Equal chance everywhere)
  • Early Game Room: Main Path Weight = 1, Branch Path Weight = 1, Depth Scale = Starts high (Y=1), drops low (Y=0.1) near the end. (Common early, rare late)
  • Boss Room Ante-chamber: Main Path Weight = 1, Branch Path Weight = 0, Depth Scale = Starts very low (Y=0), sharply rises only near the end (X=0.9 to 1.0). (Only appears on the main path, right before the goal)
  • Secret Room (Branches Only): Main Path Weight = 0, Branch Path Weight = 1, Depth Scale = Flat line at Y=1. (Only appears in branches, equal chance throughout branch length)

By combining these three components, you can precisely control the frequency and placement context of your tiles and props within the generated dungeons.