Exemplo n.º 1
0
        public int?FindPendulumSyncingManipulation()
        {
            int limit = 500;

            int counter = 0;

            _currentFrame = _startingFrame;
            while (_currentFrame < _startingFrame + limit)
            {
                counter++;
                _currentFrame++;
                foreach (TtcObject rngObject in _rngObjects)
                {
                    rngObject.SetFrame(_currentFrame);
                    rngObject.Update();
                }

                TtcPendulum pendulum1 = GetClosePendulum();
                TtcPendulum pendulum2 = GetFarPendulum();
                if (pendulum1._accelerationDirection == pendulum2._accelerationDirection &&
                    pendulum1._accelerationMagnitude == pendulum2._accelerationMagnitude &&
                    pendulum1._angularVelocity == pendulum2._angularVelocity &&
                    pendulum1._waitingTimer == pendulum2._waitingTimer &&
                    pendulum1._angle == pendulum2._angle)
                {
                    return(_currentFrame);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        // Given dust, goes forward and spawns height swings to investigate
        public void FindIdealReentryManipulationGivenDustFrames(List <int> dustFrames)
        {
            int phase1Limit = 1000;

            int maxDustFrame = dustFrames.Count == 0 ? 0 : dustFrames.Max();
            int counter      = 0;
            int frame        = _startingFrame;

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

                // Check if pendulum will do height swing after all dust has been made
                TtcPendulum pendulum = GetReentryPendulum();
                if (frame > maxDustFrame &&
                    pendulum._accelerationDirection == -1 &&
                    pendulum._accelerationMagnitude == 13 &&
                    pendulum._angularVelocity == 0 &&
                    pendulum._waitingTimer == 0 &&
                    pendulum._angle == 42748)
                {
                    TtcSimulation simulation = new TtcSimulation(GetSaveState(), frame, new List <int>());
                    simulation.FindIdealReentryManipulationGivenFrame1(dustFrames, frame);
                }
            }
        }
Exemplo n.º 3
0
        public void FindMovingBarManipulationGivenDustFrames(List <int> dustFrames)
        {
            int limit = 1000;

            TtcPendulum closePendulum = GetClosePendulum();
            TtcPendulum farPendulum   = GetFarPendulum();

            int maxDustFrame = dustFrames.Count == 0 ? 0 : dustFrames.Max();
            int counter      = 0;
            int frame        = _startingFrame;

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

                if (frame > maxDustFrame &&
                    farPendulum._accelerationDirection == -1 &&
                    farPendulum._accelerationMagnitude == 13 &&
                    farPendulum._angularVelocity == 0 &&
                    farPendulum._waitingTimer == 0 &&
                    farPendulum._angle == 34440)
                {
                    TtcSimulation simulation = new TtcSimulation(GetSaveState(), frame, new List <int>());
                    simulation.FindMovingBarManipulationGivenFrame1(dustFrames, frame);
                }

                (int, int)? closePair = TableConfig.PendulumSwings.GetPendulumSwingIndexExtendedPair(closePendulum.GetAmplitude());
                (int, int)? farPair   = TableConfig.PendulumSwings.GetPendulumSwingIndexExtendedPair(farPendulum.GetAmplitude());
                if (!closePair.HasValue || !farPair.HasValue)
                {
                    return;
                }
                (int c1, int c2) = closePair.Value;
                (int f1, int f2) = farPair.Value;
                if (c1 != 306)
                {
                    return;
                }
                if (f1 != 310)
                {
                    return;
                }
            }
        }
Exemplo n.º 4
0
        public void FindMovingBarManipulationGivenFrame1(List <int> dustFrames, int frame1)
        {
            TtcPendulum closePendulum = GetClosePendulum();
            TtcPendulum farPendulum   = GetFarPendulum();
            TtcPusher   middlePusher  = GetMiddlePusher();
            TtcPusher   upperPusher   = GetUpperPusher();

            int?pendulumAngleCounter = null;

            int counter = 0;
            int frame   = _startingFrame;

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

                if (counter == 142)
                {
                    if (!middlePusher.IsExtended())
                    {
                        return;
                    }
                }

                if (counter > 142 &&
                    middlePusher.IsRetracting() &&
                    middlePusher._timer < 50 &&
                    closePendulum._angle == 27477 &&
                    upperPusher.IsExtended())
                {
                    pendulumAngleCounter = counter;
                    Config.Print("SUCCESS\t{0}\t{1}\t{2}", frame1, frame, TtcMain.FormatDustFrames(dustFrames));
                }

                if (counter == 300)
                {
                    return;
                }
            }
        }
