PDA

View Full Version : lotto script part one

Lionheart008
26-02-2009, 20:43
hi all:)

does anybody can help???
it's just a test for me how to handle with arrays... and numbers...
the results aren't ok, doesn't belong between 1 and 49, but that wasn't still important for me... the "zusatzzahl" doesn't run as well as I wish... other things are ok...

' Empty ThinBASIC CONSOLE file template by lionheart for new lotto script in thinbasic

uses "console"
DIM i as long
DIM Lottozahlen(6), Zusatzzahl AS INTEGER
Lottozahlen(1) = 1, 2, 3, 4, 5, 6

FOR i = 1 to 6
Lottozahlen(i) = INT(RND(1)*49) + 1
NEXT i
Zusatzzahl = INT(RND(1)*49) + 1

PRINTL (" Die heutigen Lottozahlen: ")
FOR i = 1 TO 6
PRINT LTRIM\$(STR\$(i)) + ". " + LTRIM\$(STR\$(Lottozahlen(i)))
PRINTL (Lottozahlen(i), "")
NEXT i
waitkey
PrintL ("-Push key for extra number: -")
PrintL
PRINTL (" Und die Zusatzzahl ist die: " + LTRIM\$(STR\$(Zusatzzahl))) + " ." )
PRINTL ("end of lottozahlen short script")

more will come as soon as my original lotto script has more clearness and brightness :)

ciao , good evening, Lionheart

Petr Schreiber
26-02-2009, 20:54
Hi Frank,

I know it might sound rude, but as long as you will use German naming for variables I cannot join ( from German language I know only "schreiber" :lol: ).

Petr

Lionheart008
26-02-2009, 23:01
uses "console"
DIM i as long
DIM Lottonumber(6), extranumber AS INTEGER
Lottonumber(1) = 1, 2, 3, 4, 5, 6

' lottonumber = lottozahlen, you draw six number of 49 possibilities, 6 numbers of 49 drop down of a sphere into glasses ;)
' extranumber = after the drawing of six number you can get the 7th number as extranumber and earn more money

FOR i = 1 to 6
Lottonumber(i) = INT(RND(1)*49) + 1
NEXT i
Extranumber = INT(RND(1)*49) + 1

PRINTL (" actual drawing of Lottonumbers: ")
FOR i = 1 TO 6
PRINT LTRIM\$(STR\$(i)) + ". " + LTRIM\$(STR\$(Lottonumber(i)))
PRINTL (Lottonumber(i), "")
NEXT i
waitkey
PrintL ("-Push key for extra number: -")
PrintL
PRINTL (" And the extranumber is : " + LTRIM\$(STR\$(Extranumber))) + " ." )
PRINTL ("end of lottonumber short script")

you are right, sorry ;)
the problem is to draw 6 numbers of 49 line per line and a extranumber (the 7th number)...

my idea is: you can make an input for six numbers into console (ui, tbgl will follow), then the sphere full of 49 numbers is rotating or calculating the end results... so you can see if you have won at the end of the script or how many numbers agree with your choosen number at first... ;)

any more questions??? :-D so we can make a competition where you can get or win the collecting jackpot money for the thinbasic donations :)))))

best regards, Lionheart
ps: this is only one part of the "lotto 6 of 49" script ;) more will come...

from German language I know only "schreiber" Laughing ).
yes: petr, you know more of your name petr is peter... and perhaps "Prost" and "Servus" :))))

Petr Schreiber
26-02-2009, 23:15
I know this game :),

here is modified code for you, you will see the results fit perfectly in given range.

INT(RND(1)*49) + 1

... yes, you can use this in languages with simple RND implementation, but in thinBasic you can go more comfortable with ;):

RND(1, 49)

And the code isssss ... this:

uses "console"
dim i as long
dim Lottonumber(6), extranumber as long
Lottonumber(1) = 1, 2, 3, 4, 5, 6

' lottonumber = lottozahlen, you draw six number of 49 possibilities, 6 numbers of 49 drop down of a sphere into glasses Wink
' extranumber = after the drawing of six number you can get the 7th number as extranumber and earn more money

for i = 1 to 6
Lottonumber(i) = rnd(1, 49)
next
Extranumber = rnd(1, 49)

printl (" actual drawing of Lottonumber: ")
for i = 1 to 6
printl strformat\$("{1}. {2}", i, Lottonumber(i))
next
waitkey
printl ("-Push key for extra number: -")
printl
printl (" And the extranumber is :" + str\$(Extranumber) + " ." )
printl ("end of lottonumber short script")
waitkey

Thanks,
Petr

Michael Clease
27-02-2009, 00:00
Or this if you prefer random numbers that dont repeat.

uses "console"
DIM i, temp as long
DIM Lotto(49) AS LONG
DIM Lottonumbers(7) AS LONG

' lottonumber = lottozahlen, you draw six number of 49 possibilities, 6 numbers of 49 drop down of a sphere into glasses

' extranumber = after the drawing of six number you can get the 7th number as extranumber and earn more money

FOR i = 1 to 49
Lotto(i) = 1
NEXT
i = 1
RANDOMIZE

DO
temp = rnd(1,49)
if Lotto(temp) = 1 THEN
Lottonumbers(i) = temp
Lotto(temp) = 0
INCR i
ENDIF
LOOP UNTIL i > 7

PRINTL (" Your Lotto numbers are: ")
FOR i = 1 TO 6
PRINTL ("Ball "+i+" "+STR\$(LottoNumbers(i)))
NEXT
PrintL ("-Push key for extra number: -")
waitkey
PrintL
PRINTL (" And the extranumber is : " + STR\$(LottoNumbers(7)))
PRINTL ("end of lottonumber short script")
waitkey

Petr Schreiber
27-02-2009, 00:16
Michael,

that was very good tip :), I completely forgot about repeat of rnd values.

Also:

randomize timer

can be used on the beginning of the program for similar effect.

Lionheart008
27-02-2009, 11:52
hi petr, michael, all:)

yes, thank you both... for info and script! :)))

that's looking very nice and such a similar example I have built yesterday too;) but without the double numbers (don't repeat) and that was my next step... :twisted: must laugh... sometimes somebody is faster but it's not important, because I have to check it for me in the same way...

randomize timer... is in my next script :)
lottonumbers (7) ... I have found it tonight at an old cplusplus program for arrays... good!

I have built a simple array which uses the rnd feature and without it (shuffle)...
the example I add here... a good exercise for arrays with an amount of numbers you can choose...

that's good for any project you have started that there are more examples and exercises you can create beside the original script ;)

ciao and more will come, have all a nice day, Lionheart

Lionheart008
27-02-2009, 19:30
hi lotto winner:)

have done the next step, see the added script ;)

@abraxas:
question: your script (good one!) results show numbers very close (near) together... eg. 28, 30, 31, 32, 34, 35 extranumber 36...
it's possible to avoid the increasing (incr i) factor??? and replace it with another command??? to get more different numbers as result?

petr's script (also good one!) makes more variety (various) of the lotto numbers but they are in this case often double or repeat the extranumber...

perhaps somebody can check my script, if it's the same case... I have tried to avoid it.. but I am not sure...

the second part of the script is a new exercise, not ready but I will take an input for integer or numbers of the users and then you can make the lotto game and check the results... I will make it tomorrow...

best wishes, good evening, Lionheart goes to week-end :D

ciao...

ps: a little update will come:)

Lionheart008
24-05-2009, 21:25
hi dear lotto freaks :)

I would like to improve the lotto script again... and go on for gold or win the jackpot ! :D
I need the money to buy a sailing ship in summertime to conquer the bodensee with friends in germany :lol:

...but first of all I need a little help for a message box I have done something wrong, but cannot see the mistake... I have some headache from sunny weather and not fresh in my mind ;)

script part as followed...

PRINTL ("--some first rnd results:---")
FOR i = 1 to 6
Anz(i) = rnd(1, 49)
NEXT i
Extranumber = rnd(1, 49)

printl (" -- Here it comes: the actual drawing of LottoNumbers with Balls: --")
printl
for i = 1 to 6
printl strformat\$("{1}.Lottoball: {2}", i, Anz(i))
msgbox 0, "Lottonumbers results: " + strformat\$("{1}.Lottoball: {2}", i, Anz(i)), "Lotto"
next
printl ("-Push key for extra number: -")
waitkey
printl ("-wait a moment :) -")
printl

printl (" and the Extranumber is : " + LTRIM\$(STR\$(Extranumber)) + " " )
'msgbox 0, "Lottonumbers extra number: " + LTRIM\$(STR\$(Extranumber)) + " " ), "Lotto"
printl

this is wrong... the last code line of the script...
'msgbox 0, "Lottonumbers extra number: " + LTRIM\$(STR\$(Extranumber)) + " " ), "Lotto"

but why...???

ciao 3, Lionheart

Michael Hartlef
24-05-2009, 21:27
Remove the second ")" after LTRIM\$

Lionheart008
24-05-2009, 21:52
@michael:)

yeah !!! I have tomatoes on my eyes... uargh ...
thank you! :drink:

lottoscript part two... "2b", more to come too :)

'-lottozahlen 6 aus 49 pretesting by lionheart, 21-26.februar2009 :)
'- with little help from petr, michael and abraxas... , new input: may 2009

uses "console", "Math", "File", "UI"

DIM W AS INTEGER 'i
DIM Anz(7), i as LONG
DIM Zahl(49), temp as LONG
DIM Wuerfel, Augen, Q, Extranumber as long
DIM x as long

RANDOMIZE TIMER
Zahl(1) = 1,2,3,4,5,6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
Anz(1) = 1, 2, 3, 4, 5, 6,7 ' Ziel: 6 aus 49 !

PRINTL (" a little 'LOTTONUMBER' DEMO_Testprogram :) ")
PRINTL ("----------------")

PRINTL ("--some first rnd results:---")
FOR i = 1 to 6
Anz(i) = rnd(1, 49)
NEXT i
Extranumber = rnd(1, 49)

printl (" -- Here it comes: the actual drawing of LottoNumbers with Balls: --")
printl
for i = 1 to 6
printl strformat\$("{1}.Lottoball: {2}", i, Anz(i))
msgbox 0, "Lottonumbers results: " + strformat\$("{1}.Lottoball: {2}", i, Anz(i)), "Lotto"
next
printl ("-Push key for extra number: -")
waitkey
printl ("-wait a moment :) -")
printl

printl (" and the Extranumber is : " + LTRIM\$(STR\$(Extranumber)) + " " )
msgbox 0, "Lottonumbers extra number: " + LTRIM\$(STR\$(Extranumber) + " " ), "Lotto"
printl
printl ("-do you have won the jackpot? - end of little 'lottoball' script")
printl
waitkey
sleep 100
PrintL

FOR i = 1 to 49
Zahl(i) = 1
NEXT
i = 1
do
temp = rnd(1,49)
if Zahl(temp) = 1 THEN
anz(i) = temp
Zahl(temp) = 0
Incr i
ENDIF

LOOP UNTIL i > 7

'HiResTimer_Init
'STRT = HiResTimer_Get

PRINTL ("--extra: type in with integer numbers--")
PrintL
PrintL
wuerfel = ChkInput( "Enter: tumbling dice, tumbling: how many times? (numbers = 1-6) ", 1, 30) 'input integer
Augen = ChkInput( "Enter: How many eyes on the tumbling dice should be shown? (Eyes = 1-49) ", 1, 10)
Q = Augen
PRINTL (" ")

PRINTL("--------- next------------")

PRINTL
PRINTL("game: 6 of 49 Lotto programm is possible")
PRINTL ("tumbling dice Balance after Eyenumber of dice :")
FOR i = 1 to 6
PRINTL (" " & i & " * " & Anz(i) & "x" ) ' only one try:)
NEXT i
PRINTL("------------drawing of the lottoball game end ----------")

PRINTL ("-- wait and press any key to end.-- ")
SLEEP 500
' END
Waitkey
'--------------------------------------- ???
printl

Console_Write("Ok, now press any key to exit, messieurs et madames")

Console_WaitKey

FUNCTION ChkInput(sRequest AS STRING, minValue AS LONG, maxValue AS LONG) AS LONG
DIM wuerfelVal AS LONG
wuerfelVal = 0
minValue = 1
maxValue = 49
DO
PRINTL (sRequest)