Documentation
¶
Index ¶
- type Tile
- type Wfc
- func (wfc *Wfc) CollapseCell(index int)
- func (wfc *Wfc) ElaborateCell(x, y int)
- func (wfc *Wfc) FilterOptions(orig, options []string) []string
- func (wfc *Wfc) GetAvailableOptions(cellIndex int, direction string) []string
- func (wfc *Wfc) IntInSlice(a int, slice []int) bool
- func (wfc *Wfc) Iterate(numOfTilesX, numOfTilesY int) bool
- func (wfc *Wfc) LeastEntropyCellIndexes() []int
- func (wfc *Wfc) RandomOptionWithWeight(index int) string
- func (wfc *Wfc) Reset()
- func (wfc *Wfc) StartRender()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Wfc ¶ added in v0.9.0
type Wfc struct { Tiles []Tile TileEntries map[string]assets.TileEntry IsRunning bool // contains filtered or unexported fields }
func NewWfc ¶ added in v0.9.0
NewWfc returns a new WFC with the given number of tiles in the X and Y directions, and the given tile entries.
Parameters: - numOfTilesX: the number of tiles in the X direction. - numOfTilesY: the number of tiles in the Y direction. - tileEntries: a map of tile names to TileEntries.
Returns: - *Wfc: a pointer to a new WFC.
func (*Wfc) CollapseCell ¶ added in v0.9.0
CollapseCell collapses a cell.
Parameters: - cellIndex: the index of the cell to collapse.
Returns:
- nothing. It modifies the cell at the given index to have a collapsed state with a randomly chosen option.
func (*Wfc) ElaborateCell ¶ added in v0.9.0
ElaborateCell takes an x and y coordinate and elaborates a cell by filtering its available options based on the options of its adjacent cells.
Parameters: - x: the x coordinate of the cell to elaborate. - y: the y coordinate of the cell to elaborate.
Returns:
- nothing. It modifies the options of the cell at the given x and y coordinates.
func (*Wfc) FilterOptions ¶ added in v0.9.0
FilterOptions filters the original options based on the provided options slice.
It takes in two parameters: - orig []string: the original options slice - options []string: the options to filter by Returns []string: the filtered options slice
func (*Wfc) GetAvailableOptions ¶ added in v0.9.0
GetAvailableOptions takes a cell index and a direction, and returns a slice of strings that represent all the available options for the given direction.
Parameters: - cellIndex: the index of the cell to retrieve the available options for. - direction: a string representing the direction to retrieve the available options for. Can be "up", "right", "down", or "left".
Returns: - []string: a slice of strings representing the available options
func (*Wfc) IntInSlice ¶ added in v0.9.0
IntInSlice checks if a given integer is present in a slice of integers.
Parameters: - a: the integer to search for. - slice: the slice of integers to search in.
Returns: - bool: true if the integer is found in the slice, false otherwise.
func (*Wfc) Iterate ¶ added in v0.9.0
Iterate collapses one cell with least entropy, then elaborates all cells. The collapsing and elaboration is done concurrently, but the elaboration of each row is done sequentially to avoid race conditions. If all cells are collapsed, it sets IsRunning to false and returns false. Otherwise, it returns true.
func (*Wfc) LeastEntropyCellIndexes ¶ added in v0.9.0
func (*Wfc) RandomOptionWithWeight ¶ added in v0.9.0
func (*Wfc) StartRender ¶ added in v0.9.0
func (wfc *Wfc) StartRender()