Example #1
0
    private static void TickDump(Context cx, BehTree ai)
    {
        return;

        if (_cw == null || _cw.IsDone)
        {
            /*var theOut = new TheOut
             * {
             * Values = cx.Field.CalcValue(),
             * Infl = cx.Infl.CostMap.ToArray(),
             * Pacs = cx.Pacs,
             * // Predictions = ai.Predictions,
             * };*/
            var theOut = new TheOutState
            {
                // Field = cx.Field,
                Pacs = cx.Pacs,
            };
            theOut.Flags = BuildFlags(cx.Field);
            cx.Writer.Write(theOut);
            _cw = new ConsoleWriter(cx.Writer.Flush());
        }

        _cw?.Tick();
    }
Example #2
0
        private void TestBest(Simulator sim, TheOutState state)
        {
            var best = sim.RunBest(state.Field, state.Pacs);

            foreach (var path in best.Values)
            {
                Drawer.DrawPath(path, Color.Aqua);
            }

            SetImage(Drawer.Bmp);
        }
Example #3
0
        private void GenerateForTick(TheOutState state)
        {
            var sim = new Simulator(state.Field.Height, state.Field.Width);

            Generations = sim.Run(state.Field, state.Pacs);

            var bestVal = Generations.Max(s => s.Sum(p => p.Geathered));

            GenerationSlider.Value = Generations.FindIndex(s => s.Sum(p => p.Geathered) == bestVal);

            GenerationSlider.Maximum = Generations.Count - 1;
            DrawGeneration();
        }
Example #4
0
 private void RestoreField(TheOutState state)
 {
     state.Field = new GameField
     {
         Grid = new Cell[state.Flags.GetLength(0), state.Flags.GetLength(1)]
     };
     for (int i = 0; i < state.Flags.GetLength(0); i++)
     {
         for (int j = 0; j < state.Flags.GetLength(1); j++)
         {
             state.Field.Grid[i, j].SetFlag((CellFlags)state.Flags[i, j]);
         }
     }
 }