标题: [游戏娱乐] 批处理扑克游戏:梭哈-人机对战 [打印本页]
作者: wankoilz 时间: 2011-6-14 19:41 标题: 批处理扑克游戏:梭哈-人机对战
如果对梭哈有了解,输入名字就可以直接开始了,不熟悉梭哈的兄弟玩之前先看看规则。
这个游戏和真正梭哈唯一不同之处在于花色不分大小,所以存在牌面相等的情况。
话不多说,赶紧来赌博吧... ...- ::Code By wankoilz 2011/6/11 @win7 QQ:375913828
- ::From bbs.bathome.net 批处理之家
- @echo off&setlocal enabledelayedexpansion
- mode con lines=34 cols=42&title 梭哈-人机对战 by wankoilz&color 8e
-
- echo 行赌生涯,梭哈-人机对战 规则说明:
- echo ┏━━━━━━━━━━━━━━━━━━┓
- echo ┃总共发五张牌。第一轮发底牌,不下注。┃
- echo ┃而后每发一张牌进行一轮下注,共四轮。┃
- echo ┃在任何一轮中你可以下注,也可以弃牌。┃
- echo ┃四轮下注完毕后所有人亮底牌比大小,牌┃
- echo ┃面大者胜(如果有相同的则平分赌注)。┃
- echo ┃ ┃
- echo ┃下注规则: ┃
- echo ┃每轮按照牌面大小顺序下注。 ┃
- echo ┃上次下注数额 ^<=下注数额^<= 任何玩家所┃
- echo ┃剩最小资金。否则视为非法。 ┃
- echo ┃ ┃
- echo ┃ShowHand规则: ┃
- echo ┃当桌面上有人剩余资金不够跟注时,玩家┃
- echo ┃可以选择以那人剩余资金为标准下注,此┃
- echo ┃为ShowHand。此时其他人可以选择跟注,┃
- echo ┃直接发完5张牌,比大小。 ┃
- echo ┃ ┃
- echo ┃牌面大小规则: ┃
- echo ┃同花顺^>四条^>葫芦(三条+一对)^>同花^> ┃
- echo ┃连顺^>三条^>两对^>一对^>单牌 ┃
- echo ┃A^>K^>Q^>J^>10...^>2, A2345 视为连顺 ┃
- echo ┃◇◆○●代表四种花色,花色不分大小 ┃
- echo ┣━━━━━━━━━━━━━━━━━━┫
- echo ┃总之,玩了就知道了,你懂的....电脑绝┃
- echo ┃不是吃干饭的,你试试认认真真和电脑玩┃
- echo ┃几把就知道厉害了,嘿嘿... ┃
- echo ┃ ┃
- echo ┃准备开始你的行赌生涯吧... ┃
- echo ┗━━━━━━━━━━━━━━━━━━┛
- set "dj=同花顺_17 四条_11 葫芦_10 同花_9 连顺_8 三条_7 两对_6 一对_3 单牌_0"
- for %%i in (%dj%) do for /f "delims=_ tokens=1-2" %%j in ("%%i") do set _%%k=%%j
- set bdfs_1=53550&set bdfs_2=3570&set bdfs_3=238&set bdfs_4=15&set bdfs_5=1
- set/p zj=请输入你的名字:&set zs=张三&set ls=李四
- set names=zj zs ls
- set zj_dz=10000&set zs_dz=10000&set ls_dz=10000
- set @=◇&set #=◆&set $=○&set [=●&set hs=@#$[
- for /l %%i in (2,1,9) do for %%j in (@ # $ [) do set %%j0%%i=!%%j!%%i
- for %%i in (11J,12Q,13K,14A) do for %%j in (@ # $ [) do (set tmp=%%i&set %%j!tmp:~,-1!=!%%j!!tmp:~-1!)
- for %%i in (@ # $ [) do set %%i10=!%%i!10
- set tmp=
- set h1=┏━━┓
- set h2=┃ @@┃
- set h3=┃ ┃
- set h4=┃ ┃
- set h5=┗━━┛
- set "xs=(for /l %%i in (1,1,5) do ((for %%j in ($) do (set "t=%%j "^&set t=^!t:~,3^!^&for %%k in ("^^!t^^!") do set tmp=^!h%%i: @@=%%~k^!^&set/p=^!tmp^!^<nul))^&echo;))"
-
- :main
- cls&echo 等待洗牌...
- setlocal&set dc=0&set t_names=%names%&set min_xz=1
- for %%i in (%names%) do (
- call :fp&set %%i_pkbl=!pkbl!
- call :pd "!%%i_pkbl!" "%%i"
- for %%j in (!pk!) do set "t=%%j "&set t=!t:~,3!&set %%i_pk=!%%i_pk!!t!
- set %%i_tpk1=◎@@◎@@◎@@◎@@
- set c=0&for /l %%j in (0,3,12) do set/a c+=1&set "dp_!c!=!%%i_pk:~%%j,3!"
- set c=0&for %%j in (!%%i_sz!) do set/a c+=1&set dp_sz_!c!=%%j
- for /l %%j in (1,1,5) do (
- set/a ran_jh=!random!%%5+1
- for %%k in (!ran_jh!) do (
- set "t=!dp_%%j!"&set "dp_%%j=!dp_%%k!"&set "dp_%%k=!t!"
- set t=!dp_sz_%%j!&set dp_sz_%%j=!dp_sz_%%k!&set dp_sz_%%k=!t!
- ))
- for /l %%j in (1,1,5) do set "%%i_pk_lx=!%%i_pk_lx!!dp_%%j!"&set %%i_sz_lx=!%%i_sz_lx! !dp_sz_%%j!
- set %%i_tpk2=!%%i_pk_lx:~0,12!&set set "%%i_dp=!%%i_pk_lx:~12,3!"
- for %%j in (!%%i_sz_lx!) do set "t=%%j "&set t=!t:~,3!&set %%i_pmbd=!%%i_pmbd!!t!
- set %%i_pmbd=@@@!%%i_pmbd:~,12!
- )
- cls
- for /l %%i in (0,3,12) do (
- set names_ph=&set max_pm_name=
- set max_xz=30000&for %%i in (!t_names!) do if !%%i_dz! lss !max_xz! set max_xz=!%%i_dz!&set max_xz_name=%%i
- set/a hh+=1,hh_xz=hh-1
- if %%i equ 0 call :xs %%i&echo;&pause
- if %%i gtr 0 (
- if !min_xz! geq !max_xz! set S_H=ok
- call :pmbd %%i
- for %%j in (!names_ph!) do (
- cls&call :xs %%i %%j
- call :xz %%j
- set/a %%j_dz-=%%j_xz,dc+=%%j_xz
- if !%%j_xz! gtr !min_xz! set min_xz=!%%j_xz!
- echo !xz_echo!
- if "!%%j_xz!"=="!max_xz!" set S_H=ok
- echo;&pause
- set "tz_pd=!t_names: =!"&if "!tz_pd:~2!"=="" goto :zjsl
- )
- if defined S_H goto :zjsl
- ))
-
- :zjsl
- cls
- if defined S_H if not "!tz_pd:~2!"=="" echo 本轮ShowHand!
- if not "!tz_pd:~2!"=="" (
- echo 下注完毕,所有人亮牌:&echo;
- ) else (
- echo 除!%t_names: =%!外,其他人弃牌&echo;
- )
- if not "!tz_pd:~2!"=="" (
- for %%i in (%t_names%) do (
- echo !%%i! 剩余现金!%%i_dz!元
- set pkxs=&for /l %%j in (0,3,12) do set pkxs=!pkxs! !%%i_pk:~%%j,3!
- %xs:$=!pkxs!%
- for %%j in (!%%i_djfs!) do echo !_%%j!
- ))
-
- set winners=&set c_winners=&call :bd djfs sz
- for %%i in (%winners%) do set winners_name=!winners_name! !%%i!
- if not "!tz_pd:~2!"=="" echo;&echo !winners_name:~1!以 !winner_dj! 胜。
- set/a dc_winners=dc/c_winners 2>nul
- for %%i in (%winners%) do set/a %%i_dz+=dc_winners
- if "%c_winners%"=="1" (
- echo !winners_name:~1!收揽了桌上的%dc_winners%元
- ) else (
- echo !winners_name:~1!平分桌上的%dc_winners%元
- )
- if %zj_dz% leq 0 echo;&echo !zj! 已输得身无分文,行赌生涯到此为止了!&echo;&pause&exit
- for %%i in (%names:zj=%) do if !%%i_dz! leq 0 set names=!names:%%i=!&echo;&echo !%%i! 输得精光,被勒令退出赌场!
- for %%i in (%names%) do set/a c_names+=1
- if "%c_names%"=="1" pause&call :dsds
- endlocal&set zj_dz=%zj_dz%&set zs_dz=%zs_dz%&set ls_dz=%ls_dz%&set names=%names%
- echo;&pause&goto :main
-
-
- :fp ::::::::::::::::::::::::::::::::发牌:::::::::::::::::::::::::::::::
- set n=0&set pk=&set pkbl=
- :lp
- set/a rnd1=!random!%%4,rnd2=!random!%%13+2
- set rnd2=0!rnd2!&set rnd2=!rnd2:~-2!
- set tmp=!hs:~%rnd1%,1!!rnd2!
- if not defined __%tmp% set __%tmp%=ok&set ___%tmp%=ok&set/a n+=1
- if %n% lss 5 goto :lp
- for /f "delims=_=" %%i in ('set ___^|sort/+5') do set pk=!pk! !%%i!&set pkbl=!pkbl! %%i
- for /f "delims==" %%i in ('set ___') do set %%i=
- goto :eof
-
-
- :pd :::::::::::::::::::::牌面种类判断(同花顺?对子?等等):::::::::::::::::
- setlocal
- set c=0&set t=
- set pdzf=0123456789abcdefghi&set "s=%~1"&set djfs=0
- set "sz=!s!"&for %%i in (@0 #0 $0 [0 @ # $ [) do set sz=!sz:%%i=!
- for %%i in (%s%) do set t=%%i&set ta=!ta! !t:~,1!&set t=
- for %%i in (%sz%) do ((if "%%i"=="!L!" set/a c+=1&set t=!t! %%i)&set L=%%i)
- if !c! equ 3 if "!t:%t:~-1%=!"==" " (set/a djfs+=11) else (set/a djfs+=10)
- if !c! equ 2 (
- for /f "tokens=1-2" %%i in ("!t!") do (
- if %%i equ %%j (set/a djfs+=7) else (set/a djfs+=6)
- ))
-
- if !c! equ 1 set/a djfs+=3
- for %%i in ("%sz%" " 1%sz: 14=%") do (
- for %%j in (%%~i) do set t1=!t1!!pdzf:~%%j,1!
- set t=%%~i&set t=!t:~,3!
- for %%k in (!t!) do if "!pdzf:~%%k,5!"=="!t1!" set/a djfs+=8
- set t1=&set t2=%%~i
- )
- if %djfs% equ 8 if "%t2:~-1%"=="5" set sz=%t2%
- if "!ta:%ta:~-1%=!"==" " set/a djfs+=9
-
- endlocal&set %~2_djfs=%djfs%&set %~2_sz=%sz%&goto :eof
-
-
- :bd <djfs/pm_djfs> <sz/pm_sz>::::::::::::::::::牌面大小判断::::::::::::::::::::::::
- setlocal
- for %%i in (%t_names%) do set/a x+=1
- if !x! equ 1 endlocal&set winners=!t_names: =!&set c_winners=1&goto :eof
- for %%i in (%t_names%) do (
- for %%j in (!%%i_%2!) do set t=@%%j&set %%i_bdsz=!%%i_bdsz!!t:~-2!
- if !%%i_%1! equ 10 (
- for /f "delims=_ tokens=1-2" %%j in ("!%%i_bdsz:~2,2!_!%%i_bdsz:~4,2!") do (
- if "%%j"=="%%k" (set %%i_bdsz=!%%i_bdsz:~-2! %%j) else (set %%i_bdsz=%%j %%k)
- )))
- for %%i in (%t_names%) do (
- for %%j in (3 6 7 11) do (
- if !%%i_%1! equ %%j (
- set tmp=!%%i_bdsz!
- for /l %%k in (0,2,8) do (
- for %%l in ("!%%i_bdsz:~%%k,2!") do (
- if not "%%~l"=="" (
- if "%%~l"=="!L!" set tmp=!tmp:%%~l=!%%~l
- set L=%%~l
- )))
- set %%i_bdsz=!tmp!&set tmp=
- )))
-
- for %%i in (%t_names%) do (
- set c=0
- for /l %%j in (8,-2,0) do (
- if not "!%%i_bdsz:~%%j,2!"=="" (
- set t=!%%i_bdsz:~%%j,2!&set t=!t:@=!&set/a c+=1
- for %%k in (!c!) do set/a %%i_bdfs=!t!*!bdfs_%%k!+%%i_bdfs
- )))
- for %%i in (%t_names%) do (
- if !%%i_%1! geq !max! (set djfspx=!djfspx! %%i&set max=!%%i_djfs!
- ) else (set djfspx=%%i !djfspx!
- ))
-
- set max=&for %%i in (%t_names%) do if !%%i_%1! gtr !max! set winner=%%i&set max=!%%i_%1!
- set names_ph=!djfspx!
- for /f "tokens=1-3" %%i in ("!djfspx!") do (
- if "%%k"=="" (
- if !%%j_%1! equ !%%i_%1! (
- if !%%j_bdfs! gtr !%%i_bdfs! set winner=%%j&set names_ph=%%j %%i
- if !%%j_bdfs! lss !%%i_bdfs! set winner=%%i&set names_ph=%%i %%j
- if !%%j_bdfs! equ !%%i_bdfs! set winner=%%i %%j&set names_ph=%%j %%i
- ) else (
- if !%%j_%1! gtr !%%i_%1! set names_ph=%%j %%i
- if !%%j_%1! lss !%%i_%1! set names_ph=%%i %%j
- )
- ) else (
- if !%%i_%1! equ !%%j_%1! if !%%i_%1! neq !%%k_%1! (
- if !%%i_bdfs! gtr !%%j_bdfs! set names_ph=%%k %%i %%j
- if !%%i_bdfs! lss !%%j_bdfs! set names_ph=%%k %%j %%i
- if !%%j_bdfs! equ !%%k_bdfs! set names_ph=%%k %%i %%j
- )
- if !%%j_%1! equ !%%k_%1! if !%%j_%1! neq !%%i_%1! (
- if !%%j_bdfs! gtr !%%k_bdfs! set winner=%%j&set names_ph=%%j %%k %%i
- if !%%j_bdfs! lss !%%k_bdfs! set winner=%%k&set names_ph=%%k %%j %%i
- if !%%j_bdfs! equ !%%k_bdfs! set winner=%%j %%k&set names_ph=%%j %%k %%i
- )
- if !%%j_%1! equ !%%k_%1! if !%%j_%1! equ !%%i_%1! (
- if !%%j_bdfs! gtr !%%k_bdfs! set winner=%%j&set bigger=!%%j_bdfs!
- if !%%j_bdfs! lss !%%k_bdfs! set winner=%%k&set bigger=!%%k_bdfs!
- if !%%i_bdfs! gtr !bigger! set winner=%%i
- for %%m in (!winner!) do for /f "tokens=1-2" %%n in ("!t_names:%%m= !") do (
- if !%%n_bdfs! gtr !%%o_bdfs! (
- set names_ph=!winner! %%n %%o
- ) else (
- set names_ph=!winner! %%o %%n
- ))
- if !%%j_bdfs! equ !%%k_bdfs! if !%%j_bdfs! gtr !%%i_bdfs! set winner=%%j %%k
- if !%%j_bdfs! equ !%%i_bdfs! if !%%j_bdfs! gtr !%%k_bdfs! set winner=%%j %%i
- if !%%i_bdfs! equ !%%k_bdfs! if !%%i_bdfs! gtr !%%j_bdfs! set winner=%%i %%k
- if !%%j_bdfs! equ !%%k_bdfs! if !%%j_bdfs! equ !%%i_bdfs! set winner=%%i %%j %%k
- )))
- for %%i in (%winner%) do (
- for %%j in (!%%i_djfs!) do set winner_dj=!_%%j!
- set winners=!winners! %%i
- for %%j in (!%%i_%1!) do set d=!_%%j!
- set/a c_winners+=1
- )
- endlocal&set winners=%winners%&set winner_dj=%winner_dj%&set c_winners=%c_winners%&set names_ph=%names_ph%&set max_pm_name=%names_ph:~,2%&goto :eof
-
-
- :xz ::::::::::::::::::::::::下注:::::::::::::::::::::::::::::::
- if "%1"=="zj" (
- if defined S_H (
- if "!max_pm_name!"=="zj" (
- echo !%max_xz_name%!剩余资金不够跟注,你是否 ShowHand?
- set/p zj_xz=输入【s】ShowHand,【q】弃牌:
- if "!zj_xz!"=="s" (
- set zj_xz=!max_xz!&set xz_echo= !zj!下注!zj_xz!元 叫ShowHand
- ) else (
- if "!zj_xz!"=="q" (
- set t_names=!t_names:zj=!&set zj_xz=0&set xz_echo= !zj!弃牌
- ) else (
- echo 非法输入!&pause>nul&goto :xz))
- ) else (
- echo 有人ShowHand,是否跟注?
- set/p zj_xz=输入【s】跟注ShowHand,【q】弃牌:
- if "!zj_xz!"=="s" (
- set zj_xz=!max_xz!&set xz_echo= !zj!跟注!zj_xz!元 ShowHand
- ) else (
- if "!zj_xz!"=="q" (
- set t_names=!t_names:zj=!&set zj_xz=0&set xz_echo= !zj!弃牌
- ) else (
- echo 非法输入!&pause>nul&goto :xz))
- )
- ) else (
- echo 你本轮下注最少!min_xz!元,最多!max_xz!元&echo;
- set/p zj_xz=请输入金额【输入q弃牌】:
- if "!zj_xz!"=="q" (
- set t_names=!t_names:zj=!&set zj_xz=0&set xz_echo= !zj!弃牌
- ) else (
- for /l %%i in (!min_xz!,1,!max_xz!) do if "%%i"=="!zj_xz!" set hf=ok
- if defined hf (
- set hf=
- if "!zj_xz!"=="!max_xz!" (
- set xz_echo= !zj!下注!zj_xz!元,叫ShowHand
- ) else (set xz_echo= !zj!下注!zj_xz!元)
- ) else (
- echo 非法输入!&pause>nul&goto :xz))
- )
- ) else (
- if defined S_H (
- set/a ran_xzpd=^(!random!%%10000^)+^(^(!%1_djfs!+1^)/2*800^)-!zj_djfs!*200-!max_xz!/2
- if !ran_xzpd! geq 2100 (
- set %1_xz=!max_xz!&set xz_echo= !%1!下注!%1_xz!元 叫ShowHand
- ) else (set t_names=!t_names:%1=!&set %1_xz=0&set xz_echo= !%1!弃牌)
- ) else (
- set/a ran_xzpd=^(!random!%%10000^)+^(^(!%1_djfs!+1^)/2*800^)-!zj_djfs!*70-!min_xz!/10
- set/a ran_xz=^(!random!%%50+50^)*^(!%1_djfs!+1^)+!min_xz!
- if !ran_xz! geq !max_xz! (
- set/a ran_xz=!max_xz!-1
- ) else (
- if "!hh!"=="5" if not "!max_pm_name!"=="%1" set ran_xz=!min_xz!
- )
- if !ran_xzpd! leq 1900 set t_names=!t_names:%1=!&set %1_xz=0&set xz_echo= !%1!弃牌
- if !ran_xzpd! gtr 1900 if !ran_xzpd! leq 7900 if !min_xz! lss 3500 (
- set %1_xz=!min_xz!&set xz_echo= !%1!下注!min_xz!元
- ) else (set t_names=!t_names:%1=!&set %1_xz=0&set xz_echo= !%1!弃牌)
- if !ran_xzpd! gtr 7900 set %1_xz=!ran_xz!&set xz_echo= !%1!下注!ran_xz!元
- ))
- goto :eof
-
-
- :xs ::::::::::::::::::::::::::::扑克显示:::::::::::::::::::::::::
- if %1 equ 0 (echo 发第!hh!张牌:底牌&echo;) else (echo 发第!hh!张牌,进行第!hh_xz!轮下注&echo;)
- for %%j in (!t_names!) do (
- set %%j_tpk_t=!%%j_tpk1:~%1!!%%j_tpk2:~,%1!底@@
- set %%j_pkxs=
- for /l %%k in (0,1,4) do (
- set/a x=%%k*3&for %%m in (!x!) do set %%j_pkxs=!%%j_pkxs! !%%j_tpk_t:~%%m,3!
- )
- set pkxs=!%%j_pkxs!
- echo !%%j! 剩余现金!%%j_dz!元
- %xs:$=!pkxs!%
- )
- echo;&echo 桌上赌注总共!dc!元&echo;
- if %1 equ 12 if "%2"=="zj" echo 最后一轮下注,下注后亮牌定胜负!&echo;
- if %1 gtr 0 if "%2"=="!max_pm_name!" echo !%max_pm_name%!牌面最大,!%max_pm_name%!先说话
- goto :eof
-
-
- :pmbd :::::::::::::::::::::::::获取每轮最大牌面玩家:::::::::::::::::::::::::
- for %%i in (!t_names!) do (
- set %%i_pm=!%%i_pmbd:~3,%1!
- set %%i_pm_px=
- set c=0&for %%j in (!%%i_pm!) do set/a c+=1&set t!c!=%%j
- for /l %%j in (1,1,!c!) do (
- for /l %%k in (1,1,!c!) do (
- if !t%%j! gtr !t%%k! set t=!t%%j!&set t%%j=!t%%k!&set t%%k=!t!
- ))
- for /l %%j in (1,1,!c!) do set %%i_pm_px=!t%%j! !%%i_pm_px!
- call :pd " !%%i_pm_px!" "%%i_pm"
- )
- call :bd pm_djfs pm_sz
- goto :eof
-
-
- :dsds :::::::::::::::::::::::::你赢了!:::::::::::::::::::::::::::::::::::
- cls
- for /l %%i in (1,1,8) do echo;
- set s1=张三李四技不如人,输得精光,一败涂地...
- set s2=!zj! 赌术非凡,独占鳌头,成为新一代赌神!
- set s3=很多年以后,民间还流传着 !zj! 的故事... ...
- for /l %%i in (1,1,3) do (
- for /l %%j in (0,1,30) do set/p=!s%%i:~%%j,1!<nul&ping/n 1 127.1>nul
- echo;&echo;&ping/n 2 127.1>nul
- )
- pause&exit
复制代码
作者: batman 时间: 2011-6-14 19:54
楼主莫不是赌王世家。。。
专门写赌博工具?
作者: wankoilz 时间: 2011-6-14 19:57
我是赌城老板...
作者: chenqldiy 时间: 2011-6-14 22:04
太有意思了,做成这样,不过开始发一个牌之前能不能显示没有牌,后面来1张就出现一张呢?
作者: wankoilz 时间: 2011-6-14 22:15
本帖最后由 wankoilz 于 2011-6-15 07:10 编辑
太有意思了,做成这样,不过开始发一个牌之前能不能显示没有牌,后面来1张就出现一张呢?
chenqldiy 发表于 2011-6-14 22:04
将就吧,把它当成空牌位就是了...
作者: web 时间: 2012-10-16 22:45
娱乐 解闷的东西
作者: 0123456789 时间: 2012-11-11 12:08
代码好复杂,看不懂。
作者: uxdhoh 时间: 2012-11-12 19:00
就是喜欢你的帖子 没办法
作者: xswl 时间: 2022-12-4 12:05
谁能把他对齐,强迫症
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |