Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Text;
- var initialSeed = 0xDEAD0CAB;
- var seed = 0xDEAD0CAB;
- var initialState = seed;
- var initialAmount = 0;
- long endAmount = 32768;
- var intervalAmount = 15;
- var doIntervals = false;
- var amountToIncreaseBy = 1;
- var thresholdOfAnalysis = 8;
- if (doIntervals)
- {
- for (var i = initialAmount; i <= endAmount; i += amountToIncreaseBy)
- {
- var amountForInterval = AnalyzeRngForInitialAmountOfCalls(i, intervalAmount);
- if (amountForInterval >= thresholdOfAnalysis)
- {
- //Console.WriteLine($"{i}-{i + intervalAmount}-{amountForInterval}");
- }
- }
- }
- else
- {
- var amountForInterval = AnalyzeRngForInitialAmountOfCalls(initialAmount, endAmount);
- }
- int AnalyzeRngForInitialAmountOfCalls(int beforeEntryAmount, long intervalAmount)
- {
- var build = new StringBuilder();
- long maxNumberOfCalls = beforeEntryAmount+intervalAmount;
- var fileTimer = 0;
- var amountOfTimesInFullRngCycle = 0;
- seed = initialSeed;
- if (beforeEntryAmount != 0)
- {
- for (long preRngCalls = 0; preRngCalls <= beforeEntryAmount; preRngCalls++)
- {
- rand();
- }
- }
- //long countOfBuildingAtEnd = 0;
- //long countOfBuildingAtBegin = 0;
- //long countOfRightSideAlley = 0;
- //long countOfLeftSideAlley = 0;
- //long countOfUnderAwning = 0;
- //long countOfMiddleOfBuilding = 0;
- //long count30 = 0;
- //long count31 = 0;
- //long count32 = 0, count33 = 0, count34 = 0, count35 = 0, count36 = 0, count37 = 0, count38 = 0, count39 = 0, count3A = 0, count3B = 0;
- //long count40 = 0, count41 = 0, count42 = 0;
- for (long i = beforeEntryAmount; i <= maxNumberOfCalls; i++)
- {
- initialState = seed;
- //if (initialState == 0xDEAD0CAB)
- //{
- // Console.WriteLine($"I did a full cycle at {i} calls");
- //}
- var timesToOffset = calculateOffset(fileTimer);
- offsetRng(timesToOffset);
- var piece1 = getPiece1(Stages.SpeedHighway);
- var piece2 = getPiece2(Stages.SpeedHighway);
- var piece3 = getPiece3(Stages.SpeedHighway);
- //if (piece1 == 0x12 && piece2 == 0x3A && piece3 == 0x41)
- //{
- //amountOfTimesInFullRngCycle++;
- //}
- var goodSets = new List<ValueTuple<int, int, int>>
- {
- new (0x11, 0x3A, 0x41),
- new (0x12, 0x30, 0x41),
- new (0x12, 0x31, 0x41),
- new (0x12, 0x32, 0x41),
- new (0x12, 0x35, 0x41),
- new (0x12, 0x37, 0x41),
- new (0x12, 0x3A, 0x41),
- new (0x12, 0x3B, 0x41),
- new (0x13, 0x30, 0x41),
- new (0x13, 0x31, 0x41),
- new (0x13, 0x32, 0x41),
- new (0x13, 0x35, 0x41),
- new (0x13, 0x37, 0x41),
- new (0x13, 0x3A, 0x41),
- new (0x13, 0x3B, 0x41),
- new (0x15, 0x3B, 0x41),
- new (0x15, 0x3B, 0x41),
- new (0x12, 0x31, 0x40),
- new (0x12, 0x3B, 0x40)
- };
- var theSet = new ValueTuple<int, int, int>(piece1, piece2, piece3);
- if (goodSets.Contains(theSet))
- {
- //Console.WriteLine($"{i}-{theSet.Item1:X}-{theSet.Item2:X}-{theSet.Item3:X}");
- amountOfTimesInFullRngCycle++;
- }
- build.Append($"{i},{initialState:X},{theSet.Item1:X},{theSet.Item2:X},{theSet.Item3:X}{Environment.NewLine}");
- //Console.WriteLine($"{i},{theSet.Item1:X},{theSet.Item2:X},{theSet.Item3:X}");
- //var shGoodPiece1s = new List<int> { 0x12, 0x13, 0x15 };
- //var shGoodPiece2s = new List<int> { 0x30, 0x31, 0x32, 0x37, 0x3A, 0x3B };
- //var shGoodPiece3s = new List<int> { 0x40, 0x41 };
- //if (shGoodPiece1s.Contains(piece1) && shGoodPiece2s.Contains(piece2) && shGoodPiece3s.Contains(piece3))
- //{
- // Console.WriteLine($"{i}-{piece1:X}-{piece2:X}-{piece3:X}");
- // amountOfTimesInFullRngCycle++;
- //}
- //switch ((SpeedHighwayP1s)piece1)
- //{
- // case SpeedHighwayP1s.BuildingAtEnd:
- // countOfBuildingAtEnd++;
- // break;
- // case SpeedHighwayP1s.BuildingAtBegin:
- // countOfBuildingAtBegin++;
- // break;
- // case SpeedHighwayP1s.RightSideAlley:
- // countOfRightSideAlley++;
- // break;
- // case SpeedHighwayP1s.LeftSideAlley:
- // countOfLeftSideAlley++;
- // break;
- // case SpeedHighwayP1s.UnderAwning:
- // countOfUnderAwning++;
- // break;
- // case SpeedHighwayP1s.MiddleOfBuilding:
- // countOfMiddleOfBuilding++;
- // break;
- //}
- //switch ((SpeedHighwayP2s)piece2)
- //{
- // case SpeedHighwayP2s.YellowCanisterNearGreyBalcony:
- // count30++;
- // break;
- // case SpeedHighwayP2s.GreyCanisterNearMiddleEntrance:
- // count31++;
- // break;
- // case SpeedHighwayP2s.YellowCanisterNearMiddleBuilding:
- // count32++;
- // break;
- // case SpeedHighwayP2s.GreyCanisterNearEnd:
- // count33++;
- // break;
- // case SpeedHighwayP2s.YellowCanisterNearElectricEnemy:
- // count34++;
- // break;
- // case SpeedHighwayP2s.GreyCanisterInAlcove:
- // count35++;
- // break;
- // case SpeedHighwayP2s.ElectricSpinner:
- // count36++;
- // break;
- // case SpeedHighwayP2s.BlackSpikeNearGreyBalcony:
- // count37++;
- // break;
- // case SpeedHighwayP2s.BlackSpikeNearBuildingP1:
- // count38++;
- // break;
- // case SpeedHighwayP2s.Cop:
- // count39++;
- // break;
- // case SpeedHighwayP2s.BlackSpikeMiddleBuilding:
- // count3A++;
- // break;
- // case SpeedHighwayP2s.BlackSpikeIL:
- // count3B++;
- // break;
- //}
- //switch ((SpeedHighwayP3s)piece3)
- //{
- // case SpeedHighwayP3s.GreyBalcony:
- // count40++;
- // break;
- // case SpeedHighwayP3s.BalconyNearSpawn:
- // count41++;
- // break;
- // case SpeedHighwayP3s.RedBalcony:
- // count42++;
- // break;
- //}
- seed = initialState;
- rand();
- }
- //Console.WriteLine($"Count of YellowCanisterNearGreyBalcony: {count30}");
- //Console.WriteLine($"Count of GreyCanisterNearMiddleEntrance: {count31}");
- //Console.WriteLine($"Count of YellowCanisterNearMiddleBuilding: {count32}");
- //Console.WriteLine($"Count of GreyCanisterNearEnd: {count33}");
- //Console.WriteLine($"Count of YellowCanisterNearElectricEnemy: {count34}");
- //Console.WriteLine($"Count of GreyCanisterInAlcove: {count35}");
- //Console.WriteLine($"Count of ElectricSpinner: {count36}");
- //Console.WriteLine($"Count of BlackSpikeNearGreyBalcony: {count37}");
- //Console.WriteLine($"Count of BlackSpikeNearBuildingP1: {count38}");
- //Console.WriteLine($"Count of Cop: {count39}");
- //Console.WriteLine($"Count of BlackSpikeMiddleBuilding: {count3A}");
- //Console.WriteLine($"Count of BlackSpikeIL: {count3B}");
- var thing = build.ToString();
- return amountOfTimesInFullRngCycle;
- //Console.WriteLine($"Piece 1 = {piece1:X}");
- //Console.WriteLine($"Piece 2 = {piece2:X}");
- //Console.WriteLine($"Piece 3 = {piece3:X}");
- }
- int calculateOffset(int fileFrameCount) => fileFrameCount & 0xF;
- void offsetRng(int offset)
- {
- for (int i = 0; i < offset; i++)
- {
- rand();
- }
- }
- uint rand()
- {
- seed = 0x343FD * seed + 0x269EC3;
- return (seed >> 0x10) & 0x7FFF;
- }
- void srand(uint newSeed)
- {
- seed = newSeed;
- }
- int getPiece1(Stages stage)
- {
- int possiblePiece1s = 0;
- switch (stage)
- {
- case Stages.SpeedHighway:
- possiblePiece1s = 0x6;
- break;
- case Stages.Casinopolis:
- possiblePiece1s = 0x6;
- break;
- case Stages.RedMountain:
- possiblePiece1s = 0x6;
- break;
- case Stages.SkyDeck:
- possiblePiece1s = 0x3;
- break;
- }
- return (int)(possiblePiece1s * rand() / 32768.0 * 0.9900001) | 0x10;
- }
- int getPiece2(Stages stage)
- {
- int possiblePiece2Digs = 0;
- int possiblePiece2Enemies = 0;
- switch (stage)
- {
- case Stages.SpeedHighway:
- possiblePiece2Enemies = 0xC;
- break;
- case Stages.Casinopolis:
- possiblePiece2Enemies = 0x5;
- break;
- case Stages.RedMountain:
- possiblePiece2Digs = 0x6;
- possiblePiece2Enemies = 0x6;
- break;
- case Stages.SkyDeck:
- possiblePiece2Digs = 0x4;
- possiblePiece2Enemies = 0x8;
- break;
- }
- int piece2;
- if (stage == Stages.RedMountain || stage == Stages.SkyDeck)
- {
- piece2 = (int)((possiblePiece2Digs + possiblePiece2Enemies) * rand() / 32768.0 * 0.9900001);
- if (piece2 >= possiblePiece2Digs)
- {
- piece2 = (piece2 - possiblePiece2Digs) | 0x30;
- }
- else
- {
- piece2 |= 0x20;
- }
- }
- else
- {
- piece2 = (int)(possiblePiece2Enemies * rand() / 32768.0 * 0.9900001) | 0x30;
- }
- return piece2;
- }
- int getPiece3(Stages stage)
- {
- int possiblePiece3s = 0;
- switch (stage)
- {
- case Stages.SpeedHighway:
- possiblePiece3s = 0x3;
- break;
- case Stages.Casinopolis:
- possiblePiece3s = 0x3;
- break;
- case Stages.RedMountain:
- possiblePiece3s = 0x3;
- break;
- case Stages.SkyDeck:
- possiblePiece3s = 0x6;
- break;
- }
- return (int)(possiblePiece3s * rand() / 32768.0 * 0.9900001) | 0x40;
- }
- enum Stages
- {
- SpeedHighway,
- Casinopolis,
- RedMountain,
- SkyDeck
- }
- enum SpeedHighwayP1s
- {
- BuildingAtEnd = 0x10,
- BuildingAtBegin = 0x11,
- RightSideAlley = 0x12,
- LeftSideAlley = 0x13,
- UnderAwning = 0x14,
- MiddleOfBuilding = 0x15
- }
- enum SpeedHighwayP2s
- {
- YellowCanisterNearGreyBalcony = 0x30,
- GreyCanisterNearMiddleEntrance = 0x31,
- YellowCanisterNearMiddleBuilding = 0x32,
- GreyCanisterNearEnd = 0x33,
- YellowCanisterNearElectricEnemy = 0x34,
- GreyCanisterInAlcove = 0x35,
- ElectricSpinner = 0x36,
- BlackSpikeNearGreyBalcony = 0x37,
- BlackSpikeNearBuildingP1 = 0x38,
- Cop = 0x39,
- BlackSpikeMiddleBuilding = 0x3A,
- BlackSpikeIL = 0x3B
- }
- enum SpeedHighwayP3s
- {
- GreyBalcony = 0x40,
- BalconyNearSpawn = 0x41,
- RedBalcony = 0x42
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement