Ejemplo n.º 1
0
 public LevelConfiguration(TweakPicker tp, SegPicker sp, OptimizationSetup optimizationSetup, InitialWanderSetup iws)
 {
     TweakPicker        = tp;
     SegPicker          = sp;
     OptimizationSetup  = optimizationSetup;
     InitialWanderSetup = iws;
 }
Ejemplo n.º 2
0
        public string GetStr()
        {
            var os = OptimizationSetup.GetStr();

            if (string.IsNullOrWhiteSpace(os))
            {
                os = "";
            }
            else
            {
                os = " " + os;
            }
            return($"{TweakPicker.GetStr()} {SegPicker.GetName()}{os}");
        }
Ejemplo n.º 3
0
        static void CreateLevel(LevelGenerationConfig config)
        {
            var levelstem = $"../../../output/{config.x}x{config.y}";
            var csvpath   = levelstem + "/results.csv";
            var csv       = new CsvWriter(csvpath);

            if (!System.IO.Directory.Exists(levelstem))
            {
                System.IO.Directory.CreateDirectory($"{levelstem}");
            }

            var runcount = 0;
            //var ws = new InitialWanderSetup(steplimit:2, startPoint:(1,1), gomax:true);
            var ws = new InitialWanderSetup();

            foreach (var tweakPicker in TweakPickers.GetPickers(config.tweakPickerName))
            {
                foreach (var el in config.genLimits)
                {
                    var os = new OptimizationSetup();
                    os.GlobalTweakLim = el;

                    foreach (var segPicker in SegPickers.GetSegPickers(config.segPickerName))
                    {
                        runcount++;

                        var lc  = new LevelConfiguration(tweakPicker, segPicker, os, ws);
                        var log = new Log(lc);

                        var rnd   = new System.Random(config.seed);
                        var level = new Level(lc, config.x, config.y, rnd, config.seed);

                        level.InitialWander(lc);

                        //bit awkward to do it here - it needs a better guarantee of finding the best seg.
                        segPicker.Init(config.seed, level);
                        tweakPicker.Init(config.seed);
                        var st         = Stopwatch.StartNew();
                        var tweakStats = level.RepeatedlyTweak(config.saveTweaks, config.saveEvery.Value, st);
                        var elapsed    = st.Elapsed;

                        //before doing any outputting, validate the level.
                        DoDebug(level, show: false, validateBoard: true);
                        AfterLevelGenerated(level, config, levelstem, lc, tweakStats, elapsed, csv, log, runcount);
                    }
                }
            }
        }