Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run / develop this project #3

Closed
squarism opened this issue Sep 30, 2016 · 89 comments
Closed

How to run / develop this project #3

squarism opened this issue Sep 30, 2016 · 89 comments

Comments

@squarism
Copy link

squarism commented Sep 30, 2016

For anyone curious (on a mac):

Run:

$ brew install mono (if you don't have it)
WaveFunctionCollapse $ mcs -pkg:dotnet /reference:System.Drawing.dll *.cs
WaveFunctionCollapse $ mono Main.exe

(it starts working your CPU)

🌻

@Rubonnek
Copy link

Rubonnek commented Sep 30, 2016

In Arch Linux the same command works. Only had to install mono:

# pacman -S mono
$ mcs -pkg:dotnet /reference:System.Drawing.dll *.cs

@ultrasam
Copy link

How can I run this on a PC?

@nilsding
Copy link

@ultrasam I lazied out and created a new C# project in Xamarin Studio (which is pretty much like Visual Studio) and added the C# files which where in the repo. Had to add references to System.Xml and System.Drawing before building.

@ultrasam
Copy link

When creating a new C# project in Visual Studio it gives me several options:
Windows Forms Application,
WPF Application
Console Application
Shared Project
Class Library

Which one should I pick??

@nilsding
Copy link

nilsding commented Sep 30, 2016

Use a Console Application and remove the Program1.cs file

@ultrasam
Copy link

I've got all this errors when I tried to build this, I am new at doing a project in Visual Studio 2015, sorry about that, but any help would be appreciated
image

@mwaltersva
Copy link

Right click References > Add, select System.Draw

@ultrasam
Copy link

Ok, perfect that worked it compiled with no errors, now how do I use the program??

@ultrasam
Copy link

Ok, I think I had two programs with the method main and that was causing problems, but now I fixed that and now I am getting the error shown here:
image
By the way the file samples.xml is there...

@dzoba
Copy link

dzoba commented Sep 30, 2016

After following @squarism 's directions I am getting

System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.dylib
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x000cc] in <93576e487af246b9880ff86779ad60ff>:0
   --- End of inner exception stack trace ---
  at System.Drawing.Bitmap..ctor (System.String filename, System.Boolean useIcm) [0x0002b] in <93576e487af246b9880ff86779ad60ff>:0
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in <93576e487af246b9880ff86779ad60ff>:0
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)
  at OverlappingModel..ctor (System.String name, System.Int32 N, System.Int32 width, System.Int32 height, System.Boolean periodicInput, System.Boolean periodicOutput, System.Int32 symmetry, System.Int32 foundation) [0x00041] in <e8e8a4739e4b4f79b85af1dc0961b451>:0
  at Program.Main () [0x000c9] in <e8e8a4739e4b4f79b85af1dc0961b451>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.dylib
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x000cc] in <93576e487af246b9880ff86779ad60ff>:0
   --- End of inner exception stack trace ---
  at System.Drawing.Bitmap..ctor (System.String filename, System.Boolean useIcm) [0x0002b] in <93576e487af246b9880ff86779ad60ff>:0
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in <93576e487af246b9880ff86779ad60ff>:0
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)
  at OverlappingModel..ctor (System.String name, System.Int32 N, System.Int32 width, System.Int32 height, System.Boolean periodicInput, System.Boolean periodicOutput, System.Int32 symmetry, System.Int32 foundation) [0x00041] in <e8e8a4739e4b4f79b85af1dc0961b451>:0
  at Program.Main () [0x000c9] in <e8e8a4739e4b4f79b85af1dc0961b451>:0```

After googling I don't see a simple answer to that. Any one here encountered/solved it?

EDIT:

I was able to get it to do a bit more by following these commands in addition to what @squarism posted. Not sure if this is the best way, but it seems to be working.

  1. brew cask install mono-mdk
  2. open /usr/local/Caskroom/mono-mdk/4.6.1.3/MonoFramework-MDK-4.6.1.3.macos10.xamarin.universal.pkg
  3. env PATH=/Library/Frameworks/Mono.framework/Commands/:$PATH mcs -pkg:dotnet /reference:System.Drawing.dll *.cs
  4. env PATH=/Library/Frameworks/Mono.framework/Commands/:$PATH mono Main.exe

@kchapelier
Copy link
Contributor

kchapelier commented Sep 30, 2016

@ultrasam is the samples.xml files actually copied to the build directory ? If it isn't you could try copy pasting it there manually to confirm it fixes the issue you're having. I can't remember what was the setting to include a resource file in the build system of VS though...

EDIT: you will probably have the same issue with all the images

@ultrasam
Copy link

well the file is there and I included it in the project:
image
Here is my project's folder:
image

Do you see anything wrong there?

@ultrasam
Copy link

Ok I put the samples folder and samples.xml inside the bin/Debug/ folder and it worked!!!, it started creating a bunch of BMPs, now if I want to use my own designs, should I put them on the samples folder??

@kchapelier
Copy link
Contributor

yes, and reference them in the samples.xml file and fiddle with the properties a bit

@TheDudeFromCI
Copy link

Is there a pre-compiled version of this? I am very new to C#, and have no idea how to compile or run it. >.>

@ultrasam
Copy link

ultrasam commented Oct 1, 2016

Here: https://dl.dropboxusercontent.com/u/24996373/TileCreation.rar

I hope this helps somebody

@TheDudeFromCI
Copy link

Thanks, that's perfect. ^^

@ultrasam
Copy link

ultrasam commented Oct 1, 2016

If you make any new bitmaps or any interesting tileset could you share it, I want to learn

@CoenraadS
Copy link

CoenraadS commented Oct 1, 2016

Windows Installation Instructions:

  1. Download NuGet: https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
  2. CMD > nuget install Microsoft.Net.Compilers -Version 1.3.2
  3. CMD > \Microsoft.Net.Compilers.1.3.2\tools\csc.exe *.cs

In my example I had WaveFunctionCollapse-master as my working directory.

@NNNenov
Copy link

NNNenov commented Oct 1, 2016

Thank you all for helping me to understand how to set this up!
I am a total amateur, so am playing with this as one.
The first thing I tried to do was modify one of the sample images, "flowers", I changed the colours of the petals, and added some other hues of green in the stems.
But this results in many "CONTRADICTION"s, it would be really good to have an idea why this is happening, is it because there is no direct chain of same colour pixels, but then, how do the flower heads work?
Is there a reference to what parameters are available, or what the parameters demonstrated in samples.xml mean? eg, what does foundation="102" mean?

@nylki
Copy link

nylki commented Oct 1, 2016

In Fedora 24 this worked for me (besides mono, mono-data-oracle was needed):

sudo dnf install mono-devel mono-data-oracle
mcs -pkg:dotnet /reference:System.Drawing.dll *.cs
mono Main.exe

@mxgmn
Copy link
Owner

mxgmn commented Oct 2, 2016

@NNNenov First, remove the foundation param at all, for default flowers it's hard to set up. Ground in results will be in the middle of a picture, but that's fine. Do contradictions remain? If yes, I need to see your bitmap.

@ka-petrov
Copy link

ka-petrov commented Oct 2, 2016

In Ubuntu 16.04 running the command
mcs -pkg:dotnet /reference:System.Drawing.dll *.cs

results in the following:
error CS1061: Type 'System.Xml.XmlNode' does not contain a definition for 'Get' and no extension method 'Get' of type 'System.Xml.XmlNode' could be found. Are you missing an assembly reference?

Can't figure out what reference am I missing :( including System.Xml changes nothing.
Not familiar with mono, but really want to play with the algorithm, pls help :)

@kchapelier
Copy link
Contributor

@imaginary-unit Do you have the Stuff.cs in the same folder ? The extension method in question is here : https://github.com/mxgmn/WaveFunctionCollapse/blob/master/Stuff.cs#L47

@ka-petrov
Copy link

@kchapelier Ouch, somehow I didn't include it.. thanks! now it works.

@NNNenov
Copy link

NNNenov commented Oct 2, 2016

@mxgmn yeah it looks like I picked the most fussy one to test first! It works fine without the foundation param. I am curious though what this foundation param means and its input values, in the example its set to 102, but the source image is only 23 pixels high?

@mxgmn
Copy link
Owner

mxgmn commented Oct 2, 2016

@NNNenov Foundation is a special case of constraint. I use it in examples like Flowers, City, Platformer to make the ground level be at the bottom of the output. If you delete the foundation param from samples.xml, you'll see that ground appears anywhere in the middle of an output, not necessary at the bottom. Why 102? It goes through input image in a scanline order. First it sees a 3x3 pattern of sky, so 0 is the index of 3x3 blue box. 1 is the index of 3x3 blue box with one pixel of yellow in the bottom right corner, and so on, 102 is the index of top row earth, bottom two rows sky pattern.

@BrianLovelace128
Copy link

I ran the program just fine, but I'm unable to open any of the .bmp files. Image viewer is giving me a message saying "File has bogus header data." Does anyone have any idea why this may be?

@kchapelier
Copy link
Contributor

@BrianLovelace128 Try renaming them to png, this is a known issue which will probably be fixed in the next version ( #1 )

@NNNenov
Copy link

NNNenov commented Oct 3, 2016

@mxgmn I thought I understood this but the 3x3 pattern part threw me off a little.
so 0 is the index of the top left pixel? and that pixel is the top left anchor/start point of the 3x3 pixel sector? like this? flowers ref
So each index is 3x3 pixels, and to set an anchor you count the amount of pixels in scanline order, then quanitze/divide by 3?

@selfsame
Copy link

selfsame commented Oct 10, 2016

@gromilQaaaa @mxgmn I think the second question was if WFC can output a tiling texture. I believe you could achieve that by using a N thick border constraint on the output array, where top/bottom left/right is repeated, and cropping that from the final output?

@mxgmn
Copy link
Owner

mxgmn commented Oct 10, 2016

@selfsame @gromilQaaaa Then sure, periodic="True" option generates a periodic texture. Most of the examples on the readme page are periodic.

@nanodeath
Copy link
Contributor

@mxgmn So periodic means the images should tile seemlessly, then? Didn't realize that.

@mxgmn
Copy link
Owner

mxgmn commented Oct 10, 2016

@nanodeath Yes. I scroll right/left up/down in videos and gifs to demonstrate that generated images are periodic.

@nanodeath
Copy link
Contributor

@mxgmn Ah...I had no idea what the panning was supposed to signify. I just assumed you were generating a larger image than what was initially being shown, and then panning for effect. Anywho, glad to learn more about the codebase.

@mxgmn
Copy link
Owner

mxgmn commented Oct 10, 2016

@nanodeath I also stacked 2 tiled "Rooms" outputs in the readme to demonstrate that they stack seamlessly.

@mxgmn
Copy link
Owner

mxgmn commented Oct 11, 2016

@NNNenov @nanodeath Pardon, nvm, this actually can be done fast, I'll do it right now...

@selfsame
Copy link

@NNNenov you can take a look at this version of the tiled model, I use strings instead of bitmaps that include a rotation number and parse that for the 3d display ("0foo", "3foo") https://github.com/selfsame/WaveFunctionCollapse/blob/master/SimpleTiledModel.cs

@NNNenov
Copy link

NNNenov commented Oct 23, 2016

Hey! I've just been trying to understand whats happening in the data.xml file for the tilesets.
Here's my understanding so far:

image
these are all the types of symmetry you can define for a tile.

Symmetry types define which way the tiles' neighbor rule can be mirrored to accommodate for more connection types and cut down on the amount of neighbour definitions needed?

So because of symmetry types, all neighbour entries are defined with single neighbor values, which are then calculated for the rest of its sides based on its symmetry type

So with left = X, right would equal something that can connect to the tile on any of its sides at the given rotation, because of this, X tiles never need to have a rotation defined.
left = I, right would equal something that can connect to only the left or right side of the tile,
left = T, right would equal something that can connect to only the left or right side of the tile,
but left = T 1 (or 3), right would equal something that can only connect to that side, but not the other?

If I am correct with the above assumptions, I have some questions about the following:
if left = L, technically not a symmetrical tile, does it still mean that
if left = L, right can equal something which can connect to the right and top side?
If that's the case I guess it is symmetrical because top and right are equal and bottom and left are equal?
See image:
image

however, in the castles data.xml file, there's a section(line 57,58) roadturn, which is L type, and is listed twice for a Tower to the right, which would suggest L symmetry has to be treated as unique on all sides?

I still have some more questions, but they are likely to change after I learn more from these queries

@mxgmn
Copy link
Owner

mxgmn commented Oct 24, 2016

In this castle example top row is <neighbor left="roadturn 1" right="tower"/> and bottom is <neighbor left="roadturn 2" right="tower"/>. What does that mean?

First, note in the Castle example tower tile has symmetry type L despite its picture having symmetry type X. I've redrawn it a little so L-symmetry would be apparent.

Imagine that we don't have any symmetry system at all. Than we also need to add lines like <neighbor left="tower 2" right="roadturn 3"/>, <neighbor up="roadturn 1" down="tower 3"/> and many more. But with the symmetry system we need only to enumerate neighbors up to a symmetry, and there are exactly 2 ways to do it for roadturn and tower - with continuations looking in the same direction or in different directions.

@pointyointment
Copy link

@CoenraadS

Step 2 fails, saying:

WARNING: Install failed. Rolling back...
Package 'Microsoft.Net.Compilers.2.0.0' is not found on source 'https://api.nuget.org/v3/index.json'.

I have tried various things without success.

@mxgmn
Copy link
Owner

mxgmn commented Nov 3, 2016

@pointyointment I don't know why it fails, but you can also try building through Visual Studio:

  1. Download Visual Studio 2015 Community (free).
  2. Create a console C# application (file -> new project).
  3. Delete Program.cs.
  4. Add all WFC .cs files.
  5. Add System.Drawing reference through solution explorer on the right.
  6. Move all WFC data files to bin/Release.
  7. Switch to release build option. Build, run.

@CoenraadS
Copy link

@pointyointment

nuget install Microsoft.Net.Compilers -Version 1.3.2

Not sure what changed since I posted, but it seems a version is required now.

@kronpano
Copy link

Not sure if this is still active but could somebody expand a bit on a 3D extension of the SW??
I was thinking of extending the XML with an "up" tag and then I would somehow need to "fix" those tiles in that level and build the rest around it??
Does that sound reasonable??

@mxgmn
Copy link
Owner

mxgmn commented Jul 23, 2017

@kronpano What is SW? I uploaded a simple 3D implementation of WFC here, the algorithm is the same in 3D.

@kronpano
Copy link

SW = software and Thanks - hadn't seen that - will give it a try.
Cheers

@fxgenstudio
Copy link

I want to generate a city for my voxel game, do you have a simple example, other than knots, to start understand ? thanks.

@mxgmn
Copy link
Owner

mxgmn commented Aug 16, 2017

@procfxgen You mean a 3d example? 3d version is not released yet, so only Knots so far. Check out 6 2d example tilesets here, the algorithm is the same in all dimensions.

@fxgenstudio
Copy link

I play with knots 3d example, how to add ground ?

@mxgmn
Copy link
Owner

mxgmn commented Aug 16, 2017

@procfxgen Add ground.vox and ground.png, then in data.xml add the ground tile and vertical and horizontal adjacencies with existing tiles.

@fxgenstudio
Copy link

fxgenstudio commented Aug 18, 2017

Thanks, I have my ground titles now !
wfc_01
How to make "line" tile above "ground" titles ?
my "data.xml"

 <set` pixelsize="8" voxelsize="3">
   <tiles>
     <tile name="down" symmetry="T"/>
     <tile name="empty" symmetry="X"/>
     <tile name="line" symmetry="I"/>
     <tile name="turn" symmetry="L"/>
     <tile name="up" symmetry="T"/>
     <tile name="vertical" symmetry="X"/>
     <tile name="ground" symmetry="X"/>
   </tiles>
   <neighbors>
     <horizontal left="empty" right="empty"/>
     <horizontal left="empty" right="ground"/>
     <horizontal left="ground" right="up"/>
     <vertical left="empty" right="empty"/>
     <vertical left="empty" right="ground"/>
     <vertical left="ground" right="up"/>
   </neighbors>
   <subsets>
     <subset name="dense knots">
       <tile name="down" symmetry="T"/>
       <tile name="line" symmetry="I"/>
       <tile name="turn" symmetry="L"/>
       <tile name="up" symmetry="T"/>
       <tile name="vertical" symmetry="X"/>
       <tile name="ground" symmetry="X"/>
     </subset>
     <subset name="only turns">
       <tile name="turn" symmetry="L"/>
     </subset>
   </subsets>
 </set>

