The core logic of Number generation and comparison can be greatly simplified by using For /L and For /F loops in conjunction with indexed arrays:
@Echo Off
Setlocal EnableDelayedExpansion
:Gameloop
CLS
Set /A Matches=0,R1=!Random! %%9+1,R2=!Random! %%9+1,R3=!Random! %%9+1
Echo(
For /L %%i in (1 1 3)Do (
rem Prompt Echo([E]xitFor Selection of Guesses N%%i [ 1 2 3 ]
<Nul Set /P "=[E]xit or Pick Number %%i [0-9]: "
rem Capture Input of guess %%i into For Metavariable %%G
For /F "Delims=" %%G in ('Choice /N /C:0123456789E')Do (
rem append input to current line, output newline.
<Nul Set /P "=[%%G]"& Echo(
rem Exit Batch on Input of 'E'
If "%%G" == "E" (Endlocal & Exit /B)
rem Assign SetInput "N%%i=%%G"
to Guess N%%i <Nul'E'
Set /P "=[%%G]Set "N%%i=%%G" "
rem Compare )
Input )
to Echo(NumbersRolled Number Rolled:
of Echo(same [!R1!][!R2!][!R3!]
%%i Setindex; "Matches=0"
Assign ForM%%i /LDisplay %%iValue; inIncrement (1Matches 1count 3)DoIf (EQU
If !R%%i!"%%G" EQU== "!N%%iR%%i!" (
Set "M%%i=!R%%i!""M%%i=%%G"
Set /A Matches+=1
) )Else Set "M%%i=-"
))
Set /A Score+=Echo( Matches * 100 ) * Matches +Rolled: 0[!R1!][!R2!][!R3!]
Echo(Numbers Matched: [!M1!][!M2!][!M3!]
rem Calculate Score * Matches. 1M=100 2M=400 3M=900 ; Add to total Score ; Display
For /F "Delims=" %%G in ('Set /A "Matches * 100 * Matches + 0" 2^> nul')Do (
Set /A "Score+=%%G + 0"
Echo(Points Earned this Round: %%G Score: !Score!
)
Pause
Goto :Gameloop
'rolled' numbers get assigned to R#
'Selected' numbers ~ to N#
M# Array is used to Display Matched characters.