Skip to content

Commit

Permalink
trivial symmetry support, FloorPlan tileset
Browse files Browse the repository at this point in the history
  • Loading branch information
mxgmn committed Oct 8, 2020
1 parent 014e66f commit 8d819f2
Show file tree
Hide file tree
Showing 22 changed files with 189 additions and 11 deletions.
13 changes: 11 additions & 2 deletions SimpleTiledModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SimpleTiledModel(string name, string subsetName, int width, int height, b
bool unique = xroot.Get("unique", false);

List<string> subset = null;
if (subsetName != default(string))
if (subsetName != null)
{
XElement xsubset = xroot.Element("subsets").Elements("subset").FirstOrDefault(x => x.Get<string>("name") == subsetName);
if (xsubset == null) Console.WriteLine($"ERROR: subset {subsetName} is not found");
Expand All @@ -45,6 +45,7 @@ Color[] tile(Func<int, int, Color> f)
};

Color[] rotate(Color[] array) => tile((x, y) => array[tilesize - 1 - y + x * tilesize]);
Color[] reflect(Color[] array) => tile((x, y) => array[tilesize - 1 - x + y * tilesize]);

tiles = new List<Color[]>();
tilenames = new List<string>();
Expand Down Expand Up @@ -86,6 +87,12 @@ Color[] tile(Func<int, int, Color> f)
a = i => 1 - i;
b = i => 1 - i;
}
else if (sym == 'F')
{
cardinality = 8;
a = i => i < 4 ? (i + 1) % 4 : 4 + (i - 1) % 4;
b = i => i < 4 ? i + 4 : i - 4;
}
else
{
cardinality = 1;
Expand Down Expand Up @@ -132,7 +139,8 @@ Color[] tile(Func<int, int, Color> f)

for (int t = 1; t < cardinality; t++)
{
tiles.Add(rotate(tiles[T + t - 1]));
if (t <= 3) tiles.Add(rotate(tiles[T + t - 1]));
if (t >= 4) tiles.Add(reflect(tiles[T + t - 4]));
tilenames.Add($"{tilename} {t}");
}
}
Expand Down Expand Up @@ -194,6 +202,7 @@ Color[] tile(Func<int, int, Color> f)
for (int t2 = 0; t2 < T; t2++) if (tp[t2]) sp.Add(t2);

int ST = sp.Count;
if (ST == 0) Console.WriteLine($"ERROR: tile {tilenames[t1]} has no neighbors in direction {d}");
propagator[d][t1] = new int[ST];
for (int st = 0; st < ST; st++) propagator[d][t1][st] = sp[st];
}
Expand Down
2 changes: 1 addition & 1 deletion Stuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static long ToPower(this int a, int n)
return product;
}

