Jump to content

Need idea: ID generation - Bingo game


Recommended Posts

I'd create an array with all the possible number...then loop through random numers vs the array subscripts, creating a second array...where the random number's max is the ubound of the original array...then when you move from 1st to second...delete the first arrays subscript, until it is no longer an array (ubound = 0)..second array are your 'random' numbers

example with 10 cards (not doing dupe checks)

#include <array.au3>

Local $aFixed[90]
Local $aOriginal[90]
Local $aRandom[90]
For $i = 0 to UBound($aFixed)-1
    $aFixed[$i]=$i+1
Next

$iTotalGameCards = 10
Local $aAllCards[$iTotalGameCards]
For $i = 0 To UBound($aAllCards)-1
    $aOriginal = $aFixed

    $iCounter = 0
    While UBound($aOriginal)>0
        $iRandom = Random(0, UBound($aOriginal)-1,1)
        $aRandom[$iCounter]=$aOriginal[$iRandom]
        _ArrayDelete($aOriginal,$iRandom)
        $iCounter +=1
    WEnd
    $aAllCards[$i]=$aRandom
Next

For $i = 0 To UBound($aAllCards)-1
    _ArrayDisplay($aAllCards[$i])
Next

using a 2d array:

#include <array.au3>

Local $aFixed[90]
Local $aOriginal[90]

For $i = 0 to UBound($aFixed)-1
    $aFixed[$i]=$i+1
Next


$iMaxRows = 10
$iMaxCols = 9

$iTotalGameCards = 10
Local $aAllCards[$iTotalGameCards]
For $i = 0 To UBound($aAllCards)-1
    $aOriginal = $aFixed
    Local $aRandom[$iMaxRows][$iMaxCols]

    While UBound($aOriginal)>0
        For $j = 0 To UBound($aRandom)-1
            For $k = 0 To UBound($aRandom,2)-1
                $iRandom = Random(0, UBound($aOriginal)-1,1)
                $aRandom[$j][$k]=$aOriginal[$iRandom]
                _ArrayDelete($aOriginal,$iRandom)
            Next
        Next
    WEnd
    $aAllCards[$i]=$aRandom
Next

For $i = 0 To UBound($aAllCards)-1
    _ArrayDisplay($aAllCards[$i])
Next
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...