|
Post by elcoyote on Oct 23, 2018 5:55:04 GMT
Several years ago I received help from ''TyCamden, Welopez, and tsh73" to create a manual "Bingo Callling Board," Thank You! But now I'm trying to revise that program to "automatic randomly select numbers 1 to 75 (American Bingo). Believe I have the basic program working - with one minor problem. Cleaning the board of already called numbers and starting over again. If you see anywhere the program can be improve - please do so - the last time we talked was 10 year ago and I'm now pushing 80. Bingo Caller 8ea.bas (8.3 KB)
|
|
|
Post by tsh73 on Oct 23, 2018 8:28:05 GMT
put nextgame label up, so it clears screen/redraws and add redim to clear arrays
[nextgame]
redim the(75) redim a(75) 'clear arrays #main "fill White" 'clear the board #main "down; backcolor White" #main "flush"
clickit=0
'-----------------------------------------------------------------
|
|
|
Post by B+ on Oct 23, 2018 19:57:25 GMT
This looks like the Generator part:
for nextnumber=1 to 75 do the(nextnumber)=int(75*rnd(1)+1) alreadyfound=0 for j=1 to nextnumber if a(j)=the(nextnumber) then alreadyfound=1 exit for end if next j loop until alreadyfound=0 a(nextnumber)=the(nextnumber) next nextnumber
I remember I posted something like this for cards and being lectured (rightly) about Fisher-Yates.
Why not just shuffle the numbers and draw them in order they ended up, then no worries if you drew it already because you didn't!
|
|
|
Post by B+ on Oct 24, 2018 14:33:06 GMT
Something like this:
'setup '' global callIndex, NumberIs 'eh! use gosub so it's kept global dim numbers(75) for i = 1 to 75 numbers(i) = i next
'test calling method for i = 1 to 75 'first just check 1 deck scan gosub [callME] print ME;" "; if i mod 10 = 0 then print next print input "One Deck load presented, press enter to check going past it a couple of times"; enter$ print for i = 1 to 300 'first just check 1 deck gosub [callME] print ME;" "; if i mod 10 = 0 then print if i mod 75 = 0 then print : print next end
[shuffle] 'fisher-yates shuffle Ha! a Lesson DON"T USE i for indexing in a GOSUB for shuffleI = 75 to 2 step -1 shuffleR = int(rnd(0) * shuffleI) + 1 shuffleT = numbers(shuffleR) numbers(shuffleR) = numbers(shuffleI) numbers(shuffleI) = shuffleT next return
[callME] if callIndex = 0 then gosub [shuffle] callIndex = callIndex + 1 if callIndex > 75 then gosub [shuffle] : callIndex = 1 ME = numbers(callIndex) return
|
|
|
Post by elcoyote on Oct 29, 2018 19:56:26 GMT
I previously posted a "quick reply" but I don't see it on the board. So I'm trying again! Thank you - tsh73 - you hit the nail on the head, AGAIN!!!!
|
|