Example #1
0
        // Investigates a wall push swing to see if it qualifies
        // Frame 2 is the frame at the start of the pendulum swing that lets Mario get wall displacement
        public void FindIdealReentryManipulationGivenFrame2(List <int> dustFrames, int frame1, int frame2)
        {
            //Config.Print("ATTEMPT\t{0}\t{1}\t{2}", frame1, frame2, "[" + string.Join(",", dustFrames) + "]");
            int counter = 0;
            int frame   = _startingFrame;

            while (true)
            {
                counter++;
                frame++;
                foreach (TtcObject rngObject in _rngObjects)
                {
                    rngObject.SetFrame(frame);
                    rngObject.Update();
                }

                // bob-omb 1 is in range
                if (counter == 63)
                {
                    GetFirstBobomb().SetWithinMarioRange(1);
                }

                // collecting star particles
                if (counter == 66)
                {
                    _rng.PollRNG(80);
                }

                // bob-omb 2 is in range
                if (counter == 70)
                {
                    GetSecondBobomb().SetWithinMarioRange(1);
                }

                // hand is in position
                if (counter == 77)
                {
                    TtcHand hand          = GetLowerHand();
                    int     min           = 36700;
                    int     max           = 39400;
                    bool    handQualifies = hand._angle >= min && hand._angle <= max;
                    if (!handQualifies)
                    {
                        return;
                    }
                }

                // spinner is in position
                if (counter == 122)
                {
                    TtcSpinner spinner = GetLowestSpinner();
                    int        min     = 12600;
                    int        max     = 14700;
                    bool       spinnerAngleQualifies =
                        (spinner._angle >= min && spinner._angle <= max) ||
                        (spinner._angle >= min + 32768 && spinner._angle <= max + 32768);
                    bool spinnerDirectionQualifies = spinner._direction == -1;
                    bool spinnerQualifies          = spinnerAngleQualifies && spinnerDirectionQualifies;
                    if (!spinnerQualifies)
                    {
                        return;
                    }

                    List <int> inputDustFrames = dustFrames.ConvertAll(dustFrame => dustFrame - 2);
                    Config.Print("SUCCESS\t{0}\t{1}\t{2}\t", frame1, frame2, "[" + string.Join(",", inputDustFrames) + "]");
                    return;
                }
            }
        }
Example #2
0
        public int FindHandMovement()
        {
            ushort startAngle = 48700;
            ushort endAngle   = 3912;
            ushort resetAngle = 44000;
            int    margin     = 100;

            TtcHand hand = _rngObjects[37] as TtcHand;

            bool goingForItBool  = false;
            int  goingForItFrame = 0;
            int  bestDist        = int.MinValue;
            int  totalDist       = (int)MoreMath.GetAngleDistance(startAngle, endAngle);

            int frame = _startingFrame;

            for (int counter = 0; true; counter++)
            {
                if (frame % 1000000 == 0)
                {
                    //Config.Print("...frame {0}", frame);
                    return(1000000);
                }

                frame++;
                foreach (TtcObject rngObject in _rngObjects)
                {
                    rngObject.SetFrame(frame);
                    rngObject.Update();
                }

                bool atStartAngle = MoreMath.GetAngleDistance(hand._angle, startAngle) <= margin;
                bool atEndAngle   = MoreMath.GetAngleDistance(hand._angle, endAngle) <= margin;
                bool atResetAngle = MoreMath.GetAngleDistance(hand._angle, resetAngle) <= margin;

                if (goingForItBool)
                {
                    if (atStartAngle)
                    {
                        goingForItBool  = true;
                        goingForItFrame = frame;
                        //Config.Print("Start again on frame {0}", frame);
                    }
                    else if (atEndAngle)
                    {
                        //Config.Print("End on frame {0}", frame);
                        //Config.Print("Success from {0} to {1}", goingForItFrame, frame);
                        return(goingForItFrame);
                    }
                    else if (atResetAngle)
                    {
                        goingForItBool = false;
                        //Config.Print("Reset on frame {0}", frame);
                    }
                }
                else
                {
                    if (atStartAngle)
                    {
                        goingForItBool  = true;
                        goingForItFrame = frame;
                        //Config.Print("Start on frame {0}", frame);
                    }
                    else if (atEndAngle)
                    {
                    }
                    else if (atResetAngle)
                    {
                    }
                }

                if (goingForItBool)
                {
                    int currentDist = (int)MoreMath.GetAngleDifference(startAngle, hand._angle);
                    if (currentDist > bestDist)
                    {
                        bestDist = currentDist;

                        /*
                         * Config.Print(
                         *  "Frame {0} has dist {1} of {2} ({3})",
                         *  frame,
                         *  currentDist,
                         *  totalDist,
                         *  MoreMath.GetPercentString(currentDist, totalDist, 2));
                         */
                    }
                }
            }
        }