我写了个象棋残局,请大家帮忙看下怎么样。。。需要第三方cmos.exe,在压缩包里。。。
双炮对孤王,中间有个炮只能横向移动,增加难度。。。- @echo off
- Setlocal Enabledelayedexpansion
- mode con:cols=36 lines=25
- color 71
- title Cyxgg's 象棋残局
- set p1=1
- set p2=1
- set rw=1
- set bw=1
- set rwh=2
- set rwl=16
- set bwh=20
- set bwl=20
- set p1h=18
- set p1l=24
- set p2h=16
- set p2l=8
- set nbw=将
- set nrw=帅
- set np1=炮
- set np2=炮
- set round=0
- if exist xqtmp (rd /s /q xqtmp)
- md xqtmp
- cd xqtmp
- call :start
- goto get1
-
- :start
- cls
- echo ╔═╦═╦═╦═╦═╦═╦═╦═╗
- echo ║ ┃ ┃ ┃╲┃╱┃ ┃ ┃ ║
- echo ╠━╋━╋━╋━╋━╋━╋━╋━╣
- echo ║ ┃ ┃ ┃╱┃╲┃ ┃ ┃ ║
- echo ╠━╋━╋━╋━╋━╋━╋━╋━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━╬━╋━╋━╋━╋━╋━╬━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━╋━╬━╋━╬━╋━╬━╋━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━┻━┻━┻━┻━┻━┻━┻━╣
- echo ║ 楚 河 汉 界 ║
- echo ╠━┳━┳━┳━┳━┳━┳━┳━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━╋━╬━╋━╬━╋━╬━╋━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━╬━╋━╋━╋━╋━╋━╬━╣
- echo ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ║
- echo ╠━╋━╋━╋━╋━╋━╋━╋━╣
- echo ║ ┃ ┃ ┃╲┃╱┃ ┃ ┃ ║
- echo ╠━╋━╋━╋━╋━╋━╋━╋━╣
- echo ║ ┃ ┃ ┃╱┃╲┃ ┃ ┃ ║
- echo ╚═╩═╩═╩═╩═╩═╩═╩═╝
- cmos 0 0 0 %rwl% %rwh%
- call :color 帅 fc
- if not %rwl%==32 echo.━
- cmos 0 0 0 %bwl% %bwh%
- call :color 将 f0
- if not %bwl%==32 echo.━
- if %p1%==1 (
- cmos 0 0 0 %p1l% %p1h%
- call :color 炮 f0
- if not %p1l%==32 echo.━
- )
- if %p2%==1 (
- cmos 0 0 0 %p2l% %p2h%
- call :color 炮 f0
- if not %p2l%==32 echo.━
- )
- goto :eof
-
- :get1
- cmos 0 -1 1
- set /a dj1=%errorlevel%
- set /a dja=%dj1:~0,-3%
- set /a djb=%dj1%-1000*%dja%
- if %dja% gtr 34 goto get1
- if %djb% gtr 23 goto get1
- set /a dje=(%dja%-1)%%4
- if %dje% gtr 1 goto get1
- set /a dje=%djb%%%2
- if %dje%==0 goto get1
- set /a djd=%djb%-1
- set /a djc=(%dja%-1)/2*2
- for %%i in (bw,p1,p2) do (
- if !%%i!==1 if !%%ih!==%djd% if !%%il!==%djc% set do=%%i&&goto get2
- )
- goto get1
-
- :get2
- cmos 0 1 1
- set /a dj2=%errorlevel%
- if %dj2% lss 0 if %round%==0 (
- cmos 0 0 0 %djc% %djd%
- set /p=# <nul
- if not !%do%l!==32 echo.━
- set round=1
- goto get2
- ) else (
- cmos 0 0 0 %djc% %djd%
- call :color !n%do%! f0
- if not !%do%l!==32 echo.━
- set round=0
- goto get2
- )
- set /a dja=%dj2:~0,-3%
- set /a djb=%dj2%-1000*%dja%
- if %dj2%==%dj1% goto get2
- if %dja% gtr 34 goto get2
- if %djb% gtr 23 goto get2
- set /a dje=(%dja%-1)%%4
- if %dje% gtr 1 goto get2
- set /a dje=%djb%%%2
- if %dje%==0 goto get2
- set /a djb-=1
- set /a dja=(%dja%-1)/2*2
- for %%i in (rw,bw,p1,p2) do if !%%i!==1 if !%%ih!==%djb% if !%%il!==%dja% (
- if %%i==rw goto get2
- set djc=%dja%&&set djd=%djb%&&set do=%%i
- cmos 0 0 0 %djc% %djd%
- call :color !n%do%! f0
- if not !%do%l!==32 echo.━
- goto get2
- )
- set back=0
- if !%do%l!==%dja% (call :doa) else (call :dob)
- if %back%==1 goto get2
- goto p%do%
-
- :doa
- for %%i in (bw,rw,p1,p2) do if %dja%==!%%il! (
- if !%do%h! lss !%%ih! if %djb% gtr !%%ih! set back=1
- if !%do%h! gtr !%%ih! if %djb% lss !%%ih! set back=1
- )
- goto :eof
-
- :dob
- for %%i in (bw,rw,p1,p2) do if %djb%==!%%ih! (
- if !%do%l! lss !%%il! if %dja% gtr !%%il! set back=1
- if !%do%l! gtr !%%il! if %dja% lss !%%il! set back=1
- )
- goto :eof
-
- :pbw
- if %dja% lss 11 goto get2
- if %dja% gtr 20 goto get2
- if %djb% lss 18 goto get2
- if %dja%==%bwl% (
- set /a dje=%djb%-%bwh%
- if "!dje:~-1,1!"=="4" goto get2
- set bwh=%djb%
- call :start
- goto cpu
- )
- if %djb%==%bwh% (
- call :pdbw %dja% %rwl% %p1l% %p2l% %djb% %rwh% %p1h% %p2h%
- if !back!==0 goto get2
- set /a dje=%dja%-%bwl%
- if "!dje:~-1,1!"=="8" goto get2
- set bwl=%dja%
- call :start
- goto cpu
- )
- goto get2
-
- :pp1
- if %dja%==%p1l% (
- call :msg 为了增加难度,此棋只能横向移动。 64 象棋残局
- goto get2
- )
- if %djb%==%p1h% (
- call :pdbw %bwl% %rwl% %dja% %p2l% %bwh% %rwh% %djb% %p2h%
- if !back!==0 goto get2
- set p1l=%dja%
- call :start
- goto cpu
- )
- goto :get2
-
- :pp2
- if %dja%==%p2l% (
- set p2h=%djb%
- call :start
- goto cpu
- )
- if %djb%==%p2h% (
- call :pdbw %bwl% %rwl% %p1l% %dja% %bwh% %rwh% %p1h% %djb%
- if !back!==0 goto get2
- set p2l=%dja%
- call :start
- goto cpu
- )
- goto :get2
-
- :cpu
- if %p2l%==%rwl% (
- set /a dje=%p2h%-%rwh%
- if !dje! gtr 2 goto cpu2
- if not !dje:~-1!==2 goto cpu2
- set /a djf=%rwh%+!dje!
- call :pdbw %bwl% %rwl% %p1l% %p2l% %bwh% !djf! %p1h% %p2h%
- if !back!==0 goto cpu2
- if !djf! gtr 4 goto cpu2
- set go=rwh
- set go2=!dje!
- set p2=0
- set p2h=-1
- set p2l=-1
- goto cpuok
- )
- if %p2h%==%rwh% (
- set /a dje=%p2l%-%rwl%
- if !dje! gtr 4 goto cpu2
- if not !dje:~-1!==4 goto cpu2
- set /a djf=%rwl%+!dje!
- call :pdbw %bwl% !djf! %p1l% %p2l% %bwh% %rwh% %p1h% %p2h%
- if !back!==0 goto cpu2
- if !djf! gtr 20 goto cpu2
- if !djf! lss 12 goto cpu2
- set go=rwl
- set go2=!dje!
- set p2=0
- set p2h=-1
- set p2l=-1
- goto cpuok
- )
-
- :cpu2
- call :c%rwl%
- goto cpuok
-
- :cpuok
- set /a %go%+=%go2%
- call :start
- goto get1
-
- :c12
- call :pdbw %bwl% 16 %p1l% %p2l% %bwh% %rwh% %p1h% %p2h%
- if %back%==1 (
- call :jiang %p2l% %p1l% 16 %bwl% %rwh% %p2h% %bwh%
- if !back!==1 goto c121
- set go=rwl
- set go2=4
- goto :eof
- )
-
- :c121
- if %p1l%==12 if %p2l%==12 goto win
- if %rwh%==4 (
- set go=rwh
- set go2=-2
- goto :eof
- ) else (
- set go=rwh
- set go2=2
- goto :eof
- )
-
- :c16
- set dje=
- call :jiang %p2l% %p1l% 16 %bwl% %rwh% %p2h% %bwh%
- if %back%==1 (
- call :pdbw %bwl% 20 %p1l% %p2l% %bwh% %rwh% %p1h% %p2h%
- if !back!==0 set dje=-
- set go=rwl
- set go2=!dje!4
- goto :eof
- )
- if %rwh%==4 (
- set go=rwh
- set go2=-2
- goto :eof
- )
- if %rwh%==2 if %p2h%l%p2l%==4l16 (
- set go=rwh
- set go2=-2
- goto :eof
- ) else (
- set go=rwh
- set go2=2
- goto :eof
- )
- if %rwh%==0 if %p2h%l%p2l%==2l16 (
- call :pdbw %bwl% 20 %p1l% %p2l% %bwh% %rwh% %p1h% %p2h%
- if !back!==1 set dje=-
- set go=rwl
- set go2=-4
- goto :eof
- ) else (
- set go=rwh
- set go2=2
- goto :eof
- )
-
- :c20
- call :pdbw %bwl% 16 %p1l% %p2l% %bwh% %rwh% %p1h% %p2h%
- if %back%==1 (
- call :jiang %p2l% %p1l% 16 %bwl% %rwh% %p2h% %bwh%
- if !back!==1 goto c201
- set go=rwl
- set go2=-4
- goto :eof
- )
-
- :c201
- if %p1l%==20 if %p2l%==20 goto win
- if %rwh%==4 (
- set go=rwh
- set go2=-2
- goto :eof
- ) else (
- set go=rwh
- set go2=2
- goto :eof
- )
-
- :win
- call :msg 你赢了! 64 象棋残局
- exit
-
- :pdbw
- set back=1
- if not %1==%2 goto :eof
- if %3==%1 if %7 gtr %6 if %7 lss %5 goto :eof
- if %4==%1 if %8 gtr %6 if %8 lss %5 goto :eof
- set back=0
- goto :eof
-
- :jiang
- set back=0
- if not %1==%2 goto :eof
- if not %1==%3 goto :eof
- if %1==%4 if %6 gtr %7 goto :eof
- if %6 lss %5 goto :eof
- set back=1
- goto :eof
-
- :color
- set color=%1
- set /p= <nul>%color%
- findstr /a:%2 . "%color%*"
- goto :eof
-
- :msg
- echo Msgbox "%1",%2,"%3">1.vbs
- start /wait 1.vbs
- goto :eof
复制代码 http://pan.baidu.com/share/link?shareid=3889153573&uk=1124163200 |