Guest User

Untitled

a guest
Feb 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. class Life
  2. def initialize (a, b, c)
  3. #Matrizengrösse x und y
  4. @a = a
  5. @b = b
  6. #Startkonfiguration
  7. @c = c
  8. #Die erste Ziffer ist bedeutungslos die zweite ist die Distanz x+1
  9. #die dritte die Distanz y+1
  10. @Umgebung = [121,112,101,110,122,100,120,102]
  11. @e1= 23; @e2=32; @e3=11
  12. #@Feld = Array.new(@a) { Array.new(@b) { Array.new(4,0) } }
  13. field
  14. end
  15.  
  16. #erstelle Felder
  17. def field
  18. @Feld = Array.new(@a) do |x|
  19. Array.new(@b) do |y|
  20. r = [1, @c % 4, 0, 0 ]
  21. @c = (@c - @c%4)/4
  22. r
  23. end
  24. end
  25. end
  26. #def field
  27. #x = 0
  28. #y = 0
  29. #while (x < @a)
  30. #while (y < @b)
  31. #@Feld[x][y][1] = @c%4
  32. #@c= (@c - @c%4)/4
  33. #y= y+1
  34. #end
  35. #x= x+1
  36. #end
  37.  
  38. # Sortiere nach Kategorien und führe den Test durch
  39. def testWechsel
  40. x1=0 ;x2=0; x3=0 ;x0=0
  41. x01=0; x02=0; x03=0
  42. x12=0; x13=0; x23=0
  43. x012=0; x013=0; x023=0
  44. x123=0
  45. #begin
  46. @Umgebung.each do |u|
  47. #einordnen , zählen wieviele von welchem typus
  48. case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][1]
  49. when @e1%10
  50. # case @Ersatz[1+((u/10)%10)-1][1+(u%10)-1][2]
  51. # when @e1%10
  52. # case @Ersatz[1+((u/10)%10)-1][1+(u%10)-1][3]
  53. # when @e1%10 & @e2/10!=0
  54. then x1=x1+1 break
  55. # when @e2%10 then x12=x12+1 break
  56. # when @e3%10 then x13=x13+1 break
  57. else x01=x01+1
  58. # end
  59. # when @e2%10 & @e2%10!=0
  60. # case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][3]
  61. # when @e1%10 then x12=x12+1 break
  62. # when @e2%10 then x12=x12+1 break
  63. # when @e3%10 then x123=x123+1 break
  64. # else x012=x012+1
  65. # end
  66. # when @e3%10 & @e3%10!=0
  67. # case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][3]
  68. # when @e1%10 then x13=x13+1 break
  69. # when @e2%10 then x123=x123+1 break
  70. # when @e3%10 then x13=x13+1 break
  71. # else x013=x013+1
  72. # end
  73. # else x01=x01+1
  74. # end
  75. else x0=x0+1
  76. end
  77. #rescue SyntaxError
  78. #end
  79. end
  80.  
  81. #Prüfe ob sich der Änderungswert ändert
  82. def testRegel
  83.  
  84. end
  85.  
  86. #Starte den test
  87. def testmain
  88. @Ersatz=[]+ @Feld
  89. @Ersatz.each do |n|
  90. n.each do |m|
  91. testWechsel
  92. testRegel
  93. end
  94. end
  95.  
  96. end
  97.  
  98. end
  99.  
  100. l = Life.new(4, 5, 417)
Add Comment
Please, Sign In to add comment