Advertisement
Guest User

Weakness finder source code

a guest
Jul 16th, 2017
1,995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. package notDefault;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. // TODO Auto-generated method stub
  7. int typeCount = 18;
  8. Type[] types = new Type[typeCount];
  9. types[0] = new Type("Rock", 1, 2, 1, 2, 0.5, 1, 0.5, 2, 0.5, 1, 0.5, 1, 2, 2, 1, 1, 1, 1);
  10. types[1] = new Type("Water", 1, 0.5, 2, 2, 1, 1, 0.5, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 1, 1, 1);
  11. types[2] = new Type("Electric", 1, 1, 0.5, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 1, 0.5, 1, 1, 1, 1);
  12. types[3] = new Type("Grass", 1, 0.5, 0.5, 0.5, 2, 1, 2, 0.5, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1);
  13. types[4] = new Type("Poison", 1, 1, 1, 0.5, 0.5, 2, 1, 2, 1, 0.5, 1, 1, 0.5, 1, 1, 1, 1, 0.5);
  14. types[5] = new Type("Psychic", 1, 1, 1, 1, 1, 0.5, 1, 1, 1, 2, 1, 2, 0.5, 1, 1, 1, 2, 1);
  15. types[6] = new Type("Fire", 2, 2, 1, 0.5, 1, 1, 0.5, 2, 1, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 0.5);
  16. types[7] = new Type("Ground", 0.5, 2, 0, 2, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1);
  17. types[8] = new Type("Flying", 2, 1, 2, 0.5, 1, 1, 1, 0, 1, 0.5, 1, 1, 0.5, 1, 2, 1, 1, 1);
  18. types[9] = new Type("Bug", 2, 1, 1, 0.5, 1, 1, 2, 0.5, 2, 1, 1, 1, 0.5, 1, 1, 1, 1, 1);
  19. types[10] = new Type("Normal", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1);
  20. types[11] = new Type("Ghost", 1, 1, 1, 1, 0.5, 1, 1, 1, 1, 0.5, 0, 2, 0, 1, 1, 1, 2, 1);
  21. types[12] = new Type("Fighting", 0.5, 1, 1, 1, 1, 2, 1, 1, 2, 0.5, 1, 1, 1, 1, 1, 1, 0.5, 2);
  22. types[13] = new Type("Steel", 0.5, 1, 1, 0.5, 0, 0.5, 2, 2, 0.5, 0.5, 0.5, 1, 2, 0.5, 0.5, 0.5, 1, 0.5);
  23. types[14] = new Type("Ice", 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 0.5, 1, 1, 1);
  24. types[15] = new Type("Dragon", 1, 0.5, 0.5, 0.5, 1, 1, 0.5, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2);
  25. types[16] = new Type("Dark", 1, 1, 1, 1, 1, 0, 1, 1, 1, 2, 1, 0.5, 2, 1, 1, 1, 0.5, 2);
  26. types[17] = new Type("Fairy", 1, 1, 1, 1, 2, 1, 1, 1, 1, 0.5, 1, 1, 0.5, 2, 1, 0, 0.5, 1);
  27.  
  28. for(int i = 1; i <= typeCount; i ++){
  29. Type[] combo = new Type[i];
  30. search(combo, types, 0, 0, typeCount);
  31. }
  32. }
  33.  
  34. public static void search(Type[] combo, Type[] types, int currentComboIndex, int currentTypeIndex,
  35. int typeCount){
  36. //System.out.println("first print " + currentComboIndex);
  37. for(int i = currentTypeIndex; i < typeCount; i ++){
  38. //System.out.println(currentComboIndex + " " + i);
  39. //System.out.println("second print " + currentComboIndex);
  40. combo[currentComboIndex] = types[i];
  41.  
  42. //System.out.println(currentComboIndex + " " + combo.length);
  43. if(currentComboIndex + 1 < combo.length){
  44. //System.out.println(i);
  45. search(combo, types, currentComboIndex + 1, i + 1, typeCount);
  46. }
  47. else{
  48. boolean noWeakness = true;
  49.  
  50. for(int j = 0; j < typeCount; j ++){
  51. double effect = 1;
  52.  
  53. for(int k = 0; k < combo.length; k ++){
  54. effect *= combo[k].effects[j];
  55. }
  56.  
  57. if(effect > 1){
  58. noWeakness = false;
  59. }
  60. }
  61.  
  62. if(noWeakness){
  63. for(int k = 0; k < combo.length; k ++){
  64. System.out.print(combo[k].name + " ");
  65. }
  66.  
  67. System.out.print("\n");
  68. }
  69. }
  70. }
  71. }
  72. }
  73.  
  74. package notDefault;
  75.  
  76. public class Type {
  77. public String name;
  78. public double[] effects = new double[18];
  79.  
  80. public Type(String inString, double arg0, double arg1, double arg2, double arg3, double arg4, double arg5,
  81. double arg6, double arg7, double arg8, double arg9, double arg10, double arg11, double arg12, double arg13,
  82. double arg14, double arg15, double arg16, double arg17){
  83. name = inString;
  84. effects[0] = arg0;
  85. effects[1] = arg1;
  86. effects[2] = arg2;
  87. effects[3] = arg3;
  88. effects[4] = arg4;
  89. effects[5] = arg5;
  90. effects[6] = arg6;
  91. effects[7] = arg7;
  92. effects[8] = arg8;
  93. effects[9] = arg9;
  94. effects[10] = arg10;
  95. effects[11] = arg11;
  96. effects[12] = arg12;
  97. effects[13] = arg13;
  98. effects[14] = arg14;
  99. effects[15] = arg15;
  100. effects[16] = arg16;
  101. effects[17] = arg17;
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement