MINCUS1308
07-18-2018, 04:47 AM
I'm making minesweeper in excel because they don't have any games on the computers at work.
As part of this, I'm attempting to generate 'x' unique random numbers and then store them in MyArray.
For i = 1 To NoOfMines
Do
MineValue = CInt(Int((Size * Size - 1) * Rnd + 1))
Loop Until IsError(Application.Match(CInt(MineValue), MyArray, 0))
MyArray(i, 0) = MineValue
Next I
Typically I generate 'x-1' unique numbers with 1 number repeated. '[(x-1)+1=x]
Every now and again I get 'x' unique numbers but its pretty rare.
I cannot identify a pattern of repeats associated with the iteration of 'i'.
Any thoughts about the folly in my logic?
As part of this, I'm attempting to generate 'x' unique random numbers and then store them in MyArray.
For i = 1 To NoOfMines
Do
MineValue = CInt(Int((Size * Size - 1) * Rnd + 1))
Loop Until IsError(Application.Match(CInt(MineValue), MyArray, 0))
MyArray(i, 0) = MineValue
Next I
Typically I generate 'x-1' unique numbers with 1 number repeated. '[(x-1)+1=x]
Every now and again I get 'x' unique numbers but its pretty rare.
I cannot identify a pattern of repeats associated with the iteration of 'i'.
Any thoughts about the folly in my logic?