Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Is there an easier way!

Author
Message
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 23rd Apr 2007 12:56
Hi.

Is there an easier way of matching numbers.

Here is the code im using for the random part:

Rem Random draw begins
randomize timer()
random_number = rnd(50)
random_number2 = rnd(50)
random_number3 = rnd(50)
play sound 1
text 240,235, STR$(random_number)
sleep 2000
play sound 1
text 260,235, STR$(random_number2)
sleep 2000
play sound 1
text 280,235, STR$(random_number3)
sleep 2000

This is for matching the player number to 1 random number that is drawn. This require only 1 line of code, so its easy.

If player_number = random_number or random_number2 or random_number3 then
player_credit=player_credit +10

Here is the complicated part, or maiby its the only way of doing this. This is for matching multiple, if the player gets 2 matches or 3 instead 1.

Else if player_number = random_number and random_number2
player_credit=player_credit +20
Else if player_number = random_number and random_number3
player_credit=player_credit +20
Else if player_number = random_number2 and random_number3
player_credit=player_credit +20
Else if player_number = random_number and random_number2 and random_number3
player_credit=player_credit +50

This is not so complicated, but i want 10 random numbers. I then have to code in this way to match all kinds of patterns.

Is there an easier way of doing this?

As always, all help is very much appreciated.
Hammaman
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 23rd Apr 2007 14:45
I'm not sure I understand what you're trying to do fully , but will have a stab at a reply ...

I would tend to check the player_number against each random number separately, and keep a "score" of how many times they are identical.

For example,
num_identical = 0
If player_number = random_number1 Then num_identical = num_identical + 1
If player_number = random_number2 Then num_identical = num_identical + 1
... and so on.

Then simply increase the players score by the number of matches held in num_identical.

I'd also look into using an array to hold the random numbers (and scores for the number of matches), as this would enable you to loop through each of the tests above.

Hope this helps!
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 23rd Apr 2007 16:16
Thanks for the help Hammaman.

This is pretty much the same way im doing it now, i still have to code every single match in every kind of pattern like you just did above.

Isnt there an easier way of calculating how many matches the player gets?

Also, how do i use the an array to hold the numbers etc...I am only familier with the way im doing now.
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 23rd Apr 2007 16:30
How about arrays?

Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 23rd Apr 2007 17:01
Thanks for the help Crit.

But, that dident work for me. How does it know how many matches it gets. If the player gets 1 match the payout will be 10, 2 match 50, 3 match 100 etc...

Seems tho i still have to code every pattern of match still.

But this is usefull, now i dont have to assign random_number 1,2,3 etc...

Im still struggling to get it to calculate matches automatic, and to act acordingly to give the correct payouts.
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 23rd Apr 2007 17:17
Then make another array with the payouts and do something like this:

player_payout = payoutarray(count)
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 23rd Apr 2007 20:00
I cant get it to work because i dont know how to set up the code proparly in hole.

Would it be to much trouble?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Apr 2007 20:14
No arrays are needed for this. Here you go...



TDK_Man

Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 23rd Apr 2007 20:24
Just to be complete, here is code added to my first example:

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Apr 2007 20:30
Just re-read your earlier post and noticed the winnings are not 10 per matching number. So, you would need to do a small modification in the 'Select & Display 10 Random Numbers' section...

If the payout were 10 for 1 match, 20 for 2 matches and so on, you could use a formula. However as this isn't the case, this would be best done using an array.

Dim PayoutMultiplier(10)

PayoutMultiplier(1) = 1
PayoutMultiplier(2) = 5
PayoutMultiplier(3) = 10


...and so on.

In effect, the value stored in element 1 is the number to multiply 10 by for one match. Element 2 is what to multiply 10 by for two matches and so on. Just set them up at the start.

New version:



I've also added a NumbersInDraw variable for testing purposes. Set this to say 10 to increase the odds of winning and check the payout.

TDK_Man

Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 23rd Apr 2007 21:38
Great, thanks to all 3 of you for providing me help.

I will copy and paste in the codes and and try them right now!

Regards, Staale.

Login to post a reply

Server time is: 2024-09-25 21:30:18
Your offset time is: 2024-09-25 21:30:18