[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

批处理象棋人机对战

原创区发不了,发在这儿算是转载自己的新版本:17.7.7.2

原版本(不能人机)地址:http://www.bathome.net/thread-44656-1-1.html

中国象棋,支持和电脑对弈,不过IQ很低,不知道怎么搞的

也许是命令不恰当吧

使用了象棋引擎精灵,引擎使用参照了happy886rr
主程序源码:
  1. @echo off&setlocal enabledelayedexpansion&mode 90,33&title 批处理版象棋&color 76
  2. :Restart
  3. call :Module_StartWith
  4. :loop_1
  5. color 76
  6. title 批处理版象棋 - 请选棋
  7. call :Module_Echo
  8. set "msg_4=[信息]"
  9. call :Cmos loop_1 X Y
  10. call :Check_1
  11. :loop_2
  12. color 7e
  13. title 批处理版象棋 - 请走棋
  14. call :Cmos loop_2 New_X New_Y
  15. call :Check_2
  16. if "!P_ID_%New_X%_%New_Y%!" equ "j" (msg * 你输了,加油! 点击鼠标继续
  17. color c0&cmos c f&goto :Restart)
  18. set /a Undo_Num+=1
  19. set "Undo_!Undo_Num!=P_ID_!X!_!Y!=!P_ID_%X%_%Y%! P_ID_!New_X!_!New_Y!=!P_ID_%New_X%_%New_Y%!"
  20. set "P_ID_!New_X!_!New_Y!=!P_ID_%X%_%Y%!"&set "P_ID_!X!_!Y!=#"
  21. set now=c
  22. goto :Think
  23. :Module_StartWith
  24. set  "line_0=                           "
  25. set  "line_1= ┏━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┓ "
  26. set  "line_2= ┃  ┃  ┃  ┃╲ ┃ ╱┃  ┃  ┃  ┃ "
  27. set  "line_3= ┃  ┃  ┃  ┃ ╲┃╱ ┃  ┃  ┃  ┃ "
  28. set  "line_4= ┣━━╋━━╋━━╋━━╋━━╋━━╋━━╋━━┫ "
  29. set  "line_5= ┃  ┃  ┃  ┃ ╱┃╲ ┃  ┃  ┃  ┃ "
  30. set  "line_6= ┃  ┃  ┃  ┃╱ ┃ ╲┃  ┃  ┃  ┃ "
  31. set  "line_7= ┣━━╬━━╋━━╋━━╋━━╋━━╋━━╬━━┫ "
  32. set  "line_8= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  33. set  "line_9= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  34. set "line_10= ╠━━╋━━╬━━╋━━╬━━╋━━╬━━╋━━╣ "
  35. set "line_11= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  36. set "line_12= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  37. set "line_13= ┣━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┫ "
  38. set "line_14= ┃                       ┃ "
  39. set "line_15= ┃                       ┃ "
  40. set "line_16= ┣━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┫ "
  41. set "line_17= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  42. set "line_18= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  43. set "line_19= ╠━━╋━━╬━━╋━━╬━━╋━━╬━━╋━━╣ "
  44. set "line_20= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  45. set "line_21= ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃ "
  46. set "line_22= ┣━━╬━━╋━━╋━━╋━━╋━━╋━━╬━━┫ "
  47. set "line_23= ┃  ┃  ┃  ┃╲ ┃ ╱┃  ┃  ┃  ┃ "
  48. set "line_24= ┃  ┃  ┃  ┃ ╲┃╱ ┃  ┃  ┃  ┃ "
  49. set "line_25= ┣━━╋━━╋━━╋━━╋━━╋━━╋━━╋━━┫ "
  50. set "line_26= ┃  ┃  ┃  ┃ ╱┃╲ ┃  ┃  ┃  ┃ "
  51. set "line_27= ┃  ┃  ┃  ┃╱ ┃ ╲┃  ┃  ┃  ┃ "
  52. set "line_28= ┗━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┛ "
  53. set "line_29=                           "
  54. for /l %%# in (1,1,10) do set "msg_%%#= "
  55. set now=j&set Undo_Num=0
  56. set "str=卒炮将士象马车兵炮帅仕相马车"&set "var=abcdefghijklmn"
  57. for %%# in (#@1 a@P b@C c@K d@A e@B f@N g@R h@p i@c j@k k@a l@b m@n m@r) do set t=%%#&set Fen_!t:@==!
  58. for /l %%# in (0,1,13) do set E_!var:~%%#,1!=!str:~%%#,1!
  59. for /l %%$ in (1,1,10) do for /l %%# in (1,1,9) do set P_ID_%%$_%%#=#
  60. for %%# in (1_1@g 1_2@f 1_3@e 1_4@d 1_5@c 1_6@d 1_7@e 1_8@f 1_9@g 10_1@n 10_2@m 10_3@l 10_4@k 10_5@j 10_6@k 10_7@l 10_8@m 10_9@n 3_2@b 3_8@b 8_2@i 8_8@i 4_1@a 4_3@a 4_5@a 4_7@a 4_9@a 7_1@h 7_3@h 7_5@h 7_7@h 7_9@h) do (set "t=%%#"&set "P_ID_!t:@==!")
  61. set "msg_1=批处理版象棋,由a2002编写完成,第三方cmos,引擎使用参照Happy886rr"
  62. set "msg_2=  ┏━┓┏━┓┏━┓      ┃悔┃┃重┃┃退┃      ┗━┛┗━┛┗━┛    "
  63. set "msg_4=[信息]"&set "c=h i j k l m n"&set "j=a b c d e f g"
  64. goto :eof
  65. :Module_Set
  66. for /l %%$ in (1,1,10) do for /l %%# in (1,1,9) do (
  67. if "!P_ID_%%$_%%#!" equ "#" (
  68. set /a t1=%%$*3-3,t2=t1+1,t3=t2+1,t4=%%#*3-3
  69. for /f "tokens=1-6 delims= " %%a in ("%%$ %%# !t1! !t2! !t3! !t4!") do set "P_Top_%%a_%%b=!line_%%c:~%%f,3!"&set "P_Between_%%a_%%b=!line_%%d:~%%f,3!"&set "P_Bottom_%%a_%%b=!line_%%e:~%%f,3!")
  70. for %%a in (a b c d e f g) do if "!P_ID_%%$_%%#!" equ "%%a" set "P_Top_%%$_%%#=┌─┐"&set "P_Between_%%$_%%#=│!E_%%a!│"&set "P_Bottom_%%$_%%#=└─┘"
  71. for %%a in (h i j k l m n) do if "!P_ID_%%$_%%#!" equ "%%a" set "P_Top_%%$_%%#=╔═╗"&set "P_Between_%%$_%%#=║!E_%%a!║"&set "P_Bottom_%%$_%%#=╚═╝")
  72. goto :eof
  73. :Module_Echo
  74. call :Module_Set
  75. set "msg_3=走棋方:!E_%now%!"
  76. cls
  77. echo ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  78. for /l %%# in (1,1,10) do (
  79. echo ┃!P_Top_%%#_1!!P_Top_%%#_2!!P_Top_%%#_3!!P_Top_%%#_4!!P_Top_%%#_5!!P_Top_%%#_6!!P_Top_%%#_7!!P_Top_%%#_8!!P_Top_%%#_9!┃!msg_%%#:~0,15!
  80. echo ┃!P_Between_%%#_1!!P_Between_%%#_2!!P_Between_%%#_3!!P_Between_%%#_4!!P_Between_%%#_5!!P_Between_%%#_6!!P_Between_%%#_7!!P_Between_%%#_8!!P_Between_%%#_9!┃!msg_%%#:~15,15!
  81. echo ┃!P_Bottom_%%#_1!!P_Bottom_%%#_2!!P_Bottom_%%#_3!!P_Bottom_%%#_4!!P_Bottom_%%#_5!!P_Bottom_%%#_6!!P_Bottom_%%#_7!!P_Bottom_%%#_8!!P_Bottom_%%#_9!┃!msg_%%#:~30,15!)
  82. echo ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
  83. goto :eof
  84. :Check_1
  85. if "!P_ID_%X%_%Y%!" equ "#" set "msg_4=棋不能为空!!!"&goto :loop_1
  86. for %%# in (!%now%!) do if "!P_ID_%X%_%Y%!" equ "%%#" set "msg_4=请拿自己的棋!!!"&goto :loop_1
  87. goto :eof
  88. :Check_2
  89. set t=0
  90. set F_c=!j!&set F_j=!c!
  91. for %%# in (!F_%now%!) do if "!P_ID_%New_X%_%New_Y%!" equ "%%#" set "msg_4=非法走棋!!!"&goto :loop_1
  92. call :CalcA
  93. if "!P_ID_%X%_%Y%!" equ "a" (if !X! leq 5 (if !Return! equ -1 goto :eof) else (for %%# in (-1 200 -200) do if !Return! equ %%# goto :eof))
  94. if "!P_ID_%X%_%Y%!" equ "h" (if !X! geq 6 (if !Return! equ 1 goto :eof) else (for %%# in (1 200 -200) do if !Return! equ %%# goto :eof))
  95. for %%# in (b i) do (if "!P_ID_%X%_%Y%!" equ "%%#" (if "!P_ID_%New_X%_%New_Y%!" equ "#" (
  96. if !Return! lss 200 if !Return! gtr 0 (call :CalcB 4&if !CalcB_Return! equ 1 goto :eof)
  97. if !Return! lss 0 if !Return! gtr -200 (call :CalcB 2&if !CalcB_Return! equ 1 goto :eof)
  98. if "!Return:~-2!" equ "00" if !Return! gtr 0 (call :CalcB 3&if !CalcB_Return! equ 1 goto :eof)
  99. if "!Return:~-2!" equ "00" if !Return! lss 0 (call :CalcB 1&if !CalcB_Return! equ 1 goto :eof)
  100. ) else (
  101. if !Return! lss 200 if !Return! gtr 0 (call :CalcB 4&if !CalcB_Return! equ 3 goto :eof)
  102. if !Return! lss 0 if !Return! gtr -200 (call :CalcB 2&if !CalcB_Return! equ 3 goto :eof)
  103. if "!Return:~-2!" equ "00" if !Return! gtr 0 (call :CalcB 3&if !CalcB_Return! equ 3 goto :eof)
  104. if "!Return:~-2!" equ "00" if !Return! lss 0 (call :CalcB 1&if !CalcB_Return! equ 3 goto :eof))))
  105. if "!P_ID_%X%_%Y%!" equ "c" (if !New_X! geq 1 if !New_X! leq 3 if !New_Y! geq 4 if !New_Y! leq 6 (for %%# in (1 -1 200 -200) do if !Return! equ %%# goto :eof)
  106. if "!P_ID_%New_X%_%New_Y%!" equ "j" (call :CalcB 2&if !CalcB_Return! equ 2 goto :eof))
  107. if "!P_ID_%X%_%Y%!" equ "j" (if !New_X! geq 8 if !New_X! leq 10 if !New_Y! geq 4 if !New_Y! leq 6 (for %%# in (1 -1 200 -200) do if !Return! equ %%# goto :eof)
  108. if "!P_ID_%New_X%_%New_Y%!" equ "c" (call :CalcB 4&if !CalcB_Return! equ 2 goto :eof))
  109. if "!P_ID_%X%_%Y%!" equ "d" (if !New_X! geq 1 if !New_X! leq 3 if !New_Y! geq 4 if !New_Y! leq 6 (
  110. for %%# in (201 199 -199 -201) do if !Return! equ %%# goto :eof))
  111. if "!P_ID_%X%_%Y%!" equ "k" (if !New_X! geq 8 if !New_X! leq 10 if !New_Y! geq 4 if !New_Y! leq 6 (
  112. for %%# in (201 199 -199 -201) do if !Return! equ %%# goto :eof))
  113. if "!P_ID_%X%_%Y%!" equ "e" (if !New_X! leq 5 (
  114. if !Return! equ 402 (set /a t1=X-1,t2=Y-1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  115. if !Return! equ 398 (set /a t1=X+1,t2=Y-1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  116. if !Return! equ -398 (set /a t1=X-1,t2=Y+1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  117. if !Return! equ -402 (set /a t1=X+1,t2=Y+1&call :Command_1 !t1! !t2!&if defined t goto :eof)))
  118. if "!P_ID_%X%_%Y%!" equ "l" (if !New_X! geq 6 (
  119. if !Return! equ 402 (set /a t1=X-1,t2=Y-1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  120. if !Return! equ 398 (set /a t1=X+1,t2=Y-1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  121. if !Return! equ -398 (set /a t1=X-1,t2=Y+1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  122. if !Return! equ -402 (set /a t1=X+1,t2=Y+1&call :Command_1 !t1! !t2!&if defined t goto :eof)))
  123. for %%# in (f m) do (if "!P_ID_%X%_%Y%!" equ "%%#" (
  124. for %%$ in (202 -198) do if !Return! equ %%$ (set /a t1=X-1,t2=Y&call :Command_1 !t1! !t2!&if defined t goto :eof)
  125. for %%$ in (401 399) do if !Return! equ %%$ (set /a t1=X,t2=Y-1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  126. for %%$ in (-401 -399) do if !Return! equ %%$ (set /a t1=X,t2=Y+1&call :Command_1 !t1! !t2!&if defined t goto :eof)
  127. for %%$ in (198 -202) do if !Return! equ %%$ (set /a t1=X+1,t2=Y&call :Command_1 !t1! !t2!&if defined t goto :eof)))
  128. for %%# in (g n) do (if "!P_ID_%X%_%Y%!" equ "%%#" (if "!P_ID_%New_X%_%New_Y%!" equ "#" (
  129. if !Return! lss 200 if !Return! gtr 0 (call :CalcB 4&if !CalcB_Return! equ 1 goto :eof)
  130. if !Return! lss 0 if !Return! gtr -200 (call :CalcB 2&if !CalcB_Return! equ 1 goto :eof)
  131. if "!Return:~-2!" equ "00" if !Return! gtr 0 (call :CalcB 3&if !CalcB_Return! equ 1 goto :eof)
  132. if "!Return:~-2!" equ "00" if !Return! lss 0 (call :CalcB 1&if !CalcB_Return! equ 1 goto :eof)
  133. ) else (
  134. if !Return! lss 200 if !Return! gtr 0 (call :CalcB 4&if !CalcB_Return! equ 2 goto :eof)
  135. if !Return! lss 0 if !Return! gtr -200 (call :CalcB 2&if !CalcB_Return! equ 2 goto :eof)
  136. if "!Return:~-2!" equ "00" if !Return! gtr 0 (call :CalcB 3&if !CalcB_Return! equ 2 goto :eof)
  137. if "!Return:~-2!" equ "00" if !Return! lss 0 (call :CalcB 1&if !CalcB_Return! equ 2 goto :eof))))
  138. set "msg_4=非法走棋!!!"&goto :loop_1
  139. :Think
  140. color 76
  141. title 批处理版象棋 - 电脑思考中,请稍后...
  142. set "msg_4=电脑思考中,请稍后..."
  143. call :Module_Echo
  144. set "msg_4=[信息]"&set put=&set Fen=
  145. for /l %%# in (10,-1,1) do (
  146. set "Fen=!Fen!/"
  147. for /l %%$ in (1,1,9) do (
  148. set "t=!P_ID_%%#_%%$!"
  149. for %%@ in (!t!) do set Fen=!Fen!!Fen_%%@!))
  150. set Fen=!Fen:~1!
  151. for /f "tokens=1,2 delims= " %%a in ('CallUCCI.bat !Fen! w - - 0 !Undo_Num!') do if "%%a" equ "bestmove" set put=%%b
  152. if not defined put msg * 这盘算我输,单击鼠标再来一盘&color c0&cmos c f&goto :Restart
  153. set put=!put:a=1!&set put=!put:b=2!&set put=!put:c=3!&set put=!put:d=4!&set put=!put:e=5!&set put=!put:f=6!&set put=!put:g=7!&set put=!put:h=8!&set put=!put:i=9!
  154. set /a t1=!put:~0,1!,t2=!put:~1,1!+1,t3=!put:~2,1!,t4=!put:~3,1!+1
  155. set /a Undo_Num+=1
  156. set "Undo_!Undo_Num!=P_ID_!t2!_!t1!=!P_ID_%t2%_%t1%! P_ID_!t4!_!t3!=!P_ID_%t4%_%t3%!"
  157. if "!P_ID_%t4%_%t3!" equ "c" (msg * 我输了,IQ太低,点击鼠标继续
  158. color c0&cmos c f&goto :Restart)
  159. set P_ID_!t4!_!t3!=!P_ID_%t2%_%t1%!&set P_ID_!t2!_!t1!=#
  160. set now=j&goto :loop_1
  161. :CalcA
  162. set /a t1=X-New_X,t2=(Y-New_Y)*200
  163. set /a Return=t1+t2
  164. goto :eof
  165. :CalcB
  166. set CalcB_Return=0
  167. if "%~1" equ "1" for /l %%# in (!Y!,1,!New_Y!) do if "!P_ID_%X%_%%#!" neq "#" set /a CalcB_Return+=1
  168. if "%~1" equ "2" for /l %%# in (!X!,1,!New_X!) do if "!P_ID_%%#_%Y%!" neq "#" set /a CalcB_Return+=1
  169. if "%~1" equ "3" for /l %%# in (!New_Y!,1,!Y!) do if "!P_ID_%X%_%%#!" neq "#" set /a CalcB_Return+=1
  170. if "%~1" equ "4" for /l %%# in (!New_X!,1,!X!) do if "!P_ID_%%#_%Y%!" neq "#" set /a CalcB_Return+=1
  171. goto :eof
  172. :Cmos
  173. cmos c f
  174. set /a t1=!errorlevel!-1001
  175. if !errorlevel:~-3! equ 001 goto :%~1
  176. if !t1! leq 2000 goto :%~1
  177. set t2=!t1:~0,-3!
  178. set /a %~3=(t2-1)/6+1,%~2=(t1-t2*1000-1)/3+1
  179. if "!%~2!_!%~3!" equ "2_11" goto :Undo
  180. if "!%~2!_!%~3!" equ "2_12" goto :Restart
  181. if "!%~2!_!%~3!" equ "2_13" exit
  182. if !%~2! gtr 10 goto :%~1
  183. if !%~2! lss 1 goto :%~1
  184. if !%~3! gtr 9 goto :%~1
  185. if !%~3! lss 1 goto :%~1
  186. goto :eof
  187. :Undo
  188. if !Undo_Num! lss 2 set "msg_4=没有可悔的棋!!!"&goto :loop_1
  189. set /a t1=Undo_Num,t2=t1-1,Undo_Num-=2
  190. for /f "tokens=1,2 delims= " %%a in ("!Undo_%t1%!") do set "%%a"&set "%%b"
  191. for /f "tokens=1,2 delims= " %%a in ("!Undo_%t2%!") do set "%%a"&set "%%b"
  192. goto :loop_1
  193. :Command_1
  194. set t=&if "!P_ID_%~1_%~2!" equ "#" set t=1
  195. goto :eof
复制代码
原版下载:
把下面图片保存,改后缀为.7z,解压即是


新版:
http://pan.baidu.com/s/1i521Y65
附件: 您需要登录才可以下载或查看附件。没有帐号?注册
3

评分人数

COMS怎么调兼容?XP2002,32一直闪,点击无效

TOP

回复 13# happy886rr


    也不一定写得出来

TOP

回复 12# a2002
要不你自己开发个引擎吧,不过好难的,不是一周能写出厉害引擎的。

TOP

那我不知道了,应该不是引擎问题

TOP

人人对战可以运行

TOP

我也很无奈,批处理好多第三方64位用不了,我才装了32位的

TOP

cmos不兼容,调一调兼容性试试

TOP

回复 7# a2002


    屏幕闪烁,点击无反应

TOP

回复 5# 老刘1号


    现象是什么

TOP

回复 5# 老刘1号


    是哪个三方用不了?

TOP

xp sp2 x64
测试失败

TOP

我换过,感觉差不多

TOP

回复 2# a2002
你没带棋谱吗?'这个网站很多引擎,换其他的试试。
http://www.xqbase.com/league/enginelist.htm

TOP

改了下go depth,不过IQ还不是很高

TOP

返回列表