Microsoft Small Basic

Program Listing: FKW997
' Binero Generator
' Copyright © 2019 Nonki Takahashi. The MIT License.

GraphicsWindow.Title = "Binero Generator"
Init()
Show()
While "True"
Program.Delay(100)
Randomize()
Show()
EndWhile

Sub Init
Not["False"] = "True"
Not["True"] = "False"
size = 30
n = 10
gw = size * n
gh = size * n
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "Black"
For row = 1 To n
b = Math.Remainder(row, 2)
y = (row - 1) * size
For col = 1 To n
x = (col - 1) * size
bLine[col] = b
cLine[col] = Shapes.AddRectangle(size, size)
Shapes.Move(cLine[col], x, y)
b = 1 - b
EndFor
board[row] = bLine
cell[row] = cLine
EndFor
EndSub

Sub Randomize
found = "False"
While Not[found]
r = Math.GetRandomNumber(n - 1)
c = Math.GetRandomNumber(n - 1)
score = 0
bLine = board[r]
b = bLine[c]
If bLine[c + 1] <> b Then
score = score + 1
EndIf
bLine = board[r + 1]
If bLine[c] <> b Then
score = score + 1
EndIf
If bLine[c + 1] = b Then
score = score + 1
EndIf
If score = 3 Then
found = "True"
EndIf
EndWhile
For row = r To r + 1
bLine = board[row]
For col = c To c + 1
bLine[col] = 1 - bLine[col]
EndFor
board[row] = bLine
EndFor
EndSub

Sub Show
For row = 1 To n
cLine = cell[row]
bLine = board[row]
For col = 1 To n
If bLine[col] = 1 Then
Shapes.ShowShape(cLine[col])
Else
Shapes.HideShape(cLine[col])
EndIf
EndFor
EndFor
EndSub