unreal.WaveFunctionCollapseSubsystem

class unreal.WaveFunctionCollapseSubsystem(outer: Object | None = None, name: Name | str = 'None')

Bases: EditorSubsystem

Wave Function Collapse Subsystem

C++ Source:

  • Plugin: WaveFunctionCollapse

  • Module: WaveFunctionCollapse

  • File: WaveFunctionCollapseSubsystem.h

Editor Properties: (see get_editor_property/set_editor_property)

  • orientation (Rotator): [Read-Write]

  • origin_location (Vector): [Read-Write]

  • resolution (IntVector): [Read-Write]

  • starter_options (Map[IntVector, WaveFunctionCollapseOption]): [Read-Write]

  • use_empty_border (bool): [Read-Write]

  • wfc_model (WaveFunctionCollapseModel): [Read-Write]

collapse(try_count=1, random_seed=0) Actor

Solve a grid using a WFC model. If successful, spawn an actor.

Parameters:
  • try_count (int32) – Amount of times to attempt a successful solve

  • random_seed (int32) – Seed for deterministic results. When this value is 0 the seed will be generated. Seed value will be logged during the solve.

Return type:

Actor

derive_grid_from_transform_bounds(transforms) None

Derive grid from the bounds of an array of transforms Assumptions:

-Transforms can only represent a single grid

-Sets empty starter option if there is a valid grid position with no transform -Orientation is determined by the yaw of the first transform in the array

Parameters:

transforms (Array[Transform]) – Array of transforms (by ref)

derive_grid_from_transforms(transforms) None

Derive grid from an array of transforms Assumptions:

-Every transform represents the center point of a tile position -Sets empty starter option if there is a valid grid position with no transform -Orientation is determined by the yaw of the first transform in the array

Parameters:

transforms (Array[Transform]) – Array of transforms (by ref)

initialize_wfc() -> (tiles=Array[WaveFunctionCollapseTile], remaining_tiles=Array[int32])

Initialize WFC process which sets up Tiles and RemainingTiles arrays Pre-populates Tiles with StarterOptions, BorderOptions and InitialTiles

Returns:

tiles (Array[WaveFunctionCollapseTile]): Array of tiles (by ref)

remaining_tiles (Array[int32]): Array of remaining tile indices. Semi-sorted: Min Entropy tiles at the front, the rest remains unsorted (by ref)

Return type:

tuple

observation_propagation(random_seed) (tiles=Array[WaveFunctionCollapseTile], remaining_tiles=Array[int32], observation_queue=Map[int32, WaveFunctionCollapseQueueElement]) or None

Recursive Observation and Propagation cycle

Parameters:

random_seed (int32) –

Returns:

tiles (Array[WaveFunctionCollapseTile]): Array of tiles (by ref)

remaining_tiles (Array[int32]): Array of remaining tile indices (by ref)

observation_queue (Map[int32, WaveFunctionCollapseQueueElement]): Array to store tiles that need to be checked whether remaining options are affected (by ref)

Return type:

tuple or None

observe(random_seed) (tiles=Array[WaveFunctionCollapseTile], remaining_tiles=Array[int32], observation_queue=Map[int32, WaveFunctionCollapseQueueElement]) or None

Observation phase: This process randomly selects one tile from minimum entropy tiles then randomly selects a valid option for that tile

Parameters:

random_seed (int32) –

Returns:

tiles (Array[WaveFunctionCollapseTile]): Array of tiles (by ref)

remaining_tiles (Array[int32]): Array of remaining tile indices. Semi-sorted: Min Entropy tiles at the front, the rest remains unsorted (by ref)

observation_queue (Map[int32, WaveFunctionCollapseQueueElement]): Array to store tiles that need to be checked whether remaining options are affected during propagation phase (by ref)

Return type:

tuple or None

property orientation: Rotator

[Read-Write]

Type:

(Rotator)

property origin_location: Vector

[Read-Write]

Type:

(Vector)

propagate() (tiles=Array[WaveFunctionCollapseTile], remaining_tiles=Array[int32], observation_queue=Map[int32, WaveFunctionCollapseQueueElement], propagation_count=int32) or None

Propagation phase: This process checks if the selection made during the observation is valid by checking constraint validity with neighboring tiles. Neighboring tiles may reduce their remaining options to include only valid options. If the remaining options of a tile were modified, the neighboring tiles of the modified tile will be added to a queue. During this process, if any contradiction (a tile with zero remaining options) is encountered, the current solve will fail.

Returns:

tiles (Array[WaveFunctionCollapseTile]): Array of tiles (by ref)

remaining_tiles (Array[int32]): Array of remaining tile indices. Semi-sorted: Min Entropy tiles at the front, the rest remains unsorted (by ref)

observation_queue (Map[int32, WaveFunctionCollapseQueueElement]): Array to store tiles that need to be checked whether remaining options are affected (by ref)

propagation_count (int32): Counter for propagation passes

Return type:

tuple or None

property resolution: IntVector

[Read-Write]

Type:

(IntVector)

property starter_options: None

[Read-Write]

Type:

(Map[IntVector, WaveFunctionCollapseOption])

property use_empty_border: bool

[Read-Write]

Type:

(bool)

property wfc_model: WaveFunctionCollapseModel

[Read-Write]

Type:

(WaveFunctionCollapseModel)