public void TestGenerateMediumGraphSpace()
        {
            List <Tuple <int, int> > connections = new ();

            connections.AddRange(SeriesGenerator.PairSeries(0, 5, true));
            connections.AddRange(SeriesGenerator.PairSeries(6, 11, true));
            connections.Add(new Tuple <int, int>(5, 11));
            connections.Add(new Tuple <int, int>(2, 8));

            Graph connectionGraph = GraphBuilder.BuildGraph("Connected Rings Graph (o=o)", 12, connections);

            string content = YamlGraphStorage.SaveGraph(connectionGraph);

            FileUtilities.WriteFile("graph_map_medium.yaml", "./", content);

            // test save and load in the same order
            Graph g = YamlGraphStorage.LoadGraph(content);

            for (int i = 0; i < g.Entities.Count; i++)
            {
                Assert.AreEqual($"Location {i+1}", g.Entities[i].Name);
            }
            Layer?wfcNeighborLayer = g.GetLayer("WfcNeighborLayer");

            Assert.NotNull(wfcNeighborLayer, "Expected to find the WfcNeighborLayer!");
        }
        public void TestGenerateComplexGraphSpace()
        {
            Graph connectionGraph = new Graph("Pokemon Region Graph");

            // Add Nodes
            for (int i = 0; i < 43; i++)
            {
                Entity entity = new($"Location {i}", connectionGraph);
                connectionGraph.Entities.Add(entity);
            }

            // Add WfcNeighbor Layer
            Layer neighborLayer = new("WfcNeighborLayer");

            connectionGraph.AddLayer(neighborLayer);

            List <Tuple <int, int> > connections = new ();

            connections.AddRange(SeriesGenerator.PairSeries(0, 31, true));
            //"victory road"
            connections.Add(new(2, 32));
            connections.AddRange(SeriesGenerator.PairSeries(32, 35));
            //"bills house"
            connections.Add(new(10, 36));
            connections.AddRange(SeriesGenerator.PairSeries(36, 38));
            //"saffron" - "cerulean"
            connections.AddRange(SeriesGenerator.PairWise(new[] { 10, 39, 20 }));
            //"saffron" - "lavender"
            connections.AddRange(SeriesGenerator.PairWise(new[] { 20, 40, 14 }));
            //"Fuschia" - "verm/lavender"
            connections.AddRange(SeriesGenerator.PairWise(new[] { 26, 41, 42, 16 }));

            foreach (var(from, to) in connections)
            {
                Assert.AreEqual($"Location {from}", connectionGraph.Entities[from].Name);
                neighborLayer.AddRelation(
                    connectionGraph.Entities[from], connectionGraph.Entities[to],
                    $"Connection from {from} to {to}");
            }

            string content = YamlGraphStorage.SaveGraph(connectionGraph);

            FileUtilities.WriteFile("graph_pokemon_map.yaml", "./", content);

            // test save and load in the same order
            Graph g = YamlGraphStorage.LoadGraph(content);

            for (int i = 0; i < g.Entities.Count; i++)
            {
                Assert.AreEqual($"Location {i}", g.Entities[i].Name);
            }
            Layer?wfcNeighborLayer = g.GetLayer("WfcNeighborLayer");

            Assert.NotNull(wfcNeighborLayer, "Expected to find the WfcNeighborLayer!");
        }
Exemple #3
0
 public IEnumerable <float> GivenSeries()
 {
     series = SeriesGenerator.OverallSeries(firstNumber, growRate, length);
     return(series);
 }