Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. String crittmp = data.remove(0);
  2. Double criticalValue = Double.parseDouble(crittmp);
  3. criticalValue /= (tab.length*tab.length);
  4. System.err.println("CRITICAL VALUE = " + criticalValue);
  5.  
  6.  
  7. List<Double> steps = new ArrayList<>();
  8.  
  9. for(String s : data)
  10. steps.add(Double.parseDouble(s.trim()));
  11.  
  12. int TIME = steps.size();
  13.  
  14. transformTab();
  15.  
  16. for(int step = 0; step < TIME; step++){
  17. double pula = steps.remove(0);
  18. double ro = pula / (tab.length*tab.length);
  19.  
  20. boolean[][] border = new boolean[tab.length][tab.length];
  21. for(int i=0; i <tab.length; i++){
  22. for(int j=0; j<tab.length; j++){
  23. border[i][j] = isBorder(i, j);
  24. }
  25. }
  26.  
  27.  
  28. for(int i = 0; i < tab.length; i++){
  29. for(int j = 0; j < tab.length; j++){
  30.  
  31. if(border[i][j]){
  32. newTab[i][j].points += 0.8 * ro;
  33. pula -= 0.8 * ro;
  34. } else {
  35. newTab[i][j].points += 0.2 * ro;
  36. pula -= 0.2 * ro;
  37. }
  38.  
  39. if(newTab[i][j].points >= criticalValue){
  40. game.doExplode(newTab, i, j);
  41. System.out.println("reach critical value!");
  42. if(!AFTER)AFTER = true;
  43. }
  44.  
  45. }
  46. }
  47.  
  48. Random rand = new Random();
  49. while(pula > 0){
  50. int i = rand.nextInt(tab.length);
  51. int j = rand.nextInt(tab.length);
  52. if(border[i][j]){
  53. newTab[i][j].points += 0.8 * ro;
  54. pula -= 0.8 * ro;
  55. } else {
  56. newTab[i][j].points += 0.2 * ro;
  57. pula -= 0.2 * ro;
  58. }
  59. if(newTab[i][j].points >= criticalValue){
  60. game.doExplode(newTab, i, j);
  61. System.out.println("reach critical value!");
  62. if(!AFTER)AFTER = true;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement