It is currently Tue May 23, 2017 9:51 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Bingo
Unread postPosted: Tue May 02, 2017 10:26 am 
Offline

Joined: Tue May 02, 2017 10:11 am
Posts: 2
Sorry, do you help me to do a simple program to randomly extract 90 different numbers (bingo)? With rfobasic I did not succeed.
Hello and sorry if it hurts. Domenico from sicily


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Tue May 02, 2017 6:50 pm 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Hi Micu,

the simple way would be to dimension an array to 90 elements, then in a FOR..NEXT loop to fill the array from 1 to 90, finally shuffle the array and get all shuffled elements in another FOR..NEXT loop.

Now it's your turn to implement all that ;) it should be easy enough with the help of the manual at http://rfo-basic.com/manual

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Wed May 03, 2017 2:12 am 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
mougino wrote:
the simple way would be to dimension an array to 90 elements, then in a FOR..NEXT loop to fill the array from 1 to 90, finally shuffle the array and get all shuffled elements in another FOR..NEXT loop.

Not knowing about
Quote:
Array.shuffle Array[{<start>,<length>}]}
Randomly shuffles the values of the specified array (Array[] or Array$[])
or array segment (Array[start,length] or Array$[start,length])

... I wondered how to go about doing a shuffle! But I've never been interested in games so would not notice such a function.

BTW I think there is a spurious "}" to be removed from the first line of that quote (and of Array.sort and of Array.std_dev) in the manual.

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Wed May 03, 2017 2:25 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
@Mike you would swap different array indices at least 45 times for good randomness ;)

_________________
- Creator of the Android BASIC! Compiler


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Wed May 03, 2017 10:24 pm 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 92
Dim x, mix, temp As Integer
Dim num As Integer = 90 'This could be any number
Dim randarray(num) As Integer
Dim randnum As Random = New Random()

'Assign sequential values to array
For x = 1 To num
randarray(x) = x
Next x

'Swap the array indexes randomly
For x = num To 1 Step -1
mix = randnum.Next(1, x)
temp = randarray(mix)
randarray(mix) = randarray(x)
randarray(x) = temp
Next x

'Display all the rearranged array values in a listbox
lstShuffle.Items.Clear()
For x = 1 To num
lstShuffle.Items.Add(randarray(x))
Next x


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Thu May 04, 2017 2:36 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
cavelamb wrote:
Dim x, mix, temp As Integer
Dim num As Integer = 90 'This could be any number
Dim randarray(num) As Integer
Dim randnum As Random = New Random()

'Assign sequential values to array
For x = 1 To num
randarray(x) = x
Next x

'Swap the array indexes randomly
For x = num To 1 Step -1
mix = randnum.Next(1, x)
temp = randarray(mix)
randarray(mix) = randarray(x)
randarray(x) = temp
Next x

'Display all the rearranged array values in a listbox
lstShuffle.Items.Clear()
For x = 1 To num
lstShuffle.Items.Add(randarray(x))
Next x

I get "Array variable expected" on the first line. Program does not run.

_________________
- Creator of the Android BASIC! Compiler


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Thu May 04, 2017 3:47 am 
Offline

Joined: Tue Dec 04, 2012 10:50 am
Posts: 656
Location: UK
mougino wrote:
I get "Array variable expected" on the first line. Program does not run.

I think the trick may be to decide what language the snippet is written in...

But I like the idea of a variable type called "Random". It is a very slippery concept!

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Bingo
Unread postPosted: Thu May 04, 2017 7:16 am 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1135
Location: From Blighty
I always thought that Bingo was a British invention (Why not assume? We practically invented everything anyway!). A Google did not only reveal that mad one from the 'Banana Splits'. [The talking moose with light bulbs for ears used to scare me as a kid...], but the game could have been Invented in Italy.

Pseudo code is great, I hope no-one minds, I did this as a demo of ARRAY.SHUFFLE.

Here's some eccentricities of what with each number -- where it has been assigned -- a 'nickname.'.

Source:

https://en.m.wikipedia.org/wiki/List_of ... _nicknames

Tra-la-la-la-la:-

Code:
% BASIC!'s easy way of replacing DIM and DATA dielect

ARRAY.LOAD bingo$[], "Kelly's Eye", "One little duck", "Cup of tea", "Knock at the door", "Man alive", "Tom Mix", "Lucky", "Garden gate", "Doctor's Orders", "(Theresa's) Den", "Legs eleven", "One dozen [wolf whistle]", "Unlucky for some", "The Lawnmower", "Young and Keen", "Never been kissed", "Dancing Queen", "Coming of Age", "Goodbye Teens", "One Score", "Key of the Door", "Two little ducks", "The Lord is My Shepherd", "Knock at the door", "Duck and dive", "Two and six", "Duck and a crutch", "Two and eight", "Rise and Shine", "Burlington Bertie", "Get Up and Run", "Buckle My Shoe", "All the threes", "Ask for More", "Jump and Jive", "Three dozen", "[37]", "[38]", "Steps", "[40]", "[41]", "[42]", "[43]", "Droopy drawers", "Halfway there", "[46]", "[47]", "Four Dozen", "[49]", "It's a bullseye!", "[51]", "Danny La Rue", "Here comes Herbie", "Man at the door", "Musty Hive", "Shotts Bus", "Heinz Varieties", "[58]", "The Brighton Line", "Grandma's getting frisky", "[61]", "Tickety-boo", "[63]", "Almost retired", "Stop work", "Clickety click", "[67]", "[68]", "Anyway up", "[70]", "Bang on the Drum", "Danny La Rue", "Queen Bee. Under The Tree", "[74]", "[75]", "Trombones", "Two little crutches", "39 more steps", "[79]", "Gandhi's Breakfast", "Fat Lady", "[82]", "Stop Farting!", "Seven dozen", "Staying alive", "Between the sticks", "Torquay in Devon", "Two Fat Ladies", "Nearly there. Almost there", "Top of the shop"

% A little string manipulation to add the numbers to the nicknames...
FOR i = 1 TO 90
  bingo$[i] = INT$(i) + " = " + bingo$[i]
NEXT i

% ARRAY.SHUFFLE and PRINT is now your Bingo caller...

ARRAY.SHUFFLE bingo$[]
FOR i = 1 TO 90
  PRINT bingo$[i]
NEXT i


Bet everyone is singing the theme tune now...

♫ Tra-la-la-la-la Tra-la-la-la-la-la... ♫

Mog


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred