示例#1
0
            public void Init(IMLTrain train)
            {
                Method      = (MLMethodGeneticAlgorithm)train;
                Adversaries = new List <Adversaries>();
                var r = new RangeRandomizer(-1, 1);

                for (int i = 0; i < 6; i++)
                {
                    Adversaries.Add(new Adversaries()
                    {
                        PlayerStart = r.NextDouble() >= 0.5 ? 1.0 : -1.0, Player = new PlayerVertical(i)
                    });
                    Adversaries.Add(new Adversaries()
                    {
                        PlayerStart = r.NextDouble() >= 0.5 ? 1.0 : -1.0, Player = new PlayerHorizontal(i)
                    });
                }
                BaseAdversaries = Adversaries.ToList();
            }
示例#2
0
            //public void Init(IMLTrain train, )
            //{
            //    Method = (MLMethodGeneticAlgorithm)train;
            //    var r = new RangeRandomizer(-1, 1);
            //    Adversaries = new List<Adversaries>();
            //    Adversaries.Add(new Adversaries() { PlayerStart = 1, Player = new PlayerVertical(1) });
            //    Adversaries.Add(new Adversaries() { PlayerStart = -1, Player = new PlayerHorizontal(-1) });
            //    Adversaries.Add(new Adversaries() { PlayerStart = -1, Player = new PlayerVertical(-1) });
            //    Adversaries.Add(new Adversaries() { PlayerStart = 1, Player = new PlayerHorizontal(1) });
            //}

            public void PostIteration()
            {
                //Method.Genetic.ScoreFunction = new GameScore((BasicNetwork)Method.Method);
                var r = new RangeRandomizer(-1, 1);

                var f   = Method.Genetic.Population.Flatten();
                var Adv = Method.Genetic.Population.Flatten().Select(
                    x => new Adversaries {
                    Player = new PlayerNetwork((x as MLMethodGenome).Phenotype as BasicNetwork)
                    {
                        BaseScore = x.Score / Adversaries.Count
                    }, PlayerStart = r.NextDouble() >= 0.5 ? 1.0 : -1.0
                }).ToList();

                Adv.AddRange(Adversaries);
                Adv.Sort((x1, x2) => x2.Player.BaseScore.CompareTo(x1.Player.BaseScore));
                Adversaries = BaseAdversaries.Concat(Adv.Take(5)).ToList();
            }
示例#3
0
            public void PreIteration()
            {
                var s = Method.Genetic.ScoreFunction as GameScore;
                var r = new RangeRandomizer(-1, 1);

                s.Adversaries = Adversaries;
                var Adv = Method.Genetic.Population.Flatten().Select(
                    x => new Adversaries {
                    Player = new PlayerNetwork((x as MLMethodGenome).Phenotype as BasicNetwork), PlayerStart = r.NextDouble() >= 0.5 ? 1.0 : -1.0
                }).ToList();
                //s.Adversaries = Method.Genetic.Population.Flatten().Select(
                //    x => new Adversaries { Player = new PlayerNetwork((x as MLMethodGenome).Phenotype as BasicNetwork), PlayerStart = r.NextDouble() >= 0.5 ? 1.0 : -1.0 }).ToList();
                //s.Adversaries.AddRange(Adversaries);
            }