-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Program.cs
71 lines (61 loc) · 2.74 KB
/
Program.cs
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)
using System;
using System.Xml.Linq;
using System.Diagnostics;
static class Program
{
static void Main()
{
Stopwatch sw = Stopwatch.StartNew();
var folder = System.IO.Directory.CreateDirectory("output");
foreach (var file in folder.GetFiles()) file.Delete();
Random random = new();
XDocument xdoc = XDocument.Load("samples.xml");
foreach (XElement xelem in xdoc.Root.Elements("overlapping", "simpletiled"))
{
Model model;
string name = xelem.Get<string>("name");
Console.WriteLine($"< {name}");
bool isOverlapping = xelem.Name == "overlapping";
int size = xelem.Get("size", isOverlapping ? 48 : 24);
int width = xelem.Get("width", size);
int height = xelem.Get("height", size);
bool periodic = xelem.Get("periodic", false);
string heuristicString = xelem.Get<string>("heuristic");
var heuristic = heuristicString == "Scanline" ? Model.Heuristic.Scanline : (heuristicString == "MRV" ? Model.Heuristic.MRV : Model.Heuristic.Entropy);
if (isOverlapping)
{
int N = xelem.Get("N", 3);
bool periodicInput = xelem.Get("periodicInput", true);
int symmetry = xelem.Get("symmetry", 8);
bool ground = xelem.Get("ground", false);
model = new OverlappingModel(name, N, width, height, periodicInput, periodic, symmetry, ground, heuristic);
}
else
{
string subset = xelem.Get<string>("subset");
bool blackBackground = xelem.Get("blackBackground", false);
model = new SimpleTiledModel(name, subset, width, height, periodic, blackBackground, heuristic);
}
for (int i = 0; i < xelem.Get("screenshots", 2); i++)
{
for (int k = 0; k < 10; k++)
{
Console.Write("> ");
int seed = random.Next();
bool success = model.Run(seed, xelem.Get("limit", -1));
if (success)
{
Console.WriteLine("DONE");
model.Save($"output/{name} {seed}.png");
if (model is SimpleTiledModel stmodel && xelem.Get("textOutput", false))
System.IO.File.WriteAllText($"output/{name} {seed}.txt", stmodel.TextOutput());
break;
}
else Console.WriteLine("CONTRADICTION");
}
}
}
Console.WriteLine($"time = {sw.ElapsedMilliseconds}");
}
}