| @echo off |
| title 黑白棋V1.3.1(未完成) |
| color f0 |
| echo;黑白棋V1.3.1(未完成) Made By 路过 ^& cmd1152 |
| echo; |
| echo; 游戏规则 |
| echo;============================================================ |
| echo; 1. 棋局开始时黑棋位于e4和d5,白棋位于d4和e5。 |
| echo; 2. 黑方先行,双方交替下棋。 |
| echo; 3. 一步合法的棋步包括:在一个空格新落下一个棋子,并且翻转 |
| echo; 对手一个或多个棋子。 |
| echo; 4. 新落下的棋子与棋盘上已有的同色棋子间,对方被夹住的所有 |
| echo; 棋子都要翻转过来。可以是横着夹,竖着夹,或是斜着夹。夹住 |
| echo; 的位置上必须全部是对手的棋子,不能有空格。 |
| echo; 5. 除非至少翻转了对手的一个棋子,否则就不能落子。如果一方 |
| echo; 没有合法棋,也就是说不管他下到哪里,都不能至少翻转对手的 |
| echo; 一个棋子,那他这一轮只能跳过,而由他的对手继续落子直到他 |
| echo; 有合法棋可下。 |
| echo; 6. 如果一方至少有一步合法棋可下,他就必须落子,不得跳过。 |
| echo; 7. 棋局持续下去,直到棋盘填满或者双方都无合法棋可下。 |
| echo;============================================================ |
| pause |
| mode con cols=44 lines=22 |
| |
| %程序初始化% |
| set .=%path% |
| for /f "delims== eol=." %%z in ('set ') do (set "%%z=") |
| set path=%.% |
| if not exist hbqtmp\fp\ (md hbqtmp\fp) |
| set mqp=;=0abcdefgh;1=1;2=2;3=3;4=4;5=5;6=6;7=7;8=8;.0=白;.1=黑;_0=○;_1=●;_2= ;_5=※ |
| set/a m49=7,m59=7,m19=5,m29=5,m79=4,m89=3,m99=6%mqp:;=&set .% |
| setlocal enabledelayedexpansion |
| |
| :Init %游戏初始化% |
| for /l %%x in (1,1,8) do (for /l %%y in (1,1,8) do (set m%%x%%y=2)) |
| set /a m44=0,m55=0,m54=1,m45=1,mh=2,mb=2,ms=1,ht=0,sp=0,fp=0 |
| set "mqp= "&(for /f %%z in ('set m') do (echo;%%z))>hbqtmp\m0.txt |
| call :Read q |
| pause |
| |
| :Map %显示地图% |
| cls |
| echo;┏ABCDEFGH┓ |
| for /l %%y in (1,1,8) do ( |
| set "sc=" |
| for /l %%x in (1,1,8) do ( |
| for /f %%c in ("!m%%x%%y!") do (set sc=!sc!!._%%c!) |
| ) |
| echo;!.%%y!!sc!┃ |
| ) |
| echo;┗重玩━读谱━←→跳 |
| echo;黑%mh% 白%mb% |
| echo; |
| set np=%1%mqp:~-4% |
| if "!np!"=="0 0 " (goto :Judge) |
| if !ht! neq 0 (echo;跳过无效,可下步已用%._5%标出 |
| for /l %%x in (1,1,8) do (for /l %%y in (1,1,8) do (set/a m%%x%%y=!m%%x%%y! %% 3))) |
| echo;请!..%ms%!棋落子 |
| set ht=0 |
| if "%1"=="1" (goto :eof) |
| |
| :Mouse %获取鼠标% |
| for /l %%a in (1,1,400) do (echo.>nul) |
| cmos 0 -1 1 |
| set /a P=%errorlevel% |
| set /a X=%P:~0,-3% |
| set /a Y=%P%-1000*%X% |
| set /a "nx=(X-1)/2,ny=y-1" |
| if not defined m%nx%%ny% goto :Mouse |
| |
| if "!M%nx%%ny%!"=="7" (%读谱% |
| call :Read |
| set np=!errorlevel! |
| if !np!==0 (goto :Map) |
| goto :Fupan |
| ) |
| if "!M%nx%%ny%!"=="6" (%跳过% |
| set "mqp=!mqp!0 " |
| set/a sp+=1 |
| (for /f %%z in ('set m') do (echo;%%z))>hbqtmp\m!sp!.txt |
| goto :Check |
| ) |
| if "!M%nx%%ny%!"=="5" (%重玩% |
| call :Replay |
| if !errorlevel!==1 ( |
| del /q /a /f hbqtmp\m* >nul |
| goto :Init |
| ) else ( |
| goto :Map |
| ) |
| ) |
| if "!M%nx%%ny%!"=="4" (%后退% |
| set/a tp=sp-1 |
| if exist hbqtmp\m!tp!.txt ( |
| set/a sp-=1 |
| for /f %%z in (hbqtmp\m!sp!.txt) do (set %%z) |
| goto :Map |
| ) |
| ) |
| if "!M%nx%%ny%!"=="3" (%前进% |
| set/a tp=sp+1 |
| if exist hbqtmp\m!tp!.txt ( |
| set/a sp+=1 |
| for /f %%z in (hbqtmp\m!sp!.txt) do (set %%z) |
| goto :Map |
| ) |
| ) |
| if not "!M%nx%%ny%!"=="2" goto :Mouse |
| call :Valid %nx% %ny% 1 |
| if %errorlevel% neq 0 (%落子成功% |
| set "mqp=!mqp!%nx%%ny% " |
| if %ms%==1 (set/a mh+=1) else (set/a mb+=1) |
| set/a m%nx%%ny%=ms,sp+=1 |
| set/a "ms=(ms+1) %% 2" |
| (for /f %%z in ('set m') do (echo;%%z))>hbqtmp\m!sp!.txt |
| ) |
| set/a x=mh+mb,y=mh*mb |
| if %x%==64 (goto :Judge) |
| if %y%==0 (goto :Judge) |
| goto :Map |
| |
| :Judge %判断胜负% |
| set xqp=%mqp:0=跳% |
| for /l %%a in (1,1,8) do (for /f %%z in ("!.:~%%a,1!") do (set xqp=!xqp: %%a= %%z!)) |
| call :Map 1 |
| set np=%mqp:~-4% |
| if "!np!"=="0 0 " (echo;无棋可走) |
| echo;棋谱:%xqp% |
| echo; |
| if %mh% gtr %mb% (echo;黑棋赢!!) |
| if %mh% lss %mb% (echo;白棋赢!!) |
| if %mh%==%mb% (echo;和棋!!!) |
| call :Save |
| del /q /a /f hbqtmp\m* >nul |
| pause |
| goto :Init |
| |
| :Check %判断一方是否无合法步% |
| for /l %%x in (1,1,8) do ( |
| for /l %%y in (1,1,8) do ( |
| if !m%%x%%y!==2 ( |
| call :Valid %%x %%y 2 |
| if !errorlevel! neq 0 (set/a m%%x%%y=5,ht+=1) |
| ) |
| ) |
| ) |
| if !ht!==0 (set/a "ms=(ms+1) %% 2") |
| goto :Map |
| |
| :Valid %判断落子是否有效% |
| setlocal |
| set/a et=0,x=%1,y=%2,as=1-ms |
| for %%x in (+1 +0 -1) do (for %%y in (+1 +0 -1) do (call :Get %%x %%y)) |
| if %3==2 (endlocal&exit /b %et%) |
| if %ms%==1 (set "ml=mh+=%et%,mb-=%et%") else (set "ml=mb+=%et%,mh-=%et%") |
| for /l %%z in (1,1,%et%) do (set "ml=!ml!,m!w%%z!=ms") |
| (endlocal&set/a %ml%&exit /b %et%) |
| |
| :Get %获取吃子信息% |
| set/a xx=x,yy=y,st=et |
| set rx=%1 |
| set ry=%2 |
| for /l %%w in (1,1,8) do ( |
| set/a xx=xx%rx%,yy=yy%ry% |
| for /f %%z in ("!xx!!yy!") do (set va=!m%%z! |
| if "!va!"=="%as%" ( |
| set/a et+=1 |
| set w!et!=%%z |
| ) else ( |
| if "!va!" neq "%ms%" (set/a et=st) |
| goto :eof |
| ) |
| ) |
| ) |
| goto :eof |
| |
| :Replay %重玩% |
| cls |
| echo;重玩将删除所有记录,并且不能前进和后退。 |
| echo;输入Y回车表示重玩,其他输入皆返回 |
| set /p np= |
| if /i "!np!"=="Y" (exit /b 1) |
| exit /b 0 |
| |
| :Read %读谱% |
| if "%1"=="q" ( |
| if exist hbqtmp\m1.txt (for /l %%w in (2,1,64) do (set/a np=%%w-1 |
| if not exist hbqtmp\m%%w.txt (for /f %%z in (hbqtmp\m!np!.txt) do (set %%z) |
| set sp=!np! |
| goto :eof))) |
| ) |
| cls |
| echo;请输入棋谱名[不需要加后缀,如1] |
| echo;输入0并回车将返回游戏 |
| set np= |
| set /p np= |
| if !np!==0 (exit /b 0) |
| if not exist hbqtmp\!np!.hbqqp ( |
| echo;文件不存在! |
| pause |
| ) else ( |
| exit /b !np! |
| ) |
| goto :Read |
| |
| :Save %保存棋谱% |
| for /l %%z in (1,1,9999) do (if not exist hbqtmp\%%z.hbqqp (echo;mqp=%mqp%>hbqtmp\%%z.hbqqp |
| goto :eof)) |
| goto :eof |
| |
| :Fupan %复盘% |
| set/a fp=1 |
| %复盘功能尚未实现% |
| exitCOPY |