public void Mirror() { propagator7.Clear(); propagator7.Run(); Check(propagator7); }
public void Mirror() { propagatorMirror.Clear(); propagatorMirror.Run(); Check(propagatorMirror); }
public void Count() { propagator6.Clear(); propagator6.Run(); Check(propagator6); }
public void Count() { propagatorCount.Clear(); propagatorCount.Run(); Check(propagatorCount); }
public void Path() { propagator5.Clear(); propagator5.Run(); Check(propagator5); if (false) { var v = propagator5.ToValueArray <string>(); for (var y = 0; y < v.Topology.Height; y++) { for (var x = 0; x < v.Topology.Width; x++) { System.Console.Write(v.Get(x, y)); } System.Console.WriteLine(); } } }
public void ProcessItem() { if (config.Dest == null) { throw new ConfigurationException("Dest attribute must be set"); } var directory = config.BaseDirectory; var dest = Path.Combine(directory, config.Dest); var contdest = Path.ChangeExtension(dest, ".contradiction" + Path.GetExtension(dest)); // TODO: Neat way to do this without mutability? factory.TilesByName = new Dictionary <string, Tile>(); SampleSet sampleSet; if (config.SrcType == SrcType.Sample) { sampleSet = LoadSample(); factory.TilesByName = sampleSet.TilesByName ?? factory.TilesByName; } else { sampleSet = LoadFileSet(); } var directions = sampleSet.Directions; var topology = factory.GetOutputTopology(directions); var tileRotation = factory.GetTileRotation(config.RotationTreatment, topology); var model = factory.GetModel(directions, sampleSet, tileRotation); var constraints = factory.GetConstraints(directions, tileRotation); System.Console.WriteLine($"Processing {dest}"); var propagator = new TilePropagator(model, topology, config.Backtrack, constraints: constraints.ToArray()); Resolution status = propagator.Status; for (var retry = 0; retry < 5; retry++) { if (retry != 0) { status = propagator.Clear(); } if (status == Resolution.Contradiction) { System.Console.WriteLine($"Found contradiction in initial conditions, retrying"); continue; } if (config.Animate) { status = RunAnimate(model, propagator, dest, sampleSet.ExportOptions); } else { status = Run(propagator); } if (status == Resolution.Contradiction) { System.Console.WriteLine($"Found contradiction, retrying"); continue; } break; } Directory.CreateDirectory(Path.GetDirectoryName(dest)); if (status == Resolution.Decided) { System.Console.WriteLine($"Writing {dest}"); Exporter.Export(model, propagator, dest, config, sampleSet.ExportOptions); File.Delete(contdest); } else { System.Console.WriteLine($"Writing {contdest}"); Exporter.Export(model, propagator, contdest, config, sampleSet.ExportOptions); File.Delete(dest); } }
public void Chess() { propagator2.Clear(); propagator2.Run(); }
public void Free() { propagator1.Clear(); propagator1.Run(); }
public void Castle() { propagator3.Clear(); propagator3.Run(); }
public void ProcessItem() { if (config.Dest == null) { throw new System.Exception("dest attribute must be set"); } var directory = config.BaseDirectory; var dest = Path.Combine(directory, config.Dest); var contdest = Path.ChangeExtension(dest, ".contradiction" + Path.GetExtension(dest)); SampleSet sampleSet; if (config.SrcType == SrcType.Sample) { sampleSet = LoadSample(); } else { sampleSet = LoadFileSet(); } var directions = sampleSet.Directions; var samples = sampleSet.Samples; var is3d = directions.Type == DirectionsType.Cartesian3d; var topology = new Topology(directions, config.Width, config.Height, is3d ? config.Depth : 1, config.PeriodicX, config.PeriodicY, config.PeriodicZ); var tileRotation = GetTileRotation(config.Tiles, config.RotationTreatment, topology); var model = GetModel(config, directions, samples, tileRotation); // Setup adjacencies if (config.Adjacencies != null) { var adjacentModel = model as AdjacentModel; if (adjacentModel == null) { throw new Exception("Setting adjacencies is only supported for the \"adjacent\" model."); } foreach (var a in config.Adjacencies) { var srcAdj = a.Src.Select(Parse).Select(tileRotation.Canonicalize).ToList(); var destAdj = a.Dest.Select(Parse).Select(tileRotation.Canonicalize).ToList(); adjacentModel.AddAdjacency(srcAdj, destAdj, a.X, a.Y, a.Z, config.RotationalSymmetry, config.ReflectionalSymmetry, tileRotation); } // If there are no samples, set frequency to 1 for everything mentioned in this block foreach (var tile in adjacentModel.PatternsToTiles.Values) { adjacentModel.SetFrequency(tile, 1); } } // Setup tiles if (config.Tiles != null) { foreach (var tile in config.Tiles) { var value = Parse(tile.Value); if (tile.MultiplyFrequency != null) { var cf = tile.MultiplyFrequency.Trim(); double cfd; if (cf.EndsWith("%")) { cfd = double.Parse(cf.TrimEnd('%')) / 100; } else { cfd = double.Parse(cf); } model.MultiplyFrequency(value, cfd); } } } // Setup constraints var constraints = GetConstraints(is3d); System.Console.WriteLine($"Processing {dest}"); var propagator = new TilePropagator(model, topology, config.Backtrack, constraints: constraints.ToArray()); Resolution status = propagator.Status; for (var retry = 0; retry < 5; retry++) { if (retry != 0) { status = propagator.Clear(); } if (status == Resolution.Contradiction) { System.Console.WriteLine($"Found contradiction in initial conditions, retrying"); continue; } if (config.Animate) { status = RunAnimate(model, propagator, dest, sampleSet.ExportOptions); } else { status = propagator.Run(); } if (status == Resolution.Contradiction) { System.Console.WriteLine($"Found contradiction, retrying"); continue; } break; } Directory.CreateDirectory(Path.GetDirectoryName(dest)); if (status == Resolution.Decided) { System.Console.WriteLine($"Writing {dest}"); Exporter.Export(model, propagator, dest, config, sampleSet.ExportOptions); File.Delete(contdest); } else { System.Console.WriteLine($"Writing {contdest}"); Exporter.Export(model, propagator, contdest, config, sampleSet.ExportOptions); File.Delete(dest); } }
public void Wang() { propagatorWang.Clear(); propagatorWang.Run(); }