Exemplo n.º 5
0
        public List <int> FindKeyHandFrames()
        {
            List <int> pendulumAnglesForDust = new List <int>()
            {
                -103861, -37756, 26919, 93440,
            };
            List <int> output = new List <int>();

            TtcPendulum pendulum         = GetClosePendulum();
            int         initialAmplitude = pendulum.GetAmplitude();

            int frame = _startingFrame;

            for (int counter = 0; true; counter++)
            {
                frame++;
                foreach (TtcObject rngObject in _rngObjects)
                {
                    rngObject.SetFrame(frame);
                    rngObject.Update();
                }

                if (pendulumAnglesForDust.Contains(pendulum._angle))
                {
                    output.Add(frame);
                }

                if (pendulum.GetAmplitude() != initialAmplitude)
                {
                    output.Add(frame);
                    if (output.Count != 5)
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                    return(output);
                }
            }
        }
Exemplo n.º 6
0
        public (bool success, TtcSaveState saveState, int endFrame) FindIdealPendulumManipulation(uint pendulumAddress)
        {
            int?objectIndexNullable = ObjectUtilities.GetObjectIndex(pendulumAddress);

            if (!objectIndexNullable.HasValue)
            {
                return(false, null, 0);
            }
            int objectIndex = objectIndexNullable.Value;

            TtcPendulum pendulum = _rngObjects[objectIndex] as TtcPendulum;
            int         pendulumAmplitudeStart = (int)WatchVariableSpecialUtilities.GetPendulumAmplitude(
                pendulum._accelerationDirection, pendulum._accelerationMagnitude, pendulum._angularVelocity, pendulum._angle);
            int?pendulumSwingIndexStartNullable = TableConfig.PendulumSwings.GetPendulumSwingIndex(pendulumAmplitudeStart);

            if (!pendulumSwingIndexStartNullable.HasValue)
            {
                return(false, null, 0);
            }
            int pendulumSwingIndexStart = pendulumSwingIndexStartNullable.Value;

            //iterate through frames to update objects
            int frame   = _startingFrame;
            int counter = 0;

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

                int pendulumAmplitude = (int)WatchVariableSpecialUtilities.GetPendulumAmplitude(
                    pendulum._accelerationDirection, pendulum._accelerationMagnitude, pendulum._angularVelocity, pendulum._angle);
                int?pendulumSwingIndexNullable = TableConfig.PendulumSwings.GetPendulumSwingIndex(pendulumAmplitude);
                if (!pendulumSwingIndexNullable.HasValue)
                {
                    return(false, null, 0);
                }
                int pendulumSwingIndex = pendulumSwingIndexNullable.Value;

                if (pendulumSwingIndex > pendulumSwingIndexStart)
                {
                    if (pendulum._waitingTimer == 0)
                    {
                        return(true, GetSaveState(), frame);
                    }
                    else
                    {
                        return(false, null, 0);
                    }
                }
                else if (pendulumSwingIndex < pendulumSwingIndexStart)
                {
                    return(false, null, 0);
                }
            }

            return(false, null, 0);
        }
