Advertisement
sam1509

Untitled

Nov 9th, 2019
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. public static int ThirdRule(int[][]matrix) {
  2. int penalty=0;
  3.  
  4. int[]test1= {W,W,W,W,B,W,B,B,B,W,B};
  5.  
  6. int[] test2= {B,W,B,B,B,W,B,W,W,W,W};
  7.  
  8. int ligne = 0;
  9. int colonne = 0;
  10. int comboTest1 = 0;
  11. int comboTest2 = 0;
  12. int sequence1 = 0;
  13. int sequence2 = 0;
  14. boolean superpos = false;
  15. //ligne
  16. for(int i=0;i<matrix.length;++i) {
  17.  
  18. while ((ligne < matrix.length -1) && (sequence1<2)) {
  19.  
  20. if(test1[comboTest1] == matrix[ligne][i]) {
  21. ++comboTest1;
  22. if(comboTest1 == test1.length-1 ) {
  23. penalty += 40;
  24. ++sequence1;
  25. comboTest1 = 0;
  26. }
  27. }else {
  28. comboTest1=0;
  29. }
  30. if(test2[comboTest2] == matrix[ligne][i]) {
  31. ++comboTest2;
  32. if(comboTest2 == test2.length-1 ) {
  33. penalty += 40;
  34. superpos= true;
  35. comboTest2 = 0;
  36. }else {
  37. comboTest2=0;
  38. }
  39. ++sequence1;
  40. if (superpos == true) {
  41. for (int j=0; j<(8) && (superpos == true); ++j) {
  42.  
  43. if(test1[test1.length-4-j]!= matrix[ligne-j-11][i]) {
  44. superpos = false;
  45. }
  46.  
  47.  
  48. }
  49. if (superpos == true) {
  50. penalty -= 40;
  51. }
  52. }
  53.  
  54. }
  55.  
  56.  
  57. ++ligne;
  58. }
  59. if(sequence1 >= 2) {
  60. sequence1 = 0;
  61. }
  62.  
  63. ligne = 0;
  64. superpos = false;
  65.  
  66. while ((ligne < matrix.length -1) && (sequence2<2)) {
  67.  
  68. if(test1[comboTest1] == matrix[i][ligne]) {
  69. ++comboTest1;
  70.  
  71. if(comboTest1 == test1.length-2 ) {
  72.  
  73. penalty += 40;
  74.  
  75. ++sequence2;
  76.  
  77.  
  78.  
  79. comboTest1 = 0;
  80. }
  81. }else {
  82. comboTest1=0;
  83. }
  84. if(test2[comboTest2] == matrix[i][ligne]) {
  85. ++comboTest2;
  86. if(comboTest2 == test2.length-1 ) {
  87. penalty += 40;
  88. ++sequence2;
  89. comboTest2 = 0;
  90. superpos = true;
  91. }else {
  92. comboTest2=0;
  93. }
  94.  
  95. if (superpos == true) {
  96. for (int j=0; j<(8) && (superpos == true); ++j) {
  97. if(test1[test1.length-4-j]!= matrix[i][ligne-j-11]) {
  98. superpos = false;
  99. }
  100.  
  101.  
  102. }
  103. if (superpos == true) {
  104. penalty -= 40;
  105. }
  106. }
  107.  
  108. }
  109.  
  110.  
  111. ++ligne;
  112. }
  113. if(sequence1 >= 2) {
  114. sequence1 = 0;
  115. }
  116. ligne = 0;
  117. superpos= false;
  118. }
  119.  
  120.  
  121. //colonne
  122.  
  123.  
  124.  
  125.  
  126. return penalty;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement