项目作者: mr-highball

项目描述 :
wave function collapse algorithm
高级语言: Pascal
项目地址: git://github.com/mr-highball/wfc.git
创建时间: 2021-01-10T17:50:28Z
项目社区:https://github.com/mr-highball/wfc

开源协议:MIT License

下载


wfc

wave function collapse algorithm

Features

some features at a glance…

  • 2D & 3D graph
  • comfortable api to reshape and define constraints
  • generic user defined values
  • extendable classes if base behavior is not desired

Sample

Below is a sample which shows a possible use for wfc:

  1. //easily define the shape (2D or 3D is supported)
  2. LGraph := TGraph.Create.Reshape({width} 5, {height} 5, {depth} 1);
  3. (*
  4. constraints are also very easy to add and the interface provide fluent setters.
  5. in this case A's & B's can be present in "any direction" on the graph (north, east, up, down, etc...)
  6. *)
  7. LGraph.AddValue('A')
  8. .NewRule(AllDirections, ['A', 'B']);
  9. (*
  10. but here, we constrain to just a few directions
  11. A or B (N & S) of a "C"
  12. *)
  13. LGraph.AddValue('C')
  14. .NewRule([gdNorth, gdSouth], ['A', 'B']);
  15. (*
  16. when you're finished defining constraints and all of the
  17. possible values (states), then just run and the result can be
  18. persisted or you can access the completed graph directly
  19. *)
  20. LGraph.Run();

How To Use

  1. download and install lazarus if you don’t already have it (http://www.lazarus-ide.org)
  2. git clone this repo
    • some examples have submodule dependencies so if you want to clone this repo and bring in all of those do a git clone --recursive
    • if you already cloned you can update submodules with git submodule update --init --recursive
  3. open wfc_test.lpr and attempt to compile/run (F9 Key)
    • this project shows some basic usage of the library
    • also, by going to Toolbar -> Project\Project Options\Paths you can copy the other units text to include in your own project
  4. add .\src path to your project other units

Tip Jar

  • :dollar: BTC - bc1q55qh7xptfgkp087sfr5ppfkqe2jpaa59s8u2lz
  • :euro: LTC - LPbvTsFDZ6EdaLRhsvwbxcSfeUv1eZWGP6