示例#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);
        }