Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::: REM New Version at https://pastebin.com/bqVtyqPx
- ::: REM Saturday lotto - Rolls in groups of 8 Games of 6 balls, out of 45 possible balls, No duplicant balls (except final 3 balls (45/6 =7.5 games)).
- ::: REM Will Roll any Number of Games without retaining duplicate Games. (until maximum number of possible Combinations reached)
- ::: REM Displays rolled games and Stores them to a text file
- @echo off
- setlocal enabledelayedexpansion
- Mode 1000
- ::: REM - Game_Number variable used to track total number of Games rolled.
- Set G_N=0
- :start
- cls
- Set C_B=1
- :gen_1to45
- ECHO [1;1H[K[33mRolling Games...
- Set /a ball[%C_B%]=%random% %%45 +1
- :: REM - IF condition sends script to test function to determine if Current Ball is a repeat of Previous balls rolled - Condition checks from 2nd ball onwards.
- ::: Function Increments the Array (Ball Count) upon passing test
- ::: Ball count is only incremented if there is no duplication, - enforcing a reroll upon duplication.
- If %C_B% GTR 1 (
- GOTO :testballs
- ) else (
- Set /a C_B+=1
- GOTO gen_1to45
- )
- :gen_46to48
- ECHO [1;1H[K[33mRolling Games...
- Set /a ball[46]=%random% %%45 +1
- Set /a ball[47]=%random% %%45 +1
- Set /a ball[48]=%random% %%45 +1
- Set "_CB=42"
- ::: Progressively Calls a function to compare balls 42- 48 against each other for duplicants
- For /L %%a in (43,1,47) DO (
- CALL :testfinal6 %%a !_CB!
- Set /a _CB+=1
- )
- GOTO :display
- :display
- ECHO [1;1H[K[36mSorting...
- ::: Sorts Low to High and Sets Balls to Games in groups of 6, assigned to Array according to game Number.
- Set /a G_N+=1
- CALL :sort ball[1] !ball[1]! ball[2] !ball[2]! ball[3] !ball[3]! ball[4] !ball[4]! ball[5] !ball[5]! ball[6] !ball[6]!
- Set "game[!G_N!]=!ball[1]!,!ball[2]!,!ball[3]!,!ball[4]!,!ball[5]!,!ball[6]!"
- Set check[1]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[7] !ball[7]! ball[8] !ball[8]! ball[9] !ball[9]! ball[10] !ball[10]! ball[11] !ball[11]! ball[12] !ball[12]!
- Set "game[!G_N!]=!ball[7]!,!ball[8]!,!ball[9]!,!ball[10]!,!ball[11]!,!ball[12]!"
- Set check[2]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[13] !ball[13]! ball[14] !ball[14]! ball[15] !ball[15]! ball[16] !ball[16]! ball[17] !ball[17]! ball[18] !ball[18]!
- Set "game[!G_N!]=!ball[13]!,!ball[14]!,!ball[15]!,!ball[16]!,!ball[17]!,!ball[18]!"
- Set check[3]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[19] !ball[19]! ball[20] !ball[20]! ball[21] !ball[21]! ball[22] !ball[22]! ball[23] !ball[23]! ball[24] !ball[24]!
- Set "game[!G_N!]=!ball[19]!,!ball[20]!,!ball[21]!,!ball[22]!,!ball[23]!,!ball[24]!"
- Set check[4]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[25] !ball[25]! ball[26] !ball[26]! ball[27] !ball[27]! ball[28] !ball[28]! ball[29] !ball[29]! ball[30] !ball[30]!
- Set "game[!G_N!]=!ball[25]!,!ball[26]!,!ball[27]!,!ball[28]!,!ball[29]!,!ball[30]!"
- Set check[5]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[31] !ball[31]! ball[32] !ball[32]! ball[33] !ball[33]! ball[34] !ball[34]! ball[35] !ball[35]! ball[36] !ball[36]!
- Set "game[!G_N!]=!ball[31]!,!ball[32]!,!ball[33]!,!ball[34]!,!ball[35]!,!ball[36]!"
- Set check[6]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[37] !ball[37]! ball[38] !ball[38]! ball[39] !ball[39]! ball[40] !ball[40]! ball[41] !ball[41]! ball[42] !ball[42]!
- Set "game[!G_N!]=!ball[37]!,!ball[38]!,!ball[39]!,!ball[40]!,!ball[41]!,!ball[42]!"
- Set check[7]=!game[%G_N%]!
- Set /a G_N+=1
- CALL :sort ball[43] !ball[43]! ball[44] !ball[44]! ball[45] !ball[45]! ball[46] !ball[46]! ball[47] !ball[47]! ball[48] !ball[48]!
- Set "game[!G_N!]=!ball[43]!,!ball[44]!,!ball[45]!,!ball[46]!,!ball[47]!,!ball[48]!"
- Set check[8]=!game[%G_N%]!
- ::: REM Calls a function to compare all games and ensure no Games are the same.
- IF !G_N! GTR 8 CALL :Game_Comp
- ::: REM Removes previous Game file
- IF EXIST "LottoNumbers.txt" (
- DEL /Q "LottoNumbers.txt"
- )
- ::: REM Expands game Array and Displays to Screen, then Saves to file.
- cls
- FOR /L %%a in (1,1,!G_N!) DO (
- ECHO [37mGame[[33m%%a[37m] [90m:[36m !game[%%a]!
- ECHO Game[%%a] : !game[%%a]!>>LottoNumbers.txt
- )
- :: TYPE LottoNumbers.txt
- ::: REM Option to roll another lot of 8 games or Exit
- ECHO [35m[Roll More? Y/N:][32m
- CHOICE /T 2 /N /C:ynp /D y
- IF ERRORLEVEL==3 GOTO :hold
- IF ERRORLEVEL==2 GOTO :end
- IF ERRORLEVEL==1 GOTO :start
- ::: REM *** End Script Main. Commence Functions.
- :end
- exit
- :hold
- pause >nul
- Goto :start
- ::: Compares Balls using Negative Array offset, Ensuring No balls within a game Match
- :testballs
- Set offset=%C_B%
- Set /a offset-=1
- For /L %%a in (1,1,!offset!) DO (
- IF !ball[%%a]!==!ball[%C_B%]! (
- ECHO [2;1H[K[31m../O[32m
- GOTO gen_1to45
- ) else (
- ECHO [2;1H[K[32m O\..[32m
- )
- )
- IF !C_B!==45 GOTO gen_46to48
- Set /a C_B+=1
- GOTO gen_1to45
- :testfinal6
- Set start=%1
- Set _CB=%2
- ::: Compares Balls using positive Array offset, Ensuring No balls within the game Match
- For /L %%b in (!start!,1,48) DO (
- IF !ball[%_CB%]!==!ball[%%b]! (
- ECHO [2;1H[K[31m../O[32m
- GOTO gen_46to48
- )
- )
- GOTO :EOF
- :Game_Comp
- :: REM - "Comparison_Range" Variable offset by a number equal to number of the Games in each round from the total number of Rounds rolled.
- Set C_R=!G_N!
- Set /a C_R=!C_R!-8
- :: REM - "_Games to Compare" Variable Counts down throughout the Comparison Range to display remaining number of Comparisons to be made.
- Set _GtC=!C_R!
- FOR /L %%b IN (1,1,!C_R!) DO (
- CALL SET /a _GtC-=1
- CALL ECHO [6;1H[K[37m [[31m!_GtC![37m] [90mremaining...[32m
- CALL :Comp_all %%b
- )
- GOTO :EOF
- :: REM - Comparison Function Uses Parameter from the above For Loop to identify previous games to compare the 8 Games from the current Round against
- :: REM - using the the below For Loop.
- :Comp_all
- FOR /L %%c IN (1,1,8) DO (
- CALL ECHO [1;1H[31m[07m[K Comparing:[32m
- CALL ECHO [2;1H[0m[K[37m Game[[33m%%c[37m] [36m!check[%%c]![32m
- CALL ECHO [3;1H[K[35mVs.[32m
- CALL ECHO [4;1H[K[37m Game[[33m%1[37m] [34m!game[%1]![32m
- IF "!check[%%c]!"=="!game[%1]!" (
- cls
- ECHO game[%%c] = !check[%%c]! matches game[%1] = !game[%1]!
- Set /a G_N=!G_N!-8
- pause
- GOTO :start
- )
- )
- GOTO :EOF
- ::: REM - Assigns the Parameters to values to Allow Sorting and return of Sorted Values to game Array
- :: REM tkn[n] is the value of the Ball number of the Calling Round.
- :: REM return[n] is the Variable Name the Value of the Ball is to be returned to.
- :sort
- set S_O=0
- For %%a in (%*) DO (
- Set /a S_O+=1
- IF !S_O!==1 SET return[1]=%%a
- IF !S_O!==2 SET tkn[1]=%%a
- IF !S_O!==3 SET return[2]=%%a
- IF !S_O!==4 SET tkn[2]=%%a
- IF !S_O!==5 SET return[3]=%%a
- IF !S_O!==6 SET tkn[3]=%%a
- IF !S_O!==7 SET return[4]=%%a
- IF !S_O!==8 SET tkn[4]=%%a
- IF !S_O!==9 SET return[5]=%%a
- IF !S_O!==10 SET tkn[5]=%%a
- IF !S_O!==11 SET return[6]=%%a
- IF !S_O!==12 SET tkn[6]=%%a
- )
- ::: REM - Sorts from Last ball to First, Comparing against each previous Ball and exchanging places along the way.
- :: On IF Condition being true, the Value of tkn[n] is exchanged with the ball being compared through use of a temporary Variable.
- FOR /L %%a IN (1,1,5) DO (
- CALL :Delay 2
- IF !tkn[6]! LSS !tkn[%%a]! (
- Set tmp=!tkn[6]!
- Set tkn[6]=!tkn[%%a]!
- Set tkn[%%a]=!tmp!
- ECHO [2;1H[K[33m^<^<^<^<^<[32m
- ) else (
- ECHO [2;1H[K[32m==I==[32m
- )
- )
- FOR /L %%a IN (1,1,4) DO (
- CALL :Delay 2
- IF !tkn[5]! LSS !tkn[%%a]! (
- Set tmp=!tkn[5]!
- Set tkn[5]=!tkn[%%a]!
- Set tkn[%%a]=!tmp!
- ECHO [2;1H[K[33m^<^<^<^<^<[32m
- ) else (
- ECHO [2;1H[K[32m==I==[32m
- )
- )
- FOR /L %%a IN (1,1,3) DO (
- CALL :Delay 2
- IF !tkn[4]! LSS !tkn[%%a]! (
- Set tmp=!tkn[4]!
- Set tkn[4]=!tkn[%%a]!
- Set tkn[%%a]=!tmp!
- ECHO [2;1H[K[33m^<^<^<^<^<[32m
- ) else (
- ECHO [2;1H[K[32m==I==[32m
- )
- )
- FOR /L %%a IN (1,1,2) DO (
- CALL :Delay 2
- IF !tkn[3]! LSS !tkn[%%a]! (
- Set tmp=!tkn[3]!
- Set tkn[3]=!tkn[%%a]!
- Set tkn[%%a]=!tmp!
- ECHO [2;1H[K[33m^<^<^<^<^<[32m
- ) else (
- ECHO [2;1H[K[32m==I==[32m
- )
- )
- FOR /L %%a IN (1,1,1) DO (
- CALL :Delay 2
- IF !tkn[2]! LSS !tkn[%%a]! (
- Set tmp=!tkn[2]!
- Set tkn[2]=!tkn[%%a]!
- Set tkn[%%a]=!tmp!
- ECHO [2;1H[K[33m^<^<^<^<^<[32m
- ) else (
- ECHO [2;1H[K[32m==I==[32m
- )
- )
- FOR /L %%a IN (1,1,6) DO (
- Set !return[%%a]!=!tkn[%%a]!
- )
- GOTO :EOF
- ::: REM - Used to control the refresh rate of text on screen during FOR Loops that would otherwise refresh too quickly.
- :Delay
- FOR /L %%D IN (1,1,%1) DO (
- CALL :IncDelay
- )
- GOTO :EOF
- :IncDelay
- GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment