public bool IsValid() { TtcSimulation simulation = new TtcSimulation(SaveState); bool isValid = simulation.GetClosePendulum()._accelerationMagnitude == 13; return(isValid); }
public List <HandManipulationProgress> GetSuccessors() { if (!IsValid()) { return(new List <HandManipulationProgress>()); } List <int> keyFrames = new TtcSimulation( SaveState, Frame, new List <int>()).FindKeyHandFrames(); int endingFrame = keyFrames[4]; List <int> potentialDustFrames = new List <int>() { keyFrames[0], keyFrames[1], keyFrames[2], keyFrames[3] }; List <List <int> > dustFrameConfigurations = ControlUtilities.GetSubsetsRanged <int>(potentialDustFrames, 0, 4); List <HandManipulationProgress> successors = new List <HandManipulationProgress>(); foreach (List <int> dustFrameConfiguration in dustFrameConfigurations) { TtcSimulation simulation = new TtcSimulation(SaveState, Frame, dustFrameConfiguration); simulation.SimulateUntilFrame(endingFrame); HandManipulationProgress progress = new HandManipulationProgress( simulation.GetSaveState(), endingFrame, DustFrames.Concat(dustFrameConfiguration).ToList()); successors.Add(progress); } return(successors); }
public static void FindMidairWalkingSetup() { TtcSaveState initialSaveState = new TtcSaveState(); int initialStartFrame = MupenUtilities.GetFrameCount(); int successCounter = 0; for (int i = 0; true; i++) { if (i % 10_000 == 0) { Config.Print("Tested " + i); } List <int> dustFrames = GetDustFrames(initialStartFrame + 2, 150, 10); TtcSimulation simulation = new TtcSimulation(initialSaveState, initialStartFrame, dustFrames); (bool success, int startFrame) = simulation.FindMidairWalkingSetup1(); if (success) { successCounter++; Config.Print(); Config.Print("SUCCESS#{0}: {1}", successCounter, startFrame); List <int> inputFrames = dustFrames.ConvertAll(frame => frame - 2); foreach (int frame in inputFrames) { Config.Print(frame); } Config.Print(); } } }
// from save state public static void TtcMainMethod4() { TtcSimulation simulation = new TtcSimulation(testString4050); string result = simulation.GetObjectsString(50); Config.Print(result); }
// 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); } } }
// from start public static void TtcMainMethod5() { TtcSimulation simulation = new TtcSimulation(0, 4000); string result = simulation.GetObjectsString(4100); Config.Print(result); }
public static void TestPendulumMovement() { ushort rngValue = 0; int startingFrame = 0; TtcSimulation simulation = new TtcSimulation(rngValue, startingFrame); simulation.OutputPendulumData(); }
public static void TestReentryPhase1() { string savestateString = "000069000000130000007D00000090000000550000000E0000007D00000095000000550000006D00000055000000590000007D000000900000002D00000054000000FFFFFFFFAF12000016FFFFFF0D000000000000000100000067E4FFFFD6FFFFFF2A00000000000000FFFFFFFFFCA60000000000000D0000000000000001000000BBDBFFFF000000000D000000090000000000000032000000320000005A0000002B00000001000000000000000000000000000000B184000001000000000000000000000000000000B184000001000000000000000000000000000000B184000001000000000000000000000000000000B184000064000000000000000000000019000000010000004600000001000000270000006400000000000000030000000B0000000C0000000000000002000000210000006400000000000000000000003A000000370000000000000000000000130000006400000000000000030000003600000037000000000000000300000029000000010000001D00000001000000600000000C000000000000000300000001000000370000003C000000010000000000000064000000000000000300000007000000786D0000E0FCFFFF18FCFFFFC4DC0000A8FDFFFF50FBFFFFECBB000076FDFFFF00000000761C0000F401000018FCFFFF78820000CEFFFFFFB00400004E990000CEFFFFFF70FEFFFF60070000C201000070FEFFFF03010000F7FFFFFF010000001E0000001D00000090AB00000A00000090AB0000BCFBFFFF820000000A000000B84D000032000000B84D0000BCFBFFFF8F00000008000000D09B000001000000780000000900000028EB0000FFFFFFFF3C0000000C000000B8F8000001000000780000002C000000F8DE0000010000005A00000002000000C03A0000FFFFFFFF5A00000031000000C0210000FFFFFFFF5A0000001900000008510000FFFFFFFF780000007400000040CA0000010000005A0000003500000030740000010000003C0000002D00000078C7000001000000780000001A0000004095000001000000780000004B000000C87E000001000000780000003200000098C40000FFFFFFFF780000000E000000608F0000010000003C0000000F00000058DC00000A0000000CDC000034F3FFFFFE000000110000002C0F0000320000002C0F000034F3FFFF490000001F000000D439000032000000A035000034F3FFFF1A0000000C0000008067000032000000445C000034F3FFFF390000000300000030CC00003200000084C2000034F3FFFF7100000005000000F474000032000000F068000034F3FFFF5100000002000000CB02000006000000010000005A00000010000000EEFAFFFF0600000001000000B4000000840000000CBE0000580200000000000002000000000000000000000000000000B184000003000000000000000000000000000000B1840000B61900000000000019000000000000002700000002000000178A000002000000FF39000000000000000000000000000000000000"; int startFrame = 41887; TtcSaveState savestate = new TtcSaveState(savestateString); TtcSimulation simulation = new TtcSimulation(savestate, startFrame, new List <int>()); simulation.FindIdealReentryManipulationGivenFrame1(new List <int>(), startFrame); }
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; } } }
public static void FindMovingBarManipulation() { TtcSaveState saveState = new TtcSaveState(); int startingFrame = MupenUtilities.GetFrameCount(); List <List <int> > dustFramesLists = GetDustFrameLists(startingFrame + 2, 25, 25); Config.Print("START FindMovingBarManipulation"); foreach (List <int> dustFrames in dustFramesLists) { TtcSimulation simulation = new TtcSimulation(saveState, startingFrame, dustFrames); simulation.FindMovingBarManipulationGivenDustFrames(dustFrames); } Config.Print("END FindMovingBarManipulation"); }
public static List <int> FindIdealPendulumManipulation(uint pendulumAddress) { List <List <int> > dustFrameLists = GetDustFrameLists(MupenUtilities.GetFrameCount() + 2, 25, 25); foreach (List <int> dustFrames in dustFrameLists) { TtcSimulation simulation = new TtcSimulation(dustFrames); bool success = simulation.FindIdealPendulumManipulation(pendulumAddress).ToTuple().Item1; if (success) { return(dustFrames); } } return(null); }
FindPunchRecoilPendulumManipulation(TtcSaveState saveState) { List <List <int> > dustFrameLists = GetDustFrameLists(2, 25, 25).Skip(1).ToList(); foreach (List <int> dustFrames in dustFrameLists) { TtcSimulation simulation = new TtcSimulation(saveState); simulation.AddDustFrames(dustFrames); (bool success, TtcSaveState savestate, int endFrame) = simulation.FindPunchRecoilPendulumManipulation(); if (success) { return(success, savestate, endFrame, dustFrames); } } return(false, null, 0, null); }
FindIdealPendulumManipulation(uint pendulumAddress, TtcSaveState saveState) { List <List <int> > dustFrameLists = GetDustFrameLists(2, 25, 25); foreach (List <int> dustFrames in dustFrameLists) { TtcSimulation simulation = new TtcSimulation(saveState); simulation.AddDustFrames(dustFrames); (bool success, TtcSaveState savestate, int endFrame) = simulation.FindIdealPendulumManipulation(pendulumAddress); if (success) { return(success, savestate, endFrame, dustFrames); } } return(false, null, 0, null); }
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)); }
public static void FindPendulumSyncingManipulation() { TtcSaveState saveState = new TtcSaveState(); int startingFrame = MupenUtilities.GetFrameCount(); List <List <int> > dustFramesLists = GetDustFrameLists(startingFrame + 2, 25, 25); Config.Print("START FindPendulumSyncingManipulation"); foreach (List <int> dustFrames in dustFramesLists) { TtcSimulation simulation = new TtcSimulation(saveState, startingFrame, dustFrames); int? syncingFrame = simulation.FindPendulumSyncingManipulation(); if (syncingFrame.HasValue) { Config.Print(syncingFrame.Value + "\t" + FormatDustFrames(dustFrames)); } } Config.Print("END FindPendulumSyncingManipulation"); }
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)); }
// 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()); } }
public static string Simulate(int endFrame, List <int> dustFrames = null) { TtcSimulation simulation = new TtcSimulation(dustFrames); return(simulation.GetObjectsString(endFrame)); }
public static int FindHandMovement() { TtcSimulation simulation = new TtcSimulation(); return(simulation.FindHandMovement()); }
public int GetHandMovementFrame() { return(TtcSimulation.FindHandMovement(SaveState, Frame)); }
public static int FindHandMovement(TtcSaveState saveState, int startingFrame) { TtcSimulation simulation = new TtcSimulation(saveState, startingFrame, new List <int>()); return(simulation.FindHandMovement()); }