所以我正在开发一个扫雷游戏并分配地雷,但我无法创建一个算法来阻止地雷去一个已经有地雷的地方,这就是我目前所拥有的:
公共子 initflags()
Dim line, column As Integer
For line = 0 To 9
For column = 0 To 9
mat(line, column) = 0
Next
Next
Dim numbandeiras As Integer
Dim r, c As Integer
Do Until numbandeiras = 34
Randomize()
line = Int(Rnd() * 10)
column = Int(Rnd() * 10)
r = line
c = column
If r And c = 1 Then
mat(line, column) = 0
Else
numbandeiras = numbandeiras + 1
Call avisinhos()
mat(line, column) = 1
End If
Loop
End Sub
有人可以帮助我吗?最好的问候,乔奥。