public static T Get<T>(this XElement xelem, string attribute, T defaultT = default(T))
public static T Get<T>(this XElement xelem, string attribute, T defaultT = default)
{
XAttribute a = xelem.Attribute(attribute);
return a == null ? defaultT : (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(a.Value);
Expand Down
20 changes: 12 additions & 8 deletions samples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
<simpletiled name="Knots" subset="Fabric" width="24" height="24" periodic="True"/>
<simpletiled name="Knots" subset="Dense Fabric" width="24" height="24" periodic="True"/>
<simpletiled name="Rooms" width="30" height="30"/>
<simpletiled name="Circles" width="24" height="24"/>
<simpletiled name="Circles" subset="Large Circles" width="24" height="24"/>
<simpletiled name="Circles" subset="Large Circles and Solid" width="24" height="24"/>
<simpletiled name="Circles" subset="No Solid" width="24" height="24"/>

<overlapping name="Cat" N="3" symmetry="2" periodic="True" width="80" height="80"/>
<simpletiled name="Circles" width="24" height="24" screenshots="1"/>
<simpletiled name="Circles" subset="Large Circles" width="24" height="24" screenshots="1"/>
<simpletiled name="Circles" subset="Large Circles and Solid" width="24" height="24" screenshots="1"/>
<simpletiled name="Circles" subset="No Solid" width="24" height="24" screenshots="1"/>
<simpletiled name="FloorPlan" width="20" height="20" screenshots="3"/>

<overlapping name="Cat" N="3" symmetry="2" periodic="True" width="80" height="80"/>
<overlapping name="Cats" N="3" symmetry="2" periodic="True"/>
<overlapping name="Skyline2" N="3" symmetry="2" periodic="True" ground="-1"/>
<overlapping name="Angular" N="3" periodic="True"/>
Expand All @@ -66,8 +67,11 @@
<overlapping name="SmileCity" N="3" periodic="True"/>
<overlapping name="Spirals" N="3" periodic="True"/>
<overlapping name="Town" N="3" periodic="True"/>

<overlapping name="3Bricks" N="3" symmetry="1" periodic="True"/>
<overlapping name="Wall" N="2" symmetry="1" screenshots="1"/>
<overlapping name="Wall" N="3" symmetry="2" screenshots="1"/>
<overlapping name="Wall" N="3" screenshots="1"/>

<overlapping name="3Bricks" N="3" symmetry="1" periodic="True"/>
<overlapping name="Village" N="3" symmetry="2" limit="50" periodic="True"/>
<simpletiled name="Summer" width="15" height="15" periodic="False" limit="15"/>

Expand Down
165 changes: 165 additions & 0 deletions samples/FloorPlan/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<set size="9">
<tiles>
<tile name="empty" symmetry="X" weight="0.1"/>
<tile name="out" symmetry="L"/>
<tile name="wall" symmetry="T"/>
<tile name="in" symmetry="L"/>
<tile name="floor" symmetry="X"/>
<tile name="halfglass" symmetry="F"/>
<tile name="glass" symmetry="T"/>

<tile name="walldiv" symmetry="T"/>
<tile name="divturn" symmetry="L"/>
<tile name="div" symmetry="I"/>
<tile name="divt" symmetry="T"/>
<tile name="stairs" symmetry="T"/>

<tile name="w" symmetry="T"/>
<tile name="window" symmetry="T"/>
<tile name="door" symmetry="I" weight="0.5"/>
<tile name="vent" symmetry="X" weight="0.5"/>
<tile name="table" symmetry="X" weight="0.8"/>
</tiles>
<neighbors>
<neighbor left="empty" right="empty"/>
<neighbor left="empty" right="out"/>
<neighbor left="empty" right="wall 3"/>
<neighbor left="out" right="wall"/>
<neighbor left="wall" right="wall"/>
<neighbor left="wall" right="in"/>
<neighbor left="wall 3" right="floor"/>
<neighbor left="in" right="floor"/>
<neighbor left="floor" right="floor"/>

<neighbor left="empty" right="halfglass 3"/>
<neighbor left="out" right="halfglass"/>
<neighbor left="in 1" right="halfglass"/>
<neighbor left="halfglass 3" right="floor"/>
<neighbor left="halfglass" right="glass"/>
<neighbor left="glass" right="glass"/>
<neighbor left="empty" right="glass 3"/>
<neighbor left="glass 3" right="floor"/>

<neighbor left="empty" right="walldiv 3"/>
<neighbor left="out" right="walldiv"/>
<neighbor left="wall" right="walldiv"/>
<neighbor left="walldiv" right="in"/>
<neighbor left="walldiv" right="halfglass"/>
<neighbor left="divturn" right="walldiv 1"/>
<neighbor left="div" right="walldiv 1"/>
<neighbor left="divt" right="walldiv 1"/>

<neighbor left="wall 3" right="divturn"/>
<neighbor left="in" right="divturn"/>
<neighbor left="in" right="divturn 3"/>
<neighbor left="floor" right="divturn"/>
<neighbor left="halfglass 3" right="divturn"/>
<neighbor left="halfglass 3" right="divturn 3"/>
<neighbor left="glass 3" right="divturn"/>
<neighbor left="divturn 1" right="divturn"/>
<neighbor left="divturn 2" right="divturn"/>

<neighbor left="wall 3" right="div 1"/>
<neighbor left="in" right="div 1"/>
<neighbor left="floor" right="div 1"/>
<neighbor left="halfglass 3" right="div 1"/>
<neighbor left="glass 3" right="div 1"/>
<neighbor left="div 1" right="divturn"/>
<neighbor left="divturn" right="div"/>
<neighbor left="div" right="div"/>
<neighbor left="div 1" right="div 1"/>

<neighbor left="wall 3" right="divt 1"/>
<neighbor left="in" right="divt 1"/>
<neighbor left="floor" right="divt 1"/>
<neighbor left="halfglass 3" right="divt 1"/>
<neighbor left="glass 3" right="divt 1"/>
<neighbor left="divturn 1" right="divt 1"/>
<neighbor left="divturn" right="divt"/>
<neighbor left="div 1" right="divt 1"/>
<neighbor left="div" right="divt"/>
<neighbor left="div" right="divt 3"/>
<neighbor left="divt 3" right="divt 1"/>
<neighbor left="divt" right="divt 2"/>

<neighbor left="wall 3" right="stairs 1"/>
<neighbor left="in" right="stairs 1"/>
<neighbor left="floor" right="stairs 1"/>
<neighbor left="halfglass 3" right="stairs 1"/>
<neighbor left="glass 3" right="stairs 1"/>
<neighbor left="stairs 3" right="divturn"/>
<neighbor left="divturn" right="stairs"/>
<neighbor left="div 1" right="stairs 1"/>
<neighbor left="div" right="stairs"/>
<neighbor left="divt 3" right="stairs 1"/>
<neighbor left="divt 2" right="stairs"/>
<neighbor left="stairs 3" right="stairs 1"/>
<neighbor left="stairs 1" right="stairs 3"/>

<neighbor left="empty" right="w 3"/>
<neighbor left="out" right="w"/>
<neighbor left="w" right="in"/>
<neighbor left="floor" right="w 1"/>
<neighbor left="walldiv" right="w"/>
<neighbor left="w" right="w"/>
<neighbor left="w 3" right="divturn"/>
<neighbor left="w 3" right="div 1"/>
<neighbor left="w 3" right="divt 1"/>
<neighbor left="w 3" right="stairs 1"/>
<neighbor left="empty" right="window 3"/>
<neighbor left="out" right="window"/>
<neighbor left="window" right="in"/>
<neighbor left="floor" right="window 1"/>
<neighbor left="walldiv" right="window"/>
<neighbor left="window" right="window"/>
<neighbor left="window 3" right="divturn"/>
<neighbor left="window 3" right="div 1"/>
<neighbor left="window 3" right="divt 1"/>
<neighbor left="window 3" right="stairs 1"/>

<neighbor left="wall 3" right="door 1"/>
<neighbor left="in" right="door 1"/>
<neighbor left="floor" right="door 1"/>
<neighbor left="halfglass 3" right="door 1"/>
<neighbor left="glass 3" right="door 1"/>
<neighbor left="walldiv 3" right="door"/>
<neighbor left="w" right="door 1"/>
<neighbor left="window" right="door 1"/>
<neighbor left="door 1" right="divturn"/>
<neighbor left="divturn" right="door"/>
<neighbor left="div 1" right="door 1"/>
<neighbor left="div" right="door"/>
<neighbor left="divt 3" right="door 1"/>
<neighbor left="divt" right="door"/>
<neighbor left="divt 1" right="door"/>
<neighbor left="stairs 3" right="door 1"/>
<neighbor left="stairs" right="door"/>
<neighbor left="door 1" right="door 1"/>
<neighbor left="door" right="door"/>

<neighbor left="wall 3" right="vent"/>
<neighbor left="in" right="vent"/>
<neighbor left="halfglass 3" right="vent"/>
<neighbor left="glass 3" right="vent"/>
<neighbor left="w 3" right="vent"/>
<neighbor left="window 3" right="vent"/>
<neighbor left="vent" right="divturn"/>
<neighbor left="div 1" right="vent"/>
<neighbor left="divt 3" right="vent"/>
<neighbor left="vent" right="vent"/>
<neighbor left="stairs 3" right="vent"/>
<neighbor left="door 1" right="vent"/>
<neighbor left="wall 3" right="table"/>
<neighbor left="in" right="table"/>
<neighbor left="halfglass 3" right="table"/>
<neighbor left="glass 3" right="table"/>
<neighbor left="w 3" right="table"/>
<neighbor left="window 3" right="table"/>
<neighbor left="table" right="divturn"/>
<neighbor left="div 1" right="table"/>
<neighbor left="divt 3" right="table"/>
<neighbor left="table" right="table"/>
<neighbor left="stairs 3" right="table"/>
<neighbor left="door 1" right="table"/>
</neighbors>
</set>
Binary file added samples/FloorPlan/div.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/divt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/divturn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/floor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/glass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/halfglass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/stairs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/vent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/walldiv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/FloorPlan/window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/Wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8d819f2

Please sign in to comment.