public static BasicNetwork train(Render render)
        {
            BasicNetwork network = CreateNetwork(6, 2, 8);

            IMLTrain train;

            train = new MLMethodGeneticAlgorithm(() =>
            {
                BasicNetwork result = CreateNetwork(6, 2, 8);
                ((IMLResettable)result).Reset();
                return(result);
            }, new Tester(), 2000);

            int epoch = 1;

            for (int i = 0; i < 80; i++)
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Score:" + train.Error);
                epoch++;
                if (train.Error >= 37)
                {
                    break;
                }
            }

            return((BasicNetwork)train.Method);
        }
Exemple #2
0
        public void StartTraining()
        {
            var Scorer  = new GameScore();
            var Trainer = new MLMethodGeneticAlgorithm(GetNetwork, Scorer, 200)
            {
                ThreadCount = 8
            };


            //Trainer.ThreadCount = 1;
            var s = new BestStrategy();

            s.Init(Trainer);
            Trainer.Strategies.Add(s);
            for (int i = 0; i < 1000; i++)
            {
                Trainer.Iteration();
                Console.WriteLine(string.Format("Epoch {0} finished : {1} Hash : {2}", i, Trainer.Genetic.BestGenome.Score, Trainer.Genetic.BestGenome.GetHashCode()));
                if ((i % 10) == 0)
                {
                    SaveTrainer(Trainer);
                }
            }
            SaveTrainer(Trainer);
            System.IO.File.WriteAllText(@".\Result.txt", Trainer.Genetic.BestGenome.ToString());
        }
Exemple #3
0
        public BasicNetwork SharkTrain()
        {
            IMLTrain train = new MLMethodGeneticAlgorithm(() =>
            {
                BasicNetwork result = CreateNetwork(2, 2);
                ((IMLResettable)result).Reset();
                return(result);
            }, new SharkTrainer(), 1000);

            for (int i = 0; i < 6; i++)
            {
                train.Iteration();
                Console.WriteLine("Shark Inital Train Score: " + Math.Round(train.Error, 2));
            }

            return((BasicNetwork)train.Method);
        }