JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Minesweeper help with rnd()/randomization to set mines Archived to Disk
As a simple tip, without going into too much detail:
Rnd is always a decimal less than 1 (I believe at least, it may go to 1), CInt(Rnd()*5+1) Will be a random number from 1 to 5.
if conOdds = 10/64 then conOdds wil allways =.1564
Think of it this way, If you pick ten random numbers from 1-64 they could all be greater than 32, or all below 32. Your code checks to see if it's below .1564, which as you can possibly tell, could display no mines to 64 mines.
I'd suggest creating the array, then marking ten of them as a mine randomily. that is, have all fields as no mines, then select a random x,y coordinate.
An example being:
Do
x = Rnd * 8 + 1
y = Rnd * 8 + 1
If Field(x, y) = False Then
Field(x, y) = True 'Is mine
mines = mines + 1
End If
Loop Until mines = 10
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|