Mountebank

Untitled

Aug 17th, 2017
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.65 KB | None | 0 0
  1.  
  2. var bingoGoals = [];
  3. bingoGoals[1] = [
  4. { name: "Map Card", types: ["map"], weight: 0 },
  5. { name: "TM28 (Dig)", types: ["dig"], weight: 10 },
  6. { name: "Itemfinder", types: ["item"], weight: 0 },
  7. { name: "Radio Card", types: ["radio"], weight: 0 },
  8. ];
  9. bingoGoals[2] = [
  10. { name: "Koffing", types: ["gas"], weight: 6 },
  11. { name: "4 Different types of Poke Ball", types: ["ball"], weight: 0 },
  12. { name: "Give a Pokemon a haircut", types: ["snip"], weight: 0 },
  13. { name: "Charcoal", types: ["fire"], weight: 0 }
  14. ];
  15. bingoGoals[3] = [
  16. { name: "Call a Youngster", types: ["shorts"], weight: 0 },
  17. { name: "Magikarp", types: ["lol"], weight: 4 },
  18. { name: "Teach TM12 (Sweet Scent)", types: ["bug"], weight: 0 },
  19. { name: "Rattata", types: ["lol"], weight: 4 },
  20. ];
  21. bingoGoals[4] = [
  22. { name: "TM20 (Endure)", types: ["endure"], weight: 6 },
  23. { name: "Slowpoketail", types: ["money"], weight: 0 },
  24. { name: "Growlithe", types: ["grow"], weight: 4 },
  25. { name: "10 pokemon owned", types: ["pkmn"], weight: 0 }
  26. ];
  27. bingoGoals[5] = [
  28. { name: "Goldeen", types: ["oldeen"], weight: 4 },
  29. { name: "Onix", types: ["rock"], weight: 4 },
  30. { name: "Venonat", types: ["radar"], weight: 4 },
  31. { name: "Defeat all 4 trainers in National Park", types: ["park"], weight: 0 }
  32. ];
  33. bingoGoals[6] = [
  34. { name: "Cubone", types: ["money"], weight: 4 },
  35. { name: "Slowpoke", types: ["dopey"], weight: 4 },
  36. { name: "A Pokemon with 4 moves with STAB", types: ["tm"], weight: 0 },
  37. { name: "TM05 (Roar)", types: ["thirty"], weight: 0 }
  38. ];
  39. bingoGoals[7] = [
  40. { name: "Ariados", types: ["time"], weight: 2 },
  41. { name: "No money on hand or mom", types: ["cash"], weight: 0 },
  42. { name: "Farfetch'd", types: ["time"], weight: 4 },
  43. { name: "TM50 (Nightmare)", types: ["thirty"], weight: 0 }
  44. ];
  45. bingoGoals[8] = [
  46. { name: "3 eggs", types: ["egg"], weight: 0 },
  47. { name: "Kadabra", types: ["abra"], weight: 2 },
  48. { name: "Beedrill and Butterfree", types: ["buggy"], weight: 2 },
  49. { name: "Unown Pokedex", types: ["unown"], weight: 100 },
  50. { name: "Everstone", types: ["egg"], weight: 0 }
  51. ];
  52. bingoGoals[9] = [
  53. { name: "Noctowl", types: ["trees"], weight: 2 },
  54. { name: "Defeat a Ponyta", types: ["thirty"], weight: 4 },
  55. { name: "Aipom", types: ["pompom"], weight: 4 },
  56. { name: "Use no repels", types: ["repel", "instant"], weight: 0 },
  57. { name: "7 Different berries", types: ["berry"], weight: 0 }
  58. ];
  59. bingoGoals[10] = [
  60. { name: "TM40 (Swagger)", types: ["sandwich"], weight: 6 },
  61. { name: "Graveler", types: ["gravel"], weight: 2 },
  62. { name: "Do not heal at any Pokemon Centers", types: ["heal", "instant"], weight: 0 },
  63. { name: "Defeat all 8 trainers on route 32", types: ["train"], weight: 0 }
  64. ];
  65. bingoGoals[11] = [
  66. { name: "TM10 (Hidden Power)", types: ["time"], weight: 0 },
  67. { name: "Burn Sudowoodo", types: ["wtf"], weight: 2 },
  68. { name: "Phanpy", types: ["time"], weight: 4 },
  69. { name: "HM05 (Flash)", types: ["flash"], weight: 0 }
  70. ];
  71. bingoGoals[12] = [
  72. { name: "Azumarill", types: ["time"], weight: 2 },
  73. { name: "A Pokemon with Focus Energy", types: ["focus"], weight: 8 },
  74. { name: "Win Bug Catching contest", types: ["day"], weight: 0 },
  75. { name: "Corsola", types: ["rod"], weight: 4 }
  76. ];
  77. bingoGoals[13] = [
  78. { name: "Catch Shuckle", types: ["shuck"], weight: 4 },
  79. { name: "Do not use any TMs", types: ["tm", "instant"], weight: 0 },
  80. { name: "A shiny Pokemon", types: ["waters"], weight: 0 },
  81. { name: "Release starter before level 11", types: ["starter"], weight: 0 }
  82. ];
  83. bingoGoals[14] = [
  84. { name: "Miltank", types: ["time"], weight: 4 },
  85. { name: "TM 13 (Snore)", types: ["zzz"], weight: 0 },
  86. { name: "A Pokemon with 4 non-TM status moves", types: ["hop"], weight: 0 },
  87. { name: "Mystic Water", types: ["thirty"], weight: 0 }
  88. ];
  89. bingoGoals[15] = [
  90. { name: "20 TMs", types: ["tm"], weight: 0 },
  91. { name: "King's Rock", types: ["slow"], weight: 0 },
  92. { name: "Soft Sand", types: ["pro"], weight: 0 },
  93. { name: "Exp Share", types: ["whirl"], weight: 0 }
  94. ];
  95. bingoGoals[16] = [
  96. { name: "20 Pokemon owned", types: ["pkmn"], weight: 0 },
  97. { name: "Mantine", types: ["mant"], weight: 4 },
  98. { name: "Heracross", types: ["hera"], weight: 4 },
  99. { name: "Evolve Eevee", types: ["stone"], weight: 4 }
  100. ];
  101. bingoGoals[17] = [
  102. { name: "Stop starter evolving 6 times", types: ["starter"], weight: 1 },
  103. { name: "Wobbuffet", types: ["time"], weight: 4 },
  104. { name: "Xatu", types: ["alph"], weight: 2 },
  105. { name: "Defeat Lapras", types: ["day"], weight: 0 }
  106. ];
  107. bingoGoals[18] = [
  108. { name: "Poliwhirl", types: ["raise"], weight: 2 },
  109. { name: "Encounter Suicune on route 42", types: ["cune"], weight: 0 },
  110. { name: "Dunsparce", types: ["sparce"], weight: 4 },
  111. { name: "4 Rare Candies", types: ["rare"], weight: 5 }
  112. ];
  113. bingoGoals[19] = [
  114. { name: "A Pokemon with pursuit", types: ["suit"], weight: 8 },
  115. { name: "Pokemon with an evasion boosting move", types: ["ass"], weight: 4 },
  116. { name: "TM 46 (Thief)", types: ["whirl"], weight: 6 },
  117. { name: "Nidoking or Nidoqueen", types: ["nido"], weight: 1 }
  118. ];
  119. bingoGoals[20] = [
  120. { name: "Granbull", types: ["raise"], weight: 2 },
  121. { name: "Berry Juice", types: ["shuck"], weight: 5 },
  122. { name: "Max phonebook", types: ["battles"], weight: 0 },
  123. { name: "HM02 (Fly)", types: ["whee"], weight: 0 }
  124. ];
  125. bingoGoals[21] = [
  126. { name: "Mineralbadge", types: ["steel"], weight: 0 },
  127. { name: "80 Pokemon seen", types: ["pkmn"], weight: 0 },
  128. { name: "Electrode", types: ["elec"], weight: 2 },
  129. { name: "3 baby Pokemon", types: ["egg"], weight: 4 }
  130. ];
  131. bingoGoals[22] = [
  132. { name: "Bayleef", types: ["starter"], weight: 2 },
  133. { name: "TM21 (Frustration) or TM27 (Return)", types: ["day"], weight: 0 },
  134. { name: "A Pokemon with Flame Wheel", types: ["starter"], weight: 8 },
  135. { name: "Own 10 different Flying type Pokemon", types: ["pkmn"], weight: 2 }
  136. ];
  137. bingoGoals[23] = [
  138. { name: "3 level 30 Pokemon", types: ["red"], weight: 0 },
  139. { name: "Glacierbadge", types: ["whirl"], weight: 0 },
  140. { name: "Defeat 10 Pokemaniacs", types: ["harley"], weight: 0 },
  141. { name: "Sandslash", types: ["raise"], weight: 2 }
  142. ];
  143. bingoGoals[24] = [
  144. { name: "$50,000", types: ["money", "cash"], weight: 0 },
  145. { name: "Battle a Legendary Pokemon", types: ["ass"], weight: 0 },
  146. { name: "30 Pokemon owned", types: ["pkmn"], weight: 0 },
  147. { name: "Lanturn", types: ["raise"], weight: 2 }
  148. ];
  149. bingoGoals[25] = [
  150. { name: "Jumpluff", types: ["raise"], weight: 1 },
  151. { name: "Receive elixer from Fishing Guru", types: ["karp"], weight: 8 },
  152. { name: "Win a Battle Tower match", types: ["gg"], weight: 100 },
  153. { name: "6 Badges", types: ["whee"], weight: 0 }
  154. ];
  155.  
  156. var bingo = function (aaaa) {
  157.  
  158. var bingoList = bingoGoals;
  159. var size = 5;
  160.  
  161. function gup(name) {
  162. name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  163. var regexS = "[\\?&]" + name + "=([^&#]*)";
  164. var regex = new RegExp(regexS);
  165. var results = regex.exec(window.location.href);
  166. if (results == null)
  167. return "";
  168. else
  169. return results[1];
  170. }
  171.  
  172. var LANG = gup('lang');
  173. if (LANG == '') LANG = 'name';
  174. var SEED = "" + aaaa;
  175.  
  176. if (SEED == "") {
  177. window.location = '?seed=' + Math.ceil(999999 * Math.random());
  178. } else {
  179. var MODE = gup('mode');
  180. if (typeof size == 'undefined') size = 5;
  181.  
  182. Math.seedrandom(SEED); //sets up the RNG
  183. var MAX_SEED = 999999; //1 million cards
  184.  
  185. var lineCheckList = [];
  186.  
  187.  
  188. if (size == 5) {
  189.  
  190. lineCheckList[1] = [1, 2, 3, 4, 5, 10, 15, 20, 6, 12, 18, 24];
  191. lineCheckList[2] = [0, 2, 3, 4, 6, 11, 16, 21];
  192. lineCheckList[3] = [0, 1, 3, 4, 7, 12, 17, 22];
  193. lineCheckList[4] = [0, 1, 2, 4, 8, 13, 18, 23];
  194. lineCheckList[5] = [0, 1, 2, 3, 8, 12, 16, 20, 9, 14, 19, 24];
  195.  
  196. lineCheckList[6] = [0, 10, 15, 20, 6, 7, 8, 9];
  197. lineCheckList[7] = [0, 12, 18, 24, 5, 7, 8, 9, 1, 11, 16, 21];
  198. lineCheckList[8] = [5, 6, 8, 9, 2, 12, 17, 22];
  199. lineCheckList[9] = [4, 12, 16, 20, 9, 7, 6, 5, 3, 13, 18, 23];
  200. lineCheckList[10] = [4, 14, 19, 24, 8, 7, 6, 5];
  201.  
  202. lineCheckList[11] = [0, 5, 15, 20, 11, 12, 13, 14];
  203. lineCheckList[12] = [1, 6, 16, 21, 10, 12, 13, 14];
  204. lineCheckList[13] = [0, 6, 12, 18, 24, 20, 16, 8, 4, 2, 7, 17, 22, 10, 11, 13, 14];
  205. lineCheckList[14] = [3, 8, 18, 23, 10, 11, 12, 14];
  206. lineCheckList[15] = [4, 9, 19, 24, 10, 11, 12, 13];
  207.  
  208. lineCheckList[16] = [0, 5, 10, 20, 16, 17, 18, 19];
  209. lineCheckList[17] = [15, 17, 18, 19, 1, 6, 11, 21, 20, 12, 8, 4];
  210. lineCheckList[18] = [15, 16, 18, 19, 2, 7, 12, 22];
  211. lineCheckList[19] = [15, 16, 17, 19, 23, 13, 8, 3, 24, 12, 6, 0];
  212. lineCheckList[20] = [4, 9, 14, 24, 15, 16, 17, 18];
  213.  
  214. lineCheckList[21] = [0, 5, 10, 15, 16, 12, 8, 4, 21, 22, 23, 24];
  215. lineCheckList[22] = [20, 22, 23, 24, 1, 6, 11, 16];
  216. lineCheckList[23] = [2, 7, 12, 17, 20, 21, 23, 24];
  217. lineCheckList[24] = [20, 21, 22, 24, 3, 8, 13, 18];
  218. lineCheckList[25] = [0, 6, 12, 18, 20, 21, 22, 23, 19, 14, 9, 4];
  219.  
  220. }
  221.  
  222. function mirror(i) {
  223. if (i == 0) { i = 4; }
  224. else if (i == 1) { i = 3; }
  225. else if (i == 3) { i = 1; }
  226. else if (i == 4) { i = 0; }
  227. return i;
  228. }
  229.  
  230. function difficulty(i) {
  231. // To create the magic square we need 2 random orderings of the numbers 0, 1, 2, 3, 4.
  232. // The following creates those orderings and calls them Table5 and Table1
  233.  
  234. var Num3 = SEED % 1000; // Table5 will use the ones, tens, and hundreds digits.
  235.  
  236. var Rem8 = Num3 % 8;
  237. var Rem4 = Math.floor(Rem8 / 2);
  238. var Rem2 = Rem8 % 2;
  239. var Rem5 = Num3 % 5;
  240. var Rem3 = Num3 % 3; // Note that Rem2, Rem3, Rem4, and Rem5 are mathematically independent.
  241. var RemT = Math.floor(Num3 / 120); // This is between 0 and 8
  242.  
  243. // The idea is to begin with an array containing a single number, 0.
  244. // Each number 1 through 4 is added in a random spot in the array's current size.
  245. // The result - the numbers 0 to 4 are in the array in a random (and uniform) order.
  246. var Table5 = [0];
  247. Table5.splice(Rem2, 0, 1);
  248. Table5.splice(Rem3, 0, 2);
  249. Table5.splice(Rem4, 0, 3);
  250. Table5.splice(Rem5, 0, 4);
  251.  
  252. Num3 = Math.floor(SEED / 1000); // Table1 will use the next 3 digits.
  253. Num3 = Num3 % 1000;
  254.  
  255. Rem8 = Num3 % 8;
  256. Rem4 = Math.floor(Rem8 / 2);
  257. Rem2 = Rem8 % 2;
  258. Rem5 = Num3 % 5;
  259. Rem3 = Num3 % 3;
  260. RemT = RemT * 8 + Math.floor(Num3 / 120); // This is between 0 and 64.
  261.  
  262. var Table1 = [0];
  263. Table1.splice(Rem2, 0, 1);
  264. Table1.splice(Rem3, 0, 2);
  265. Table1.splice(Rem4, 0, 3);
  266. Table1.splice(Rem5, 0, 4);
  267.  
  268. i--;
  269. RemT = RemT % 5; // Between 0 and 4, fairly uniformly.
  270. x = (i + RemT) % 5; // RemT is horizontal shift to put any diagonal on the main diagonal.
  271. y = Math.floor(i / 5);
  272.  
  273. // The Tables are set into a single magic square template
  274. // Some are the same up to some rotation, reflection, or row permutation.
  275. // However, all genuinely different magic squares can arise in this fashion.
  276. var e5 = Table5[(x + 3 * y) % 5];
  277. var e1 = Table1[(3 * x + y) % 5];
  278.  
  279. // Table5 controls the 5* part and Table1 controls the 1* part.
  280. value = 5 * e5 + e1;
  281.  
  282. if (MODE == "short") { value = Math.floor(value / 2); } // if short mode, limit difficulty
  283. else if (MODE == "long") { value = Math.floor((value + 25) / 2); }
  284. value++;
  285. return value;
  286. }
  287.  
  288. function checkLine(i, typesA) {
  289. var synergy = 0;
  290. for (var j = 0; j < lineCheckList[i].length; j++) {
  291. var typesB = bingoBoard[lineCheckList[i][j] + 1].types;
  292. if (typeof typesB != 'undefined') {
  293. for (var k = 0; k < typesA.length; k++) {
  294. for (var l = 0; l < typesB.length; l++) {
  295. if (typesA[k] == typesB[l]) {
  296. synergy++; // if match increase
  297. if (k == 0) { synergy++ }; // if main type increase
  298. if (l == 0) { synergy++ }; // if main type increase
  299. }
  300. }
  301. }
  302. }
  303. }
  304. return synergy;
  305. }
  306.  
  307.  
  308. var bingoBoard = []; //the board itself stored as an array first
  309. for (var i = 1; i <= 25; i++) {
  310. bingoBoard[i] = { difficulty: difficulty(i) }; //array with objects that
  311. //console.log(bingoBoard[i].difficulty); //store the difficulty
  312. } // in order 1-25
  313.  
  314. var totalWeight = 0;
  315.  
  316. //populate the bingo board in the array
  317. for (var i = 1; i <= 25; i++) {
  318. var getDifficulty = bingoBoard[i].difficulty; // difficulty of current square
  319. var RNG = Math.floor(bingoList[getDifficulty].length * Math.random());
  320. if (RNG == bingoList[getDifficulty].length) { RNG--; }; //fix a miracle
  321. var j = 0, synergy = 0, currentObj = null, minSynObj = null;
  322.  
  323. do {
  324. currentObj = bingoList[getDifficulty][(j + RNG) % bingoList[getDifficulty].length];
  325. synergy = checkLine(i, currentObj.types);
  326. if (minSynObj == null || synergy < minSynObj.synergy) {
  327. minSynObj = { synergy: synergy, value: currentObj };
  328. }
  329. j++;
  330. } while ((synergy != 0) && (j < bingoList[getDifficulty].length));
  331.  
  332. bingoBoard[i].types = minSynObj.value.types;
  333. bingoBoard[i].name = minSynObj.value[LANG] || minSynObj.value.name;
  334. bingoBoard[i].synergy = minSynObj.synergy;
  335. totalWeight += minSynObj.value.weight;
  336. }
  337.  
  338. return totalWeight;
  339.  
  340. }
  341.  
  342. } // setup
  343.  
  344. var seedArray = []
  345. for (var i = 1; i <= 100000; i++ ) {
  346. var seed = i;
  347. var value = bingo(i);
  348. seedArray.push({ seed: seed, value: value });
  349. }
  350.  
  351. function custom_compare (a,b) {
  352. return a.value - b.value;
  353. }
  354.  
  355. seedArray.sort(custom_compare);
  356.  
  357. var out = ""
  358. for(var i = 0; i < 20; i++) {
  359. out += seedArray[i].seed;
  360. out += ", ";
  361. }
  362. console.log(out);
Advertisement
Add Comment
Please, Sign In to add comment