【3色・青+赤=黄】ランダムに生成され、オセロ的に収束する空間。
1 プログラム
青と赤が隣り合ったら黄色になるプログラムを作ってみました。Option Explicit Sub jikken() Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer Dim c As Integer Dim o As Long For o = 1 To 10 For i = 1 To 50 For j = 1 To 50 Randomize c = Int(3 * Rnd) Cells(i, j) = c If c = 0 Then Cells(i, j).Interior.Color = RGB(255, 255, 0) ElseIf c = 1 Then Cells(i, j).Interior.Color = RGB(0, 0, 255) Else Cells(i, j).Interior.Color = RGB(255, 0, 0) End If Next j Next i For k = 1 To 49 Step 2 For l = 1 To 50 If (Cells(k, l).Interior.Color = RGB(0, 0, 255) And Cells(k + 1, l).Interior.Color = RGB(255, 0, 0)) Or (Cells(k, l).Interior.Color = RGB(255, 0, 255) And Cells(k + 1, l).Interior.Color = RGB(0, 0, 255)) Then Cells(k, l).Interior.Color = RGB(255, 255, 0) Cells(k + 1, l).Interior.Color = RGB(255, 255, 0) End If Next l Next k For n = 1 To 49 Step 2 For m = 1 To 50 If (Cells(m, n).Interior.Color = RGB(0, 0, 255) And Cells(m, n + 1).Interior.Color = RGB(255, 0, 0)) Or (Cells(m, n).Interior.Color = RGB(255, 0, 255) And Cells(m, n + 1).Interior.Color = RGB(0, 0, 255)) Then Cells(m, n).Interior.Color = RGB(255, 255, 0) Cells(m, n + 1).Interior.Color = RGB(255, 255, 0) End If Next m Next n Next o End Sub
2 実行結果
・【3色・青+赤=黄】ランダムに生成され、オセロ的に収束する空間(東三河狂人堂主人)・ランダムに生成され、オセロ的に収束する空間(まとめ記事)に戻る。