@mxgmn
Copy link
Owner

mxgmn commented Aug 18, 2017

@procfxgen Try this

<vertical left="empty" right="empty"/>
<vertical left="line" right="ground"/>
<vertical left="line" right="line"/>
<horizontal left="empty" right="empty"/>
<horizontal left="empty" right="line"/>
<horizontal left="empty" right="ground"/>

It should generate vertical columns.

@fxgenstudio
Copy link

sorry volume is empty ....

"vertical" correspond to blue axis (Z) and "horizontal" (X,Y) to red axis in magicavoxel ?

<set pixelsize="8" voxelsize="3">
  <tiles>
    <tile name="down" symmetry="T"/>
    <tile name="empty" symmetry="X"/>
    <tile name="line" symmetry="I"/>
    <tile name="turn" symmetry="L"/>
    <tile name="up" symmetry="T"/>
    <tile name="vertical" symmetry="X"/>
    <tile name="ground" symmetry="X"/>
  </tiles>
  <neighbors>
    <vertical left="empty" right="empty"/>
    <vertical left="line" right="ground"/>
    <vertical left="line" right="line"/>
    <horizontal left="empty" right="empty"/>
    <horizontal left="empty" right="line"/>
    <horizontal left="empty" right="ground"/>
  </neighbors>
  <subsets>
    <subset name="dense knots">
      <tile name="down" symmetry="T"/>
      <tile name="line" symmetry="I"/>
      <tile name="turn" symmetry="L"/>
      <tile name="up" symmetry="T"/>
      <tile name="vertical" symmetry="X"/>
      <tile name="ground" symmetry="X"/>
    </subset>
  </subsets>
