拼图游戏做好了!
***开局随机打乱,并保证是可以拼成的。
***两人同时对战。
@echo off
set ec3= 批处理拼图比赛
set ec4= 靓女 靓仔
set ec5= ┍=┯=┯=┐ ┍=┯=┯=┐
set ec6= │!b1!│!b2!│!b3!│ │!a1!│!a2!│!a3!│
set ec7= ┝=┿=┿=┥ ┝=┿=┿=┥
set ec8= │!b4!│!b5!│!b6!│ │!a4!│!a5!│!a6!│
set ec9= ┝=┿=┿=┥ ┝=┿=┿=┥
set ec10= │!b7!│!b8!│!b9!│ │!a7!│!a8!│!a9!│
set ec11= ┕=┷=┷=┙ ┕=┷=┷=┙
set ec12=上W,下S,左A,右D 用方向键控制
set ec13= 按 Esc 键退出
set ec14= !msg!
set ec15= !msg1!
set ec16= !msg2!
set ec17= !msg3!
set Namea=靓仔
set Nameb=靓女
chcp 437 >nul
graftabl 936>nul
(echo e 100 B8 00 00 CD 16 88 E0 B4 4C CD 21
echo r cx
echo b
echo n in.com
echo w
echo q)|debug>nul
set com80=if !m! gtr 1 set /a m-=1
set com72=if !m! lss 3 set /a m+=1
set com77=if !n! gtr 1 set /a n-=1
set com75=if !n! lss 3 set /a n+=1
set com31=if !x! gtr 1 set /a x-=1
set com17=if !x! lss 3 set /a x+=1
set com32=if !y! gtr 1 set /a y-=1
set com30=if !y! lss 3 set /a y+=1
for %%a in (1 2 3 4 5 6 7 8) do set a%%a=%%a
set "a9= "
set ai1=b 9 8 7 4 1 2 3 6
set ai2=l 1 2 5 8 7 4
set ai3=l 2 3 6 9 8 5
set ai4=l 4 5 6 9 8 7
set ai5=l 1 2 3 6 5 4
set ai6=s 1 2 5 4
set ai7=s 2 3 6 5
set ai8=s 4 5 8 7
set ai9=s 5 6 9 8
set NL=6
set NB=8
set NS=4
setlocal enabledelayedexpansion
:begin
set wina=
set winb=
set/a gg+=1
set msg3=!msg2!
set msg2=!msg1!
set msg1=!msg!
set msg=第!gg!局:
cls
set/a m=3,n=3,chbe=9
set/a ran=!random!%%8+8
set aiall=9
for /l %%a in (0,1,%ran%) do (call :random)
call :change aiall
set/a x=m,y=n,chae=chbe
for %%a in (1 2 3 4 5 6 7 8 9) do set b%%a=!a%%a!
for /l %%a in (0,1,18) do (for %%b in ("!ec%%a!") do echo; %%~b)
set/a totala=0,totalb=0
:loop
ping -n 1 127.1 >nul
call in.com
set error=!errorlevel!
if "!error!" equ "1" goto :quit
if not defined com!error! goto :loop
for %%a in (!error!) do set comm=!com%%a!
if !error! gtr 40 (set man=a) else (set man=b)
%comm%
if !man! equ b (
set/a chto=x*3+y-3
set/a chbx=chbe
) else (
set/a chto=m*3+n-3
set/a chbx=chae
)
if !chto! equ !chbx! goto :loop
for /f "tokens=1,2 delims=-" %%a in ("!%man%%chbx%!-!%man%%chto%!") do (set %man%!chbx!=%%b&set %man%!chto!=%%a)
set ch%man%e=!chto!
set/a total%man%+=1
cls
for /l %%a in (0,1,18) do (for %%b in ("!ec%%a!") do echo; %%~b)
set str=
for /l %%a in (1,1,9) do (set str=!str!!%man%%%a!)
if "!str!" equ "12345678 !win%man%!" echo !Name%man%!赢了,用了!total%man%!步。&set win%man%=#&set msg=!msg! !Name%man%!用了!total%man%!步&pause&if defined wina (if defined winb goto :begin)
goto :loop
:quit
echo 谢谢使用,再见!
ping -n 2 127.1 >nul
goto :eof
:change
set ver=!%1:~,1!
for %%a in (!%1:~1!) do (
for /f "tokens=1,2 delims=-" %%b in ("a!ver!-!a%%a!") do (
set a%%a=!%%b!
set %%b=%%c
)
set ver=%%a
)
set/a chbe=ver
set/a ver-=1,"m=ver/3+1",n=ver%%3+1
goto :eof
:random
set v=0
for /l %%a in (1,1,9) do (
if "!ai%%a:%chbe%=!" neq "!ai%%a!" (
set /a v+=1
set r!v!=!ai%%a!
)
)
set/a ran=!random!%%v+1
set/a r=N!r%ran%:~,1!
set str=!r%ran%:~1!
set str=!str:*%chbe%=!%str%
set/a ran=!random!%%r*2+4
set str=!str:~,%ran%!
set aiall=!aiall!!str!
set chbe=!str:~-2!
goto :eof
[
Last edited by netbenton on 2009-6-7 at 00:19 ]