Exemplo n.º 7
0
        // Given frame 1, goes forward and spawns wall push swings to investigate
        // Frame 1 is the frame at the start of the pendulum swing that lets Mario get the right height
        public void FindIdealReentryManipulationGivenFrame1(List <int> dustFrames, int frame1)
        {
            //Config.Print("TRY\t{0}\t{1}", frame1, "[" + string.Join(",", dustFrames) + "]");
            int phase2Limit = 1000;

            TtcPendulum pendulum     = GetReentryPendulum();
            TtcBobomb   firstBobomb  = GetFirstBobomb();
            TtcBobomb   secondBobomb = GetSecondBobomb();
            TtcBobomb   thirdBobomb  = null;
            TtcBobomb   fourthBobomb = null;

            int counter = 0;
            int frame   = _startingFrame;

            while (frame < _startingFrame + phase2Limit)
            {
                counter++;
                frame++;
                foreach (TtcObject rngObject in _rngObjects)
                {
                    // coin for bobomb 1
                    if (counter == 162 && rngObject == firstBobomb)
                    {
                        _rng.PollRNG(3);
                    }
                    // coin for bobomb 2
                    if (counter == 258 && rngObject == secondBobomb)
                    {
                        _rng.PollRNG(3);
                    }
                    rngObject.SetFrame(frame);
                    rngObject.Update();
                }

                // bob-omb 2 start
                if (counter == 19)
                {
                    secondBobomb.SetWithinMarioRange(1);
                }

                // bob-omb 2 end, bob-omb 4 start
                if (counter == 258)
                {
                    _rngObjects.Remove(secondBobomb);
                    fourthBobomb = new TtcBobomb(_rng, 0, 0); // starts outside range
                    _rngObjects.Insert(68, fourthBobomb);
                }

                // bob-omb 1 start
                if (counter == 154)
                {
                    firstBobomb.SetWithinMarioRange(1);
                }

                // bob-omb 1 end, bob-omb 3 start
                if (counter == 162)
                {
                    _rngObjects.Remove(firstBobomb);
                    thirdBobomb = new TtcBobomb(_rng, 0, 1); // starts inside range
                    _rngObjects.Insert(68, thirdBobomb);
                }

                // bob-omb 3 exiting range
                if (counter == 363)
                {
                    thirdBobomb.SetWithinMarioRange(0);
                }

                // dust frames
                if (counter >= 84 && counter <= 95 && counter != 93)
                {
                    _rng.PollRNG(4);
                }

                // bob-omb 2 fuse smoke
                if ((counter >= 99 && counter <= 211 && counter % 8 == 3) ||
                    (counter >= 219 && counter <= 257 && counter % 2 == 1))
                {
                    _rng.PollRNG(3);
                }

                // bob-omb 1 fuse smoke
                if (counter >= 156 && counter <= 162 && counter % 2 == 0)
                {
                    _rng.PollRNG(3);
                }

                // pendulum must have enough waiting frames
                if (counter == 162)
                {
                    bool pendulumQualifies = pendulum._waitingTimer >= 18;
                    if (!pendulumQualifies)
                    {
                        return;
                    }
                }

                // Check if pendulum will do wall push swing
                if (counter > 363 + 15 &&
                    pendulum._accelerationDirection == -1 &&
                    pendulum._accelerationMagnitude == 42 &&
                    pendulum._angularVelocity == 0 &&
                    pendulum._waitingTimer == 0 &&
                    pendulum._angle == 42748)
                {
                    TtcSimulation simulation = new TtcSimulation(GetSaveState(), frame, new List <int>());
                    simulation.FindIdealReentryManipulationGivenFrame2(dustFrames, frame1, frame);
                }

                //Config.Print(frame + "\t" + _rng.GetIndex() + "\t" + GetSaveState());
            }
        }
Exemplo n.º 8
0
        public (bool success, TtcSaveState saveState, int endFrame) FindDualPendulumManipulation()
        {
            TtcPendulum pendulum1 = GetClosePendulum();
            int?        pendulum1SwingIndexBaselineNullable = pendulum1.GetSwingIndex();

            if (!pendulum1SwingIndexBaselineNullable.HasValue)
            {
                return(false, null, 0);
            }
            int pendulum1SwingIndexBaseline = pendulum1SwingIndexBaselineNullable.Value;

            TtcPendulum pendulum2 = GetFarPendulum();
            int?        pendulum2SwingIndexBaselineNullable = pendulum2.GetSwingIndex();

            if (!pendulum2SwingIndexBaselineNullable.HasValue)
            {
                return(false, null, 0);
            }
            int pendulum2SwingIndexBaseline = pendulum2SwingIndexBaselineNullable.Value;

            int frame   = _startingFrame;
            int counter = 0;

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

                int?pendulum1SwingIndexNullable = pendulum1.GetSwingIndex();
                if (!pendulum1SwingIndexNullable.HasValue)
                {
                    return(false, null, 0);
                }
                int pendulum1SwingIndex = pendulum1SwingIndexNullable.Value;
                int pendulum1Countdown  = pendulum1.GetCountdown();

                int?pendulum2SwingIndexNullable = pendulum2.GetSwingIndex();
                if (!pendulum2SwingIndexNullable.HasValue)
                {
                    return(false, null, 0);
                }
                int pendulum2SwingIndex = pendulum2SwingIndexNullable.Value;
                int pendulum2Countdown  = pendulum2.GetCountdown();

                // check if pendulum changed index
                if (pendulum1SwingIndex != pendulum1SwingIndexBaseline || pendulum2SwingIndex != pendulum2SwingIndexBaseline)
                {
                    // if pendulum is moving wrong way or has waiting timer, abort
                    if (pendulum1SwingIndex < pendulum1SwingIndexBaseline ||
                        pendulum2SwingIndex < pendulum2SwingIndexBaseline ||
                        pendulum1._waitingTimer > 0 ||
                        pendulum2._waitingTimer > 0)
                    {
                        return(false, null, 0);
                    }

                    // if we're in a safe zone, return
                    if (pendulum1Countdown >= 15 && pendulum2Countdown >= 15)
                    {
                        return(true, GetSaveState(), frame);
                    }

                    // update baseline to allow for more iterations
                    pendulum1SwingIndexBaseline = pendulum1SwingIndex;
                    pendulum2SwingIndexBaseline = pendulum2SwingIndex;
                }
            }

            return(false, null, 0);
        }