unreal.WaveFunctionCollapseSubsystem
¶
- class unreal.WaveFunctionCollapseSubsystem(outer=None, name='None')¶
Bases:
unreal.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] Orientationorigin_location
(Vector): [Read-Write] Origin Locationresolution
(IntVector): [Read-Write] Resolutionstarter_options
(Map(IntVector, WaveFunctionCollapseOption)): [Read-Write] Starter Optionsuse_empty_border
(bool): [Read-Write] Use Empty Borderwfc_model
(WaveFunctionCollapseModel): [Read-Write] WFCModel
- 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
- 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
- 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
- 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
- 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 starter_options¶
[Read-Write] Starter Options
- Type
- property wfc_model¶
[Read-Write] WFCModel
- Type