Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.44 KB

File metadata and controls

39 lines (30 loc) · 1.44 KB

Core Wave Function Collapse in Lua

Core implementation of the Wave Function Collapse algorithm by mxgmn as a module in Lua. the aim of this module is to only implement the core algorithm without the parsing of a file as an input making this perfect for a project that only needs the bitmap data to do stuff.

Warning

some cases are untested, as I dont need them for my current use case.

Usage

  1. Clone the repo.
$ git clone https://github.com/quebn/wfc-core-lua.git
  1. Use the module
local wfc_core = require("wfc-core-lua")

-- bitmap is structured as { [integer]:integer, width:integer, height:integer } see `init.lua` for the luadoc structure definition.
local foo = wfc_core.overlapping(bitmap, {
    name = "Foo",
    N = 3,
    ground = true,
    periodic = true,
    symmetry = 2,
})
-- generate function ouputs a list of bitmap, returns list with 1 item if no screenshot value is provided in generate function
local outputs = foo:generate()
-- do whatever with the generated outputs

see examples.lua for more usage examples

Acknowledgments

Wave Function Collapse algorithm. The original Implementaion written in C#, serves as inspiration for this implementation.

NWFC - Wave Function Collapse but LÖVE . another implementation in lua for LÖVE2D development.

LICENSE

MIT License