mxgmn / WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics
Other
23.18k stars 1.24k forks source link

Command-line options and snap packaging #18

Closed cmars closed 6 years ago

cmars commented 7 years ago

I was pretty interested in this project after learning about it last week on HN, but I wasn't really set up for .NET/C# development, and I don't run Windows.

My C# is pretty rusty, but I've added command-line options with NDesk.Options, and a Makefile for building on Linux with Mono. Apologies in advance that my C# style could be pretty bad -- I haven't done .NET in years.

For the community interested in this project, I've also added snap packaging (see snapcraft.yaml) in this PR, so that you can just install it on Linux OSes. I've published this package under my namespace as wfc-cmars. On Ubuntu 16.04, you can install with sudo snap install wfc-cmars, and then you'll be able to run with wfc-cmars. For example:

$ wfc-cmars --help
Usage: wfc [OPTIONS]
Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics.

Options:
      --samples-from=FILE    Process samples from XML FILE. All other options
                               ignored.
  -i, --input=PATH           Input PATH: BMP image for --model=overlapping;
                               directory containing data.xml for --model=
                               simpletiled
  -o, --output=FILE          Output FILE, default=out.bmp
  -w, --width=INT            Tiled image width INT when --model=simpletiled,
                               default=48
  -h, --height=INT           Tiled image height INT when --model=simpletiled,
                               default=48
  -m, --model=TYPE           Model TYPE: `overlapping` (default) or `
                               simpletiled`. Required.
  -n=N                       N parameter, when --model=overlapping, default=2
      --limit=INT            Model limit INT, default=0
  -p, --periodic             Periodic, default false
      --symmetry=INT         Symmetry INT, when --model=overlapping, default=8
      --foundation=INT       Foundation INT, when --model=overlapping, default=0
      --pi, --periodicInput=BOOL
                             Periodic input BOOL, when --model=overlapping,
                               default=True
      --subset=NAME          Subset NAME in data.xml, when --model=simpletiled
      --black=VALUE          Black, when --model=simpletiled, default false
      --help                 Display help and exit
$ wfc-cmars -i samples/City.bmp -n 3 --symmetry 2 --foundation=-2 --periodic -o test.png
DONE

Snap packages support most or all Linux distributions, see http://snapcraft.io for instructions on installing the snap command if you don't have it.

Hope this is helpful, and thanks for this amazing fun project!

mxgmn commented 7 years ago

@cmars You're welcome and thanks for the PR! I'll keep it open so people could start faster with the command line.

cmars commented 7 years ago

Rebased to master

VelocityRa commented 7 years ago

Is this going to get merged?

mxgmn commented 7 years ago

@VelocityRa No. But you can merge it in your fork.

VelocityRa commented 7 years ago

Oh, alright.

Nakilon commented 3 years ago

I have no clue in snap and dotnet. How do I install it?

$ docker run --rm -ti snapcore/snapcraft
# sudo snap install wfc-cmars
error: cannot communicate with server: Post http://localhost/v2/snaps/wfc-cmars: dial unix /run/snapd.socket: connect: no such file or directory
cmars commented 3 years ago

Snaps are kind of awkward in that they only work with a live snapd agent running -- which doesn't easily work inside a Docker container. A Dockerfile + wrapper script might be a lot more portable than a snap...