抛砖引玉,我只写了一半,逻辑方面还没有完成- @ECHO OFF
- :Init
- ECHO A=0 B=0 >ll.txt
- SETLOCAL ENABLEDELAYEDEXPANSION
- Set _String=黑红梅方
- Set _Replace1=1 A 1 1
- Set _Replace2=A3 K 13 10
- Set _Replace3=A2 Q 12 10
- Set _Replace4=AA J 11 10
- Set _Replace5=A0 10 10 10
- Set /A _ZFen=0,_XFen=0,Total+=1
-
-
- :Start
- Set /A Count+=1,1/(2/Count) 2>nul||Set Count=2&&Goto SelectP
- If Not Defined _Computer2 (
- CALL :FaPai Computer%Count%
- If Not Defined _Computer2 (
- CALL :Screen "A" "!DianShu:~0,2!" "!HuaSe!"
- CAll :Back "A"
- )
- )
- CALL :FaPai Players%Count%
- CALL :Screen "B" "!DianShu:~0,2!" "!HuaSe!"
- Goto Start
-
- :SelectP
- Set /A CountP+=1,1/(3/CountP) 2>nul||Set CountP=3&&Goto SelectC
- If Not Defined _Players3 (
- Set ACount=2
- CALL :JiFen Players SelectP
- )
- CALL :Output
- Set /P Instr="(Quit;Enter any key;Enter):"
- If Defined Instr (
- If /I *!Instr! == *quit (
- Goto :eof
- ) Else (
- Set /A CountP=CountP-1
- Goto SelectC
- )
- )
- CALL :Console "Players" "B" "SelectP" %CountP%
- Goto %_Label%
-
- :SelectC
- Set /A CountC+=1,1/(3/CountC) 2>nul||Set CountC=3&&Goto End
- Set /A _Chk1=Players1+10,_Chk2=(21-ComputerFen-CountP)/2
- Set /A _Chk3=%random%%%2,_Chk4=%random%%%100
- If Not Defined _Computer3 (
- Set ACount=2
- CALL :JiFen Computer SelectC
- )
- If %ComputerFen% LSS 15 (
- Goto Next) Else (
- If !_Chk1! GTR !ComputerFen! (
- If !CountP! GTR 0 (
- If !_Chk2! GEQ 2 (
- If !_Chk3! EQU 1 (Goto Next)
- ) Else (
- If !_Chk2! LEQ -2 (
- If !_Chk4! EQU 99 (Goto Next)
- )
- )
- )
- )
- )
- Set /A CountC-=1
- Goto End
- :Next
- CALL :Console "Computer" "A" "SelectC" %CountC%
- Goto %_Label%
-
-
-
- :Console
- ::%1=Players(Computer) %2=B(A) %3=Select+C(P)
- Set /A ACount=Count+%~4
- CALL :FaPai %~1%ACount%
- CALL :JiFen %~1 %~3
- CALL :Screen "%~2" "!DianShu:~0,2!" "!HuaSe!"
- Goto :eof
-
- :FaPai
- ::%1=Computer(Players)+Count
- Set /A DianShu=%random%%%13+1
- If *!Set%DianShu%! == *Not Goto FaPai
- Set _%~1=%DianShu%
- If Not Defined Set%DianShu% (
- CALL :Strto
- Set Set%DianShu%=!Str!
- )
- Set Set%DianShu%=!Set%DianShu%:Not=!
- Set HuaSe=!Set%DianShu%:~0,1!
- Set Set%DianShu%=!Set%DianShu%:%HuaSe%=!Not
- :Conver
- For /F "tokens=2-5 delims== " %%a in ('
- Set _Replace') DO (
- Set "DianShu=!DianShu:%%a=%%b! "
- Set _%~1=!_%~1:%%c=%%d!
- )
- Set _x%~1=!DianShu:~0,2! !HuaSe!
- Goto :eof
-
- :Strto
- Set Str=%_String%
- Set /A _str1=%random%%%4
- Set _str2=!Str:~%_str1%,4!
- Set Str=%_str2%!Str:%_str2%=!
- Set /A _str1=%random%%%3+1
- Set _str2=!Str:~0,-%_str1%!
- Set Str=%_str2%!Str:%_str2%=!
- Goto :eof
-
- :JiFen
- Set /A Shangx=21,Fen=0,aaa=0,bbb=0,xxx=0
- For /L %%i in (1,1,%ACount%) DO (
- Set /A aaa=!_%~1%%i!,bbb=aaa/^(aaa*aaa^)*10,Fen+=aaa+bbb,Shangx+=bbb
- Set /A xxx+=aaa/^(aaa*aaa^)
- )
- If %xxx% GTR 0 Set /A Fen=Fen-(xxx-1)*10
- If %Fen% LEQ %Shangx% (
- Set _Label=%~2
- If !Fen! GTR 21 Set /A Fen-=10
- ) Else (
- Set _Label=Overflow
- Set _Lose=%~2
- If !Shangx! GTR 21 Set /A Fen-=10)
- Set %~1Fen=%Fen%
- Goto :eof
-
- :Screen
- ::%1=A(B) %2=DianShu %3=HuaSe
- Set %~11=!%~11!┏━━┓
- Set %~12=!%~12!┃%~2 ┃
- Set %~13=!%~13!┃ ┃
- Set %~14=!%~14!┃ %~3┃
- Set %~15=!%~15!┗━━┛
- Goto :eof
-
- :Back
- Set %~11=!%~11!┏━━┓
- Set %~12=!%~12!┃++++┃
- Set %~13=!%~13!┃++++┃
- Set %~14=!%~14!┃++++┃
- Set %~15=!%~15!┗━━┛
- Goto :eof
-
- :Output
- CLS
- CALL :Show 5 A
- CALL :Show 9
- ECHO.%_XFen%/%Total%
- CALL :Show 5 B
- CALL :Show 2
- Goto :eof
-
- :Show
- For /L %%i in (1,1,%~1) DO ECHO.!%~2%%i!
- Goto :eof
-
- :Overflow
- If *%_Lose% == *SelectC (
- Set _Lose=闲) Else (Set _Lose=庄)
- Goto Pri
-
- :End
- If %ComputerFen% GEQ %PlayersFen% (
- Set _Lose=庄) Else (Set _Lose=闲)
- Goto Pri
- :Pri
- Set /A CountC+=Count
- For /L %%i in (1,1,5) DO Set "A%%i="
- For /L %%i in (1,1,%CountC%) DO CALL :Screen "A" "!_xComputer%%i:~0,2!" "!_xComputer%%i:~-1!"
- CALL :Output
- ECHO %_Lose%赢
- For /F "tokens=1,2" %%i in (ll.txt) DO Set /a %%i,%%j
- If *%_Lose% == *庄 (
- Set /A A+=1) Else (
- Set /A B+=1)
- ECHO A=%A% B=%B% >ll.txt
- PAUSE>nul
- ENDLOCAL
-
- Goto :Init
复制代码
|