Map Generation - UQcsse3200/2026-studio-3 GitHub Wiki

Map Generation

Procedural generation of the MapGraph object and its nodes/connections is handled by the MapGenerationController class and by extension the MapGenerationConfig class. MapGenerationController acts as a mediator for the configuration, the node pool generation and the map graph itself. This is then the first object that is created in the flow of instantiating a MapGraph.

MapGenerationConfig

Map generation will be affected primarily by three constants defined in MapGenerationConfig:

  • MAP_HEIGHT: Determines how many layers or rows of MapNodes will be generated.
  • MAP_WIDTH: Determines the row size of the layers that are generated by the MapGraph.
  • BRANCH_CHANCE: The chance that each iterated MapNode will branch out to another path/node.

In addition the various generation weights of nodes are defined as private fields which can be get/set with the corresponding functions.

MapGenerationController

Important Fields:

  • map: Stored MapGraph object with valid generation applied.
  • seed: Random generation seed for node pool and pathing.

Both of these are private and only map can be read through getMap(). The seed is registered with MapGenerationConfig and exists for an optional constructor where the seed is defined by the MapGenerationController.

The flow of instantiating a MapGraph, applying a config, generating nodes and paths, and applying redistribution and constraint logic happens in the MapGenerationController class. As many various components are involved in getting a new valid map available for the player, this class exists to make this more straightforward and logically sectioned off from map interaction. Almost every method in MapGenerationController is private except for getMap() which returns the generated MapGraph. As such, this documentation is primarily for anyone interested in extending or experimenting with generation.

generatePathing()

Private method where all generation procedures are called from. Will be repeatedly called by MapGenerationConfig until a valid map state is created, so as to account for various deadlocks that may arise in generation.

At a high level, this will produce a random number of paths (using a heuristic defined in chooseNextNode()) from the starting point to the top of the map. From here additional branching paths are created to add diversity and decision making to the MapGraph. Various constraints are also put in place on the node types, but this is handled in NodePoolGenerator.

initializePaths()

Defines the initial number of paths created from the START node. Each of these paths are defined as node lists and then stored in a nested list. As paths are expanded in buildPath(), nodes are added and tracked in this state.

chooseNextNode(MapNode parentNode)

Acts as a heuristic function which randomly chooses the next node to path to from the node provided in the parameter. It only gets nodes that are defined as in range (see getNodesInRange()), and though it has some specific weighting to avoid untenable states it is mostly random.

buildPath(List<MapNode> path)

After paths are initialized, they are passed into this function and built out according to chooseNextNode(). Every time a new connection is formed, it has BRANCH_CHANCE chance to create a new connection over to another path.

getNodesInRange(MapNode node)

Finds all nodes that are neighboring the provided node in the layer above.

⚠️ **GitHub.com Fallback** ⚠️