Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Life
- def initialize (a, b, c)
- #Matrizengrösse x und y
- @a = a
- @b = b
- #Startkonfiguration
- @c = c
- #Die erste Ziffer ist bedeutungslos die zweite ist die Distanz x+1
- #die dritte die Distanz y+1
- @Umgebung = [121,112,101,110,122,100,120,102]
- @e1= 23; @e2=32; @e3=11
- #@Feld = Array.new(@a) { Array.new(@b) { Array.new(4,0) } }
- field
- end
- #erstelle Felder
- def field
- @Feld = Array.new(@a) do |x|
- Array.new(@b) do |y|
- r = [1, @c % 4, 0, 0 ]
- @c = (@c - @c%4)/4
- r
- end
- end
- end
- #def field
- #x = 0
- #y = 0
- #while (x < @a)
- #while (y < @b)
- #@Feld[x][y][1] = @c%4
- #@c= (@c - @c%4)/4
- #y= y+1
- #end
- #x= x+1
- #end
- # Sortiere nach Kategorien und führe den Test durch
- def testWechsel
- x1=0 ;x2=0; x3=0 ;x0=0
- x01=0; x02=0; x03=0
- x12=0; x13=0; x23=0
- x012=0; x013=0; x023=0
- x123=0
- #begin
- @Umgebung.each do |u|
- #einordnen , zählen wieviele von welchem typus
- case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][1]
- when @e1%10
- # case @Ersatz[1+((u/10)%10)-1][1+(u%10)-1][2]
- # when @e1%10
- # case @Ersatz[1+((u/10)%10)-1][1+(u%10)-1][3]
- # when @e1%10 & @e2/10!=0
- then x1=x1+1 break
- # when @e2%10 then x12=x12+1 break
- # when @e3%10 then x13=x13+1 break
- else x01=x01+1
- # end
- # when @e2%10 & @e2%10!=0
- # case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][3]
- # when @e1%10 then x12=x12+1 break
- # when @e2%10 then x12=x12+1 break
- # when @e3%10 then x123=x123+1 break
- # else x012=x012+1
- # end
- # when @e3%10 & @e3%10!=0
- # case @Ersatz[n+((u/10)%10)-1][m+(u%10)-1][3]
- # when @e1%10 then x13=x13+1 break
- # when @e2%10 then x123=x123+1 break
- # when @e3%10 then x13=x13+1 break
- # else x013=x013+1
- # end
- # else x01=x01+1
- # end
- else x0=x0+1
- end
- #rescue SyntaxError
- #end
- end
- #Prüfe ob sich der Änderungswert ändert
- def testRegel
- end
- #Starte den test
- def testmain
- @Ersatz=[]+ @Feld
- @Ersatz.each do |n|
- n.each do |m|
- testWechsel
- testRegel
- end
- end
- end
- end
- l = Life.new(4, 5, 417)
Add Comment
Please, Sign In to add comment