// Start is called before the first frame update void Start() { //prepare //startgeneration generationManager = new GenerationManager(UnityToNum(origin), prefabConditions); generationManager.ChooseFittingUnity = ChooseFittingUnity; generationManager.Generate(); }
public static void Main(string[] args) { Console.WriteLine("Hsmm Error Sources Generation Application started"); Console.WriteLine( "Please, specify Pseudo Random Generator mode as a number from the list:\r\n" + " 0 - Standart; \r\n" + " 1 - RC4; \r\n" + " 2 - Security"); PseudoRandomGeneratorType prngMode = PromptParseUtils.ParsePseudoRandomGeneratorType(Console.ReadLine()); Task.Factory.StartNew(() => { bool ifExit = false; while (!ifExit) { Console.WriteLine( "Please, specify generation parameters"); string jsonModel = null; while (jsonModel == null) { Console.WriteLine( "Specify path to model file:"); string pathToFile = Console.ReadLine(); jsonModel = ParseModelFile(pathToFile); } Console.WriteLine( "Specify desired sequence length:"); int sequenceLength = Convert.ToInt32(Console.ReadLine()); string outputPath = null; while (outputPath == null) { Console.WriteLine("Specify output file path:"); outputPath = ParseOutputPath(Console.ReadLine()); } Console.WriteLine("Starting generation"); GenerationManager manager = new GenerationManager(prngMode); GenerationResult result = manager.Generate(jsonModel, sequenceLength); if (result.HasErrors()) { Console.WriteLine("Generation failed due to the following errors:" + String.Join(", ", result.Errors.ToArray())); } else { WriteOutputToFile(outputPath, result.Value); Console.WriteLine("Generation has been successfully completed. See result in " + outputPath); } Console.WriteLine("Do you want to continue? (y/n)"); ifExit = !PromptParseUtils.ParseBoolean(Console.ReadLine()); } Console.WriteLine("Press Ctrl+C to exit..."); }); Console.CancelKeyPress += new ConsoleCancelEventHandler(OnExit); Closing.WaitOne(); }
public GenerationInfo GetGeneration(int seed) { GenerationInfo generation = null; int threshold = 50; while (threshold > 0) { threshold--; generation = GenerationManager.Generate( 0, DefGenerationSize, x => new[] { x.Cast <RoomInfo>().First(y => y != null && y.Position.y > 28 && y.Position.x > 14 && y.Position.x < 16), x.Cast <RoomInfo>().First(y => y != null && y.Position.y < 2 && y.Position.x > 14 && y.Position.x < 16) }, (random, rooms) => { for (int x = 0; x < rooms.GetLength(0); x++) { for (int y = 0; y < rooms.GetLength(1); y++) { float procent = (-(1f / 3f) * (float)Math.Pow(x - 15, 2) + 100) / 100f; if (random.NextDouble() > procent) { rooms[x, y] = null; } } } }, 0.55f, 0.4f, new Dictionary <Vector2Int, float>() { { new Vector2Int(1, 2), 0.3f }, { new Vector2Int(1, 3), 0.3f }, { new Vector2Int(1, 4), 0.2f }, { new Vector2Int(2, 1), 0.5f }, { new Vector2Int(3, 1), 0.3f }, { new Vector2Int(4, 1), 0.2f }, { new Vector2Int(2, 2), 0.2f }, { new Vector2Int(2, 3), 0.1f }, { new Vector2Int(4, 2), 0.1f }, { new Vector2Int(3, 2), 0.1f }, { new Vector2Int(3, 3), 0.1f }, { new Vector2Int(4, 4), 0.05f }, }, new List <Func <GenerationInfo, List <RoomInfo> > >(), 1, seed // 1082609359 for test ); if (generation.CellsCount >= GameSettings.SettingMinGenerationCellCount.Value) { Debug.Log("ReservedCount: " + generation.ReservedCount); Debug.Log("RoomsCount: " + generation.RoomsCount); Debug.Log("CellsCount: " + generation.CellsCount); Debug.Log("GatesCount: " + generation.GatesCount); Debug.Log("Seed: " + generation.Seed); break; } Debug.Log("Regenerate"); seed = new System.Random(seed).Next(); } if (threshold <= 0) { throw new Exception("incorrect filters for the current generation"); } return(generation); }