Пример #1
0
        public List <GameSimulationResult> SimulateGame(List <IAi> gamers, Map map, Settings settings)
        {
            var gameSimulator = new GameSimulator(map, settings, eatExceptions);

            gameSimulator.StartGame(gamers);
            var state = gameSimulator.NextMove();

            var turnTime = new StatValue();

            while (!state.IsGameOver)
            {
                var lastMove = state.PreviousMoves.Last();

                if (!silent)
                {
                    Console.WriteLine($"{lastMove}");
                }

                var time = Stopwatch.StartNew();

                state = gameSimulator.NextMove();

                turnTime.Add(time.ElapsedMilliseconds);
            }
            map = state.CurrentMap;
            return(gamers
                   .Zip(gameSimulator.Futures, (ai, futures) => new { Gamer = ai, Futures = futures })
                   .Select((e, i) => new GameSimulationResult(
                               e.Gamer,
                               scoreCalculator.GetScoreData(i, state.CurrentMap, e.Futures),
                               gameSimulator.GetLastException(e.Gamer),
                               (double)map.OptionsUsed.GetOrDefaultNoSideEffects(i, 0) / map.Mines.Length,
                               turnTime))
                   .ToList());
        }
Пример #2
0
 public void AddAll(StatValue value)
 {
     Count += value.Count;
     Sum   += value.Sum;
     Sum2  += value.Sum2;
     Min    = Math.Min(Min, value.Min);
     Max    = Math.Max(Max, value.Max);
 }
Пример #3
0
 public GameSimulationResult(IAi gamer, ScoreData gamerScore, Exception lastException, double optionsUsed, StatValue turnTime)
 {
     ScoreData     = gamerScore;
     Gamer         = gamer;
     LastException = lastException;
     TurnTime      = turnTime;
     OptionsUsed   = optionsUsed;
 }
 public void AddAll(StatValue value)
 {
     Sum   += value.Sum;
     Sum2  += value.Sum2;
     Count += value.Count;
 }