</set>

@mxgmn
Copy link
Owner

mxgmn commented Aug 18, 2017

@procfxgen This data.xml

<set pixelsize="8" voxelsize="3">
	<tiles>
		<tile name="empty" symmetry="X"/>
		<tile name="vertical" symmetry="X"/>
		<tile name="g1" symmetry="X"/>
	</tiles>
	<neighbors>
		<vertical left="empty" right="empty"/>
		<horizontal left="empty" right="empty"/>
		<vertical left="vertical" right="g1"/>
		<vertical left="vertical" right="vertical"/>
		<horizontal left="empty" right="vertical"/>
		<horizontal left="empty" right="g1"/>
		<horizontal left="vertical" right="vertical"/>
		<horizontal left="g1" right="g1"/>
	</neighbors>
</set>

and this samples.xml

<samples>
	<sample name="Knots" X="10" Y="10" Z="10" periodic="False" screenshots="2"/>
</samples>

should generate vertical columns.

If you want 3d, I think it's better to wait for a proper 3d release in September-October, it'll be much easier to experiment with, or try VoxModSynth.

@mxgmn
Copy link
Owner

mxgmn commented Aug 18, 2017

@procfxgen Yes, vertical corresponds to blue in MV, left=top, right=bottom. Horizontal - to red, and then it mixes red and green with symmetries.

@nanodeath
Copy link
Contributor

@mxgmn, is there a way you can close and lock this issue? Right now it seems to get reused every time anyone has a question (and emailing 23 people in the process), when really those questions should be new issues. Thanks!

@mxgmn
Copy link
Owner

mxgmn commented Aug 18, 2017

@nanodeath Oh, didn't know about that, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests