Advertisement
DreMinus

dumb program

Apr 24th, 2024
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.77 KB | None | 0 0
  1. using System.Text;
  2.  
  3. var initialSeed = 0xDEAD0CAB;
  4. var seed = 0xDEAD0CAB;
  5. var initialState = seed;
  6.  
  7. var initialAmount = 0;
  8. long endAmount = 32768;
  9. var intervalAmount = 15;
  10.  
  11. var doIntervals = false;
  12. var amountToIncreaseBy = 1;
  13. var thresholdOfAnalysis = 8;
  14.  
  15. if (doIntervals)
  16. {
  17.   for (var i = initialAmount; i <= endAmount; i += amountToIncreaseBy)
  18.   {
  19.     var amountForInterval = AnalyzeRngForInitialAmountOfCalls(i, intervalAmount);
  20.     if (amountForInterval >= thresholdOfAnalysis)
  21.     {
  22.       //Console.WriteLine($"{i}-{i + intervalAmount}-{amountForInterval}");
  23.     }
  24.   }
  25. }
  26. else
  27. {
  28.   var amountForInterval = AnalyzeRngForInitialAmountOfCalls(initialAmount, endAmount);
  29. }
  30.  
  31. int AnalyzeRngForInitialAmountOfCalls(int beforeEntryAmount, long intervalAmount)
  32. {
  33.   var build = new StringBuilder();
  34.   long maxNumberOfCalls = beforeEntryAmount+intervalAmount;
  35.  
  36.   var fileTimer = 0;
  37.   var amountOfTimesInFullRngCycle = 0;
  38.  
  39.   seed = initialSeed;
  40.   if (beforeEntryAmount != 0)
  41.   {
  42.     for (long preRngCalls = 0; preRngCalls <= beforeEntryAmount; preRngCalls++)
  43.     {
  44.       rand();
  45.     }
  46.   }
  47.  
  48.   //long countOfBuildingAtEnd = 0;
  49.   //long countOfBuildingAtBegin = 0;
  50.   //long countOfRightSideAlley = 0;
  51.   //long countOfLeftSideAlley = 0;
  52.   //long countOfUnderAwning = 0;
  53.   //long countOfMiddleOfBuilding = 0;
  54.  
  55.   //long count30 = 0;
  56.   //long count31 = 0;
  57.   //long count32 = 0, count33 = 0, count34 = 0, count35 = 0, count36 = 0, count37 = 0, count38 = 0, count39 = 0, count3A = 0, count3B = 0;
  58.  
  59.   //long count40 = 0, count41 = 0, count42 = 0;
  60.  
  61.   for (long i = beforeEntryAmount; i <= maxNumberOfCalls; i++)
  62.   {
  63.     initialState = seed;
  64.  
  65.     //if (initialState == 0xDEAD0CAB)
  66.     //{
  67.     //  Console.WriteLine($"I did a full cycle at {i} calls");
  68.     //}
  69.  
  70.     var timesToOffset = calculateOffset(fileTimer);
  71.     offsetRng(timesToOffset);
  72.     var piece1 = getPiece1(Stages.SpeedHighway);
  73.     var piece2 = getPiece2(Stages.SpeedHighway);
  74.     var piece3 = getPiece3(Stages.SpeedHighway);
  75.     //if (piece1 == 0x12 && piece2 == 0x3A && piece3 == 0x41)
  76.     //{
  77.     //amountOfTimesInFullRngCycle++;
  78.     //}
  79.  
  80.     var goodSets = new List<ValueTuple<int, int, int>>
  81.     {
  82.       new (0x11, 0x3A, 0x41),
  83.       new (0x12, 0x30, 0x41),
  84.       new (0x12, 0x31, 0x41),
  85.       new (0x12, 0x32, 0x41),
  86.       new (0x12, 0x35, 0x41),
  87.       new (0x12, 0x37, 0x41),
  88.       new (0x12, 0x3A, 0x41),
  89.       new (0x12, 0x3B, 0x41),
  90.       new (0x13, 0x30, 0x41),
  91.       new (0x13, 0x31, 0x41),
  92.       new (0x13, 0x32, 0x41),
  93.       new (0x13, 0x35, 0x41),
  94.       new (0x13, 0x37, 0x41),
  95.       new (0x13, 0x3A, 0x41),
  96.       new (0x13, 0x3B, 0x41),
  97.       new (0x15, 0x3B, 0x41),
  98.       new (0x15, 0x3B, 0x41),
  99.       new (0x12, 0x31, 0x40),
  100.       new (0x12, 0x3B, 0x40)
  101.     };
  102.     var theSet = new ValueTuple<int, int, int>(piece1, piece2, piece3);
  103.     if (goodSets.Contains(theSet))
  104.     {
  105.       //Console.WriteLine($"{i}-{theSet.Item1:X}-{theSet.Item2:X}-{theSet.Item3:X}");
  106.       amountOfTimesInFullRngCycle++;
  107.     }
  108.  
  109.     build.Append($"{i},{initialState:X},{theSet.Item1:X},{theSet.Item2:X},{theSet.Item3:X}{Environment.NewLine}");
  110.     //Console.WriteLine($"{i},{theSet.Item1:X},{theSet.Item2:X},{theSet.Item3:X}");
  111.     //var shGoodPiece1s = new List<int> { 0x12, 0x13, 0x15 };
  112.     //var shGoodPiece2s = new List<int> { 0x30, 0x31, 0x32, 0x37, 0x3A, 0x3B };
  113.     //var shGoodPiece3s = new List<int> { 0x40, 0x41 };
  114.  
  115.     //if (shGoodPiece1s.Contains(piece1) && shGoodPiece2s.Contains(piece2) && shGoodPiece3s.Contains(piece3))
  116.     //{
  117.     //  Console.WriteLine($"{i}-{piece1:X}-{piece2:X}-{piece3:X}");
  118.     //  amountOfTimesInFullRngCycle++;
  119.     //}
  120.  
  121.     //switch ((SpeedHighwayP1s)piece1)
  122.     //{
  123.     //  case SpeedHighwayP1s.BuildingAtEnd:
  124.     //    countOfBuildingAtEnd++;
  125.     //    break;
  126.     //  case SpeedHighwayP1s.BuildingAtBegin:
  127.     //    countOfBuildingAtBegin++;
  128.     //    break;
  129.     //  case SpeedHighwayP1s.RightSideAlley:
  130.     //    countOfRightSideAlley++;
  131.     //    break;
  132.     //  case SpeedHighwayP1s.LeftSideAlley:
  133.     //    countOfLeftSideAlley++;
  134.     //    break;
  135.     //  case SpeedHighwayP1s.UnderAwning:
  136.     //    countOfUnderAwning++;
  137.     //    break;
  138.     //  case SpeedHighwayP1s.MiddleOfBuilding:
  139.     //    countOfMiddleOfBuilding++;
  140.     //    break;
  141.     //}
  142.  
  143.     //switch ((SpeedHighwayP2s)piece2)
  144.     //{
  145.     //  case SpeedHighwayP2s.YellowCanisterNearGreyBalcony:
  146.     //    count30++;
  147.     //    break;
  148.     //  case SpeedHighwayP2s.GreyCanisterNearMiddleEntrance:
  149.     //    count31++;
  150.     //    break;
  151.     //  case SpeedHighwayP2s.YellowCanisterNearMiddleBuilding:
  152.     //    count32++;
  153.     //    break;
  154.     //  case SpeedHighwayP2s.GreyCanisterNearEnd:
  155.     //    count33++;
  156.     //    break;
  157.     //  case SpeedHighwayP2s.YellowCanisterNearElectricEnemy:
  158.     //    count34++;
  159.     //    break;
  160.     //  case SpeedHighwayP2s.GreyCanisterInAlcove:
  161.     //    count35++;
  162.     //    break;
  163.     //  case SpeedHighwayP2s.ElectricSpinner:
  164.     //    count36++;
  165.     //    break;
  166.     //  case SpeedHighwayP2s.BlackSpikeNearGreyBalcony:
  167.     //    count37++;
  168.     //    break;
  169.     //  case SpeedHighwayP2s.BlackSpikeNearBuildingP1:
  170.     //    count38++;
  171.     //    break;
  172.     //  case SpeedHighwayP2s.Cop:
  173.     //    count39++;
  174.     //    break;
  175.     //  case SpeedHighwayP2s.BlackSpikeMiddleBuilding:
  176.     //    count3A++;
  177.     //    break;
  178.     //  case SpeedHighwayP2s.BlackSpikeIL:
  179.     //    count3B++;
  180.     //    break;
  181.     //}
  182.  
  183.     //switch ((SpeedHighwayP3s)piece3)
  184.     //{
  185.     //  case SpeedHighwayP3s.GreyBalcony:
  186.     //    count40++;
  187.     //    break;
  188.     //  case SpeedHighwayP3s.BalconyNearSpawn:
  189.     //    count41++;
  190.     //    break;
  191.     //  case SpeedHighwayP3s.RedBalcony:
  192.     //    count42++;
  193.     //    break;
  194.     //}
  195.  
  196.     seed = initialState;
  197.     rand();
  198.   }
  199.  
  200.   //Console.WriteLine($"Count of YellowCanisterNearGreyBalcony: {count30}");
  201.   //Console.WriteLine($"Count of GreyCanisterNearMiddleEntrance: {count31}");
  202.   //Console.WriteLine($"Count of YellowCanisterNearMiddleBuilding: {count32}");
  203.   //Console.WriteLine($"Count of GreyCanisterNearEnd: {count33}");
  204.   //Console.WriteLine($"Count of YellowCanisterNearElectricEnemy: {count34}");
  205.   //Console.WriteLine($"Count of GreyCanisterInAlcove: {count35}");
  206.   //Console.WriteLine($"Count of ElectricSpinner: {count36}");
  207.   //Console.WriteLine($"Count of BlackSpikeNearGreyBalcony: {count37}");
  208.   //Console.WriteLine($"Count of BlackSpikeNearBuildingP1: {count38}");
  209.   //Console.WriteLine($"Count of Cop: {count39}");
  210.   //Console.WriteLine($"Count of BlackSpikeMiddleBuilding: {count3A}");
  211.   //Console.WriteLine($"Count of BlackSpikeIL: {count3B}");
  212.  
  213.   var thing = build.ToString();
  214.  
  215.   return amountOfTimesInFullRngCycle;
  216.  
  217.   //Console.WriteLine($"Piece 1 = {piece1:X}");
  218.   //Console.WriteLine($"Piece 2 = {piece2:X}");
  219.   //Console.WriteLine($"Piece 3 = {piece3:X}");
  220. }
  221.  
  222.  
  223. int calculateOffset(int fileFrameCount) => fileFrameCount & 0xF;
  224.  
  225. void offsetRng(int offset)
  226. {
  227.   for (int i = 0; i < offset; i++)
  228.   {
  229.     rand();
  230.   }
  231. }
  232.  
  233. uint rand()
  234. {
  235.   seed = 0x343FD * seed + 0x269EC3;
  236.   return (seed >> 0x10) & 0x7FFF;
  237. }
  238.  
  239. void srand(uint newSeed)
  240. {
  241.   seed = newSeed;
  242. }
  243.  
  244. int getPiece1(Stages stage)
  245. {
  246.   int possiblePiece1s = 0;
  247.   switch (stage)
  248.   {
  249.     case Stages.SpeedHighway:
  250.       possiblePiece1s = 0x6;
  251.       break;
  252.     case Stages.Casinopolis:
  253.       possiblePiece1s = 0x6;
  254.       break;
  255.     case Stages.RedMountain:
  256.       possiblePiece1s = 0x6;
  257.       break;
  258.     case Stages.SkyDeck:
  259.       possiblePiece1s = 0x3;
  260.       break;
  261.   }
  262.   return (int)(possiblePiece1s * rand() / 32768.0 * 0.9900001) | 0x10;
  263. }
  264.  
  265. int getPiece2(Stages stage)
  266. {
  267.   int possiblePiece2Digs = 0;
  268.   int possiblePiece2Enemies = 0;
  269.   switch (stage)
  270.   {
  271.     case Stages.SpeedHighway:
  272.       possiblePiece2Enemies = 0xC;
  273.       break;
  274.     case Stages.Casinopolis:
  275.       possiblePiece2Enemies = 0x5;
  276.       break;
  277.     case Stages.RedMountain:
  278.       possiblePiece2Digs = 0x6;
  279.       possiblePiece2Enemies = 0x6;
  280.       break;
  281.     case Stages.SkyDeck:
  282.       possiblePiece2Digs = 0x4;
  283.       possiblePiece2Enemies = 0x8;
  284.       break;
  285.   }
  286.  
  287.   int piece2;
  288.   if (stage == Stages.RedMountain || stage == Stages.SkyDeck)
  289.   {
  290.     piece2 = (int)((possiblePiece2Digs + possiblePiece2Enemies) * rand() / 32768.0 * 0.9900001);
  291.     if (piece2 >= possiblePiece2Digs)
  292.     {
  293.       piece2 = (piece2 - possiblePiece2Digs) | 0x30;
  294.     }
  295.     else
  296.     {
  297.       piece2 |= 0x20;
  298.     }
  299.   }
  300.   else
  301.   {
  302.     piece2 = (int)(possiblePiece2Enemies * rand() / 32768.0 * 0.9900001) | 0x30;
  303.   }
  304.   return piece2;
  305. }
  306.  
  307. int getPiece3(Stages stage)
  308. {
  309.   int possiblePiece3s = 0;
  310.   switch (stage)
  311.   {
  312.     case Stages.SpeedHighway:
  313.       possiblePiece3s = 0x3;
  314.       break;
  315.     case Stages.Casinopolis:
  316.       possiblePiece3s = 0x3;
  317.       break;
  318.     case Stages.RedMountain:
  319.       possiblePiece3s = 0x3;
  320.       break;
  321.     case Stages.SkyDeck:
  322.       possiblePiece3s = 0x6;
  323.       break;
  324.   }
  325.   return (int)(possiblePiece3s * rand() / 32768.0 * 0.9900001) | 0x40;
  326. }
  327.  
  328. enum Stages
  329. {
  330.   SpeedHighway,
  331.   Casinopolis,
  332.   RedMountain,
  333.   SkyDeck
  334. }
  335.  
  336. enum SpeedHighwayP1s
  337. {
  338.   BuildingAtEnd = 0x10,
  339.   BuildingAtBegin = 0x11,
  340.   RightSideAlley = 0x12,
  341.   LeftSideAlley = 0x13,
  342.   UnderAwning = 0x14,
  343.   MiddleOfBuilding = 0x15
  344. }
  345.  
  346. enum SpeedHighwayP2s
  347. {
  348.   YellowCanisterNearGreyBalcony = 0x30,
  349.   GreyCanisterNearMiddleEntrance = 0x31,
  350.   YellowCanisterNearMiddleBuilding = 0x32,
  351.   GreyCanisterNearEnd = 0x33,
  352.   YellowCanisterNearElectricEnemy = 0x34,
  353.   GreyCanisterInAlcove = 0x35,
  354.   ElectricSpinner = 0x36,
  355.   BlackSpikeNearGreyBalcony = 0x37,
  356.   BlackSpikeNearBuildingP1 = 0x38,
  357.   Cop = 0x39,
  358.   BlackSpikeMiddleBuilding = 0x3A,
  359.   BlackSpikeIL = 0x3B
  360. }
  361.  
  362. enum SpeedHighwayP3s
  363. {
  364.   GreyBalcony = 0x40,
  365.   BalconyNearSpawn = 0x41,
  366.   RedBalcony = 0x42
  367. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement