Пример #1
0
        public static void FindIdealCogManipulation()
        {
            TtcSaveState saveState         = new TtcSaveState();
            int          startFrame        = MupenUtilities.GetFrameCount();
            int          earliestDustFrame = startFrame + 2;

            int dustFrameRange = 40;
            int maxDustFrames  = 6;
            int minDustFrames  = 0;

            int numFramesMin = 120;
            int numFramesMax = 7000;

            //int numFramesMin = 0;
            //int numFramesMax = 3000;

            List <List <int> > dustFrameLists = GetDustFrameLists(earliestDustFrame, dustFrameRange, maxDustFrames, minDustFrames);
            int           counter             = 0;
            List <string> outputStrings       = new List <string>();

            Config.Print("Starting brute force...");
            foreach (List <int> dustFrames in dustFrameLists)
            {
                counter++;
                if (counter % 1000 == 0)
                {
                    double percent       = Math.Round(100d * counter / dustFrameLists.Count, 1);
                    string percentString = percent.ToString("N1");
                    Config.Print(
                        "counter = {0} / {1} ({2}%)",
                        counter, dustFrameLists.Count, percentString);
                }

                TtcSimulation simulation = new TtcSimulation(saveState, startFrame, dustFrames);
                int?          idealCogConfigurationFrame = simulation.FindIdealCogConfiguration(numFramesMin, numFramesMax);
                if (idealCogConfigurationFrame.HasValue)
                {
                    List <int> dustInputFrames       = dustFrames.ConvertAll(dustFrame => dustFrame - 2);
                    string     dustInputFramesString = "[" + String.Join(", ", dustInputFrames) + "]";
                    string     outputString          = dustInputFramesString + " => " + idealCogConfigurationFrame.Value;
                    outputStrings.Add(outputString);
                    Config.Print(outputString);
                }
            }
            Config.Print("In total, there were {0} successes:", outputStrings.Count);
            outputStrings.ForEach(output => Config.Print(output));
        }
Пример #2
0
        public static void TtcMainMethod2()
        {
            int earliestDustFrame = 901 + 2 + 0;
            int dustFrameRange    = 65;
            int maxDustFrames     = 5;

            int numFramesMin = 120;
            int numFramesMax = 10000;

            List <List <int> > dustFrameLists = GetDustFrameLists(earliestDustFrame, dustFrameRange, maxDustFrames);
            int           counter             = 0;
            List <string> outputStrings       = new List <string>();

            foreach (List <int> dustFrames in dustFrameLists)
            {
                counter++;
                if (counter % 1000 == 0)
                {
                    double percent       = Math.Round(100d * counter / dustFrameLists.Count, 1);
                    string percentString = percent.ToString("N1");
                    Config.Print(
                        "counter = {0} / {1} ({2}%)",
                        counter, dustFrameLists.Count, percentString);
                }

                TtcSimulation simulation = new TtcSimulation(dustFrames);
                int?          idealCogConfigurationFrame = simulation.FindIdealCogConfiguration(numFramesMin, numFramesMax);
                if (idealCogConfigurationFrame.HasValue)
                {
                    List <int> dustInputFrames       = dustFrames.ConvertAll(dustFrame => dustFrame - 2);
                    string     dustInputFramesString = "[" + String.Join(", ", dustInputFrames) + "]";
                    string     outputString          = dustInputFramesString + " => " + idealCogConfigurationFrame.Value;
                    outputStrings.Add(outputString);
                    Config.Print(outputString);
                }
            }
            Config.Print("In total, there were {0} successes:", outputStrings.Count);
            outputStrings.ForEach(output => Config.Print(output));
        }