Ejemplo n.º 1
0
        private static void Evaluate(string resource)
        {
            Console.WriteLine();
            Console.WriteLine(string.Format("Evaluating {0}", resource));
            Task.WaitAll(tasks.ToArray());
            tasks.Clear();

            scoreSetIndex = 0;

            lock (scoreLock)
            {
                scores   = new Dictionary <string, int>();
                hiscores = new Dictionary <int, Dictionary <int, List <KeyValuePair <string, int> > > >();
            }

            Load(resource);

            bool haveScores = File.Exists(string.Format("{0}.hiscores.0", resource));
            bool haveSlides = File.Exists(string.Format("{0}.slides", resource));

            if (!haveSlides)
            {
                CreateHorizontalSlides(resource, haveScores);
                CreateVerticalSlides(resource, haveScores);
                PersistSlides(string.Format("{0}.slides", resource));
            }
            else
            {
                LoadSlides(string.Format("{0}.slides", resource));
            }
            Console.WriteLine();

            //if (!haveScores)
            //{
            //    CalculateAllHiScores(resource);
            //    Task.WaitAll(tasks.ToArray());
            //    tasks.Clear();
            //    lock (scoreLock)
            //    {
            //        PersistCalculatesHiScores(string.Format("{0}.hiscores.{1}", resource, scoreSetIndex++));
            //    }
            //}

            if (generateChacheOnly)
            {
                return;                     // generate cache only
            }
            Console.WriteLine();

            switch (sortIndex)
            {
            case 0:
                for (int i = 0; i < MAX_SCORE_FILES; i++)
                {
                    if (LoadCalculatesScores(string.Format("{0}.hiscores.{1}", resource, i)))
                    {
                        slideShow.SortByScores();
                    }
                }
                break;

            case 1:
                //if (LoadCalculatesScores(string.Format("{0}.hiscores.{1}", resource, 0)))
                //{
                slideShow.SortEx();
                //}
                break;

            default:
                if (LoadCalculatesScores(string.Format("{0}.hiscores.{1}", resource, 0)))
                {
                    slideShow.Sort();
                }
                break;
            }

            Console.WriteLine();
            int score = Score(slideShow.sortedSlides);


            SaveResult(slideShow.sortedSlides, string.Format("{0}_{1}_{2}.out", resource, score, sortIndex));
            Console.WriteLine(string.Format("{0} score: {1}", resource, score));
        }