IhavenonameSDA

Tile World RNG manipulation for Launch

Mar 4th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. //The following C++ code emulates Tile World's RNG to discover a starting seed and time that will result in a perfect score for CCLP1 level 82, Launch.
  2. //This assumes a specific series of inputs calibrated to be as likely as possible, with odds of approximately 1/14800.
  3.  
  4. #include <iostream>
  5. #include <math.h>
  6. #include <stdlib.h>
  7. #include <cstring>
  8.  
  9. using namespace std;
  10.  
  11. void VerifyInput();
  12.  
  13. int LOOPS = 1000000;
  14. int startseed = 0;
  15. int seed = 0;
  16. int seeds[1000000];
  17. int index = 0;
  18. int count = 0;
  19. string RFFS = "";
  20. string dirs = "";
  21. int bits = 0;
  22. char RFF = ' ';
  23. bool match = false;
  24. string checker = "";
  25. string checkchar = "";
  26. int i = 0;
  27. int Rcount = 0;
  28. int point = 0;
  29. int verified = 0;
  30.  
  31. int main(){
  32. //set seed
  33. seed = 3;
  34. while(count < LOOPS){
  35. //push RNG
  36. seed = (seed * 1103515245 + 12345) & 0x7FFFFFFF;
  37. //store new RNG seed in array
  38. seeds[count] = seed;
  39. //convert new seed to RFF
  40. //remove the last 29 bits
  41. //0 = U, 1 = L, 2 = D, 3 = R
  42. bits = seed >> 29;
  43. if(bits == 0)
  44. RFF = 'U';
  45. if(bits == 1)
  46. RFF = 'L';
  47. if(bits == 2)
  48. RFF = 'D';
  49. if(bits == 3)
  50. RFF = 'R';
  51. //add RFF to string
  52. RFFS.append(1, RFF);
  53. count++;
  54. }
  55. count = 5;
  56. while(count < (LOOPS - 25)){
  57. //check the substring of length 4 starting at index for one of:
  58. //"LUUD", "LUUR", "ULLU", "URLU", "UDLU"
  59. dirs = RFFS.substr(count, 4);
  60. //if match, print seeds[index] and the substring of length 20
  61. if(dirs == "LUUD" || dirs == "LUUR" || dirs == "ULLU" || dirs == "URLU" || dirs == "UDLU"){
  62. VerifyInput();
  63. }
  64. count++;
  65. }
  66. cout<<verified;
  67. system("pause");
  68. return 0;
  69. }
  70.  
  71. void VerifyInput(){
  72. i = 0;
  73. Rcount = 0;
  74. match = true;
  75. checker = dirs.substr(0, 1);
  76. if(checker == "L"){
  77. point = 3;
  78. }
  79. if(checker == "U"){
  80. point = 4;
  81. }
  82.  
  83. checker = RFFS.substr(count+point, 9);
  84. if(checker.substr(0,1) == "U" || checker.substr(0,1) == "L"){
  85. match = false;
  86. }
  87. if(checker.substr(7,2) != "DD"){
  88. match = false;
  89. }
  90.  
  91. //check for exactly 2 "R"
  92. while(i < 9){
  93. checkchar = checker.substr(i,1);
  94. if(checkchar == "R"){
  95. Rcount++;
  96. }
  97. i++;
  98. }
  99. if(Rcount != 2){
  100. match = false;
  101. }
  102.  
  103. //check for no adjacent "U, L" pairs in (1, 6)
  104. i=1;
  105. while(i < 6){
  106. checkchar = checker.substr(i,2);
  107. if(checkchar == "LL" || checkchar == "LU" || checkchar == "UL" || checkchar == "UU"){
  108. match = false;
  109. }
  110. i++;
  111. }
  112.  
  113. if(match == true){
  114. cout << RFFS.substr(count, 20) << " " << seeds[count-1] << " " << seeds[count-5] << endl;
  115. }
  116. verified++;
  117. }
Add Comment
Please, Sign In to add comment