forked from mxgmn/WaveFunctionCollapse
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
Latest commit
71 lines (61 loc) · 2.74 KB
/
Copy pathProgram.cs
File metadata and controls
71 lines (61 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2016 Maxim Gumin, The MIT License (MIT)
usingSystem;
usingSystem.Xml.Linq;
usingSystem.Diagnostics;
staticclassProgram
{
staticvoidMain()
{
Stopwatchsw=Stopwatch.StartNew();
varfolder=System.IO.Directory.CreateDirectory("output");
foreach(varfileinfolder.GetFiles())file.Delete();
Randomrandom=new();
XDocumentxdoc=XDocument.Load("samples.xml");
foreach(XElementxeleminxdoc.Root.Elements("overlapping","simpletiled"))
{
Modelmodel;
stringname=xelem.Get<string>("name");
Console.WriteLine($"< {name}");
boolisOverlapping=xelem.Name=="overlapping";
intsize=xelem.Get("size",isOverlapping?48:24);
intwidth=xelem.Get("width",size);
intheight=xelem.Get("height",size);
boolperiodic=xelem.Get("periodic",false);
stringheuristicString=xelem.Get<string>("heuristic");
varheuristic=heuristicString=="Scanline"?Model.Heuristic.Scanline:(heuristicString=="MRV"?Model.Heuristic.MRV:Model.Heuristic.Entropy);
if(isOverlapping)
{
intN=xelem.Get("N",3);
boolperiodicInput=xelem.Get("periodicInput",true);
intsymmetry=xelem.Get("symmetry",8);
boolground=xelem.Get("ground",false);
model=newOverlappingModel(name,N,width,height,periodicInput,periodic,symmetry,ground,heuristic);
}
else
{
stringsubset=xelem.Get<string>("subset");
boolblackBackground=xelem.Get("blackBackground",false);
model=newSimpleTiledModel(name,subset,width,height,periodic,blackBackground,heuristic);
}
for(inti=0;i<xelem.Get("screenshots",2);i++)
{
for(intk=0;k<10;k++)
{
Console.Write("> ");
intseed=random.Next();
boolsuccess=model.Run(seed,xelem.Get("limit",-1));
if(success)
{
Console.WriteLine("DONE");
model.Save($"output/{name}{seed}.png");
if(modelisSimpleTiledModelstmodel&&xelem.Get("textOutput",false))
System.IO.File.WriteAllText($"output/{name}{seed}.txt",stmodel.TextOutput());
break;
}
elseConsole.WriteLine("CONTRADICTION");
}
}
}
Console.WriteLine($"time = {sw.ElapsedMilliseconds}");
}
}