Example #1
0
        // Students will not use that

        /*
         *
         * private static void MultiTrain(int nb, bool mutations)
         * {
         *  Factory.SetPathLoadAndSave(PathForTest);
         *  Factory.Init();
         *  Factory.TrainAllMaps(nb, mutations);
         *  Factory.PrintScore();
         *  Factory.SaveState();
         * }
         */

        public static float TestScore()
        {
            Assert.AreEqual(true, File.Exists(PathBotToSubmit));

            Factory.SetListPlayer(SaveAndLoad.Load(PathBotToSubmit));
            var ply = Factory.GetBestPlayer();
            int sum = 0;

            foreach (var tuple in RessourceLoad.MapGet())
            {
                RessourceLoad.SetCurrentMap(tuple.Key);
                int FrameNb = RessourceLoad.GetCurrentMap().Timeout;
                ply.ResetScore();
                ply.SetStart(RessourceLoad.GetCurrentMap());
                for (int j = 0; j < FrameNb; j++)
                {
                    ply.PlayAFrame();
                }
                sum += ply.GetScore();

                ply.SetStart(RessourceLoad.GetCurrentMap());
            }
            float result = (float)sum / 45000;

            if (result < 0)
            {
                result = 0;
            }
            else if (result > 1)
            {
                result = 1;
            }
            return(result);
        }
Example #2
0
 public static void SaveState()
 {
     if (_pathSave is null)
     {
         throw new Exception("No path Specified when saving !");
     }
     SaveAndLoad.Save(_pathSave, _listPlayer);
 }
Example #3
0
 public static void Init()
 {
     if (File.Exists(_pathLoad))
     {
         _listPlayer = SaveAndLoad.Load(_pathLoad);
     }
     else
     {
         InitNew();
     }
 }
Example #4
0
        /// <summary>
        /// save best player in folder save, you will be marked on this, so DON'T forget it!
        /// </summary>
        private static void SaveBest()
        {
            Factory.SetPathLoad(PathForTest);
            Factory.Init();
            var soloList = new List <Player> {
                Factory.GetBestPlayer()
            };

            SaveAndLoad.Save(PathBotToSubmit, soloList);
            Console.WriteLine("Saved Best Player");
        }