public void SelectTest()
        {
            #region Формирование исходных данных
            var history = new ExperimentHistory("", null, new Experiment());

            var game = new Game() { Title = "Game" };

            var strike = new Strike() {ErrorDistance = 0};
            var strike2 = new Strike() {ErrorDistance = 1};

            var strikes = new List<Strike> {strike, strike2};

            var users = new Users()
            {
                new User
                {
                    Person = new Person(),
                    Strikes = strikes
                }
            };

            history.AddGame(game, users);

            var settings = new List<PlayerHistorySample>
            {
                new PlayerHistorySample
                {
                    FromStrike = "first",
                    ToStrike = "last",
                    GameTitle = "Game"
                }
            };

            #endregion

            var samples = history.SelectSamples(settings);

            Assert.AreEqual(2, samples.Count());

            for (var i = 0; i < strikes.Count; i++)
            {
                Assert.AreEqual(strikes[i].ErrorDistance, samples.ElementAt(i));
            }
        }
 public UniformAdaptiveCompetitorRandom(UniformAdaptiveCompetitorModel model, ExperimentHistory history, double holeSize, double ballSize)
 {
     this._model = model;
     this._history = history;
     _holeSize = holeSize;
     _ballSize = ballSize;
 }
        public static IPlayer CreateCompetitor(StrikeInfo strikeModel, Ball ball, Hole hole, User player, ExperimentHistory history, IBallKickPhysics ballKick)
        {
            if (history == null)
                throw new NullReferenceException("history");

            IPlayer competitor;

            var competitorModel = strikeModel.CompetitorModel;

            if (competitorModel == null)
                throw new NullReferenceException("Модель соперника не задана");

            if (competitorModel is UniformCompetitorModel)
            {
                competitor = new UniformCompetitor(ball, hole, strikeModel.CompetitorModel as UniformCompetitorModel, player, ballKick);
            }
            else if (competitorModel is NormalAdaptiveCompetitorModel)
            {
                var errorGenerator = new NormalAdaptiveCompetitorRandom(strikeModel.CompetitorModel as NormalAdaptiveCompetitorModel, history);

                competitor = new Competitor(ball.Position.X, hole.Position.X, errorGenerator, ballKick);
            }
            else if (competitorModel is UniformAdaptiveCompetitorModel)
            {
                var errorGenerator = new UniformAdaptiveCompetitorRandom(strikeModel.CompetitorModel as UniformAdaptiveCompetitorModel, history, strikeModel.Hole.Size, strikeModel.Ball.Size);

                competitor = new Competitor(ball.Position.X, hole.Position.X, errorGenerator, ballKick);
            }
            else
            {
                throw new InvalidOperationException($"Модель соперника \"{competitorModel.GetType().Name}\" не поддерживается");
            }

            return competitor;
        }
        private static ExperimentHistory CreateHistory(int hitCount, int size, bool lastStrikeHit)
        {
            var history = new ExperimentHistory("", null, new Experiment());

            var game = new Game() { Title = "Game" };

            var strikes = new List<Strike>();

            var count = hitCount - 1;

            var j = 0;

            for (var i = 0; i < size; i++)
            {
                var strike = new Strike
                {
                    IsHit = j < count
                };

                j++;

                strikes.Add(strike);
            }

            strikes.Last().IsHit = lastStrikeHit;

            var users = new Users()
            {
                new User
                {
                    Person = new Person(),
                    Strikes = strikes
                }
            };

            history.AddGame(game, users);

            return history;
        }
        private static ExperimentHistory CreateHistory(double mean, double stddev, int size)
        {
            var history = new ExperimentHistory("", null, new Experiment());

            var game = new Game() {Title = "Game"};

            var samples = Normal.Samples(mean, stddev).Take(size);

            var strikes = samples.Select(t => new Strike {ErrorDistance = t}).ToList();

            var users = new Users()
            {
                new User
                {
                    Person = new Person(),
                    Strikes = strikes
                }
            };

            history.AddGame(game, users);

            return history;
        }
        public void SelectTest18()
        {
            #region Формирование исходных данных
            var history = new ExperimentHistory("", null, new Experiment());

            var game = new Game() { Title = "Game" };

            var strike = new Strike() { ErrorDistance = 0 };
            var strike2 = new Strike() { ErrorDistance = 1 };

            var strikes = new List<Strike> { strike, strike2 };

            var users = new Users()
            {
                new User
                {
                    Person = new Person(),
                    Strikes = strikes
                }
            };

            history.AddGame(game, users);

            var settings = new List<PlayerHistorySample>
            {
                new PlayerHistorySample
                {
                    ToStrike = "last - 10",
                    GameTitle = "Game"
                }
            };

            #endregion

            var samples = history.SelectSamples(settings);
        }
 public NormalAdaptiveCompetitorRandom(NormalAdaptiveCompetitorModel model, ExperimentHistory history)
 {
     _model = model;
     _history = history;
 }