public void GeneratePocketWorldTest() { Graph worldGraph = YamlGraphStorage.LoadGraph(FileUtilities.LoadFile("graph_pokemon_map.yaml")); Blackboard blackboard = new Blackboard(); List <WfcGraphTile <WorldData> > availableTiles = PokeWorldGraphTiles.GetPocketWorldGraphTiles(blackboard); WfcGraphSpace <WorldData> wfcGraphSpace = new WfcGraphSpace <WorldData>(worldGraph, availableTiles, blackboard); wfcGraphSpace.PropagateGlobally(); while (!wfcGraphSpace.GenerationFinished()) { //Console.WriteLine("--- Current Map: ---"); //Debugging.PrintWfcGraphModules<WorldData>(worldGraph.Nodes); Console.WriteLine("----"); WfcCell <WfcGraphTile <WorldData>, int> selectedCell = wfcGraphSpace.SelectCell(cell => Int32.MaxValue - cell.AvailableModules.Count); Console.WriteLine($"Selected Position: {selectedCell.Position}"); wfcGraphSpace.Collapse(selectedCell, (space, tile) => { Console.WriteLine($"Selected Type: {tile.Graph.Name}"); wfcGraphSpace.Blackboard.Increment($"{tile.Graph.Name}_count", -1); }); wfcGraphSpace.PropagateGlobally(); } Console.WriteLine("--- Final Map: ---"); Debugging.PrintWfcGraphModules <WorldData>(worldGraph.Entities); Console.WriteLine("---"); Console.WriteLine($"Generation finished! Valid Map: {wfcGraphSpace.GenerationSuccessful()}"); }
public void GenerateSimpleGraphWorldTest() { Graph worldGraph = YamlGraphStorage.LoadGraph(FileUtilities.LoadFile("graph_map_simple.yaml")); Blackboard blackboard = new Blackboard(); List <WfcGraphTile <WorldData> > availableTiles = PokeWorldGraphTiles.GetPocketWorldGraphTiles(blackboard, 3, 2, 0); WfcGraphSpace <WorldData> wfcGraphSpace = new WfcGraphSpace <WorldData>(worldGraph, availableTiles, blackboard); while (!wfcGraphSpace.GenerationFinished()) { Console.WriteLine("--- Current Map: ---"); Debugging.PrintWfcGraphModules <WorldData>(worldGraph.Entities); Console.WriteLine("----"); WfcCell <WfcGraphTile <WorldData>, int> selectedCell = wfcGraphSpace.SelectCell(); Console.WriteLine($"Selected Position: {selectedCell.Position}"); wfcGraphSpace.Collapse(selectedCell, (space, tile) => { Console.WriteLine($"Selected Type: {tile.Graph.Name}"); wfcGraphSpace.Blackboard.Increment($"{tile.Graph.Name}_count", -1); }); } Console.WriteLine("--- Final Map: ---"); Debugging.PrintWfcGraphModules <WorldData>(worldGraph.Entities); Console.WriteLine("Generation finished!"); }