中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-12 02:29
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 八数码问题,游戏 查看 1,225 回复 9
楼 主 八数码问题,游戏 发表于 2009-06-03 05:46 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
积分 2,362
发帖 1,133
注册 2008-02-02 21:36
18年会员
UID 110072
性别 男
状态 离线
如下所示初始状态:
123
485
76.

存在一个最优移动步骤如下:
123 123 123 123 123
485 --> 485 --> 4.5 --> 45. --> 456
76. 7.6 786 786 78.

我觉得这是一个非常适合用批处理制作的一个游戏,
很类似于手机上的拼图游戏(图片包括一个空位,分成9块,打乱后,要求用户通过移动图块还原图片)

不知大家有兴趣否?
2 发表于 2009-06-03 06:33 ·  中国 广东 广州 广东金万邦科技投资有限公司(新一代数据中心)IDC机房(BGP)
银牌会员
★★★
永远的菜鸟
积分 1,335
发帖 574
注册 2007-11-27 12:50
18年会员
UID 103929
性别 男
来自 广西
状态 离线
这个想法很好,严重支持!!!
3 发表于 2009-06-03 10:58 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
积分 1,488
发帖 1,357
注册 2006-05-20 12:00
20年会员
UID 55770
状态 离线
如果支持方向键操作,那可玩性是比较高的

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
4 发表于 2009-06-04 02:59 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
积分 2,362
发帖 1,133
注册 2008-02-02 21:36
18年会员
UID 110072
性别 男
状态 离线
以批处理的命令行窗口和输入方式是绝对适合的~
5 发表于 2009-06-04 04:21 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
19年会员
UID 79003
性别 男
状态 离线
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
6 发表于 2009-06-04 09:23 ·  中国 福建 三明 电信
中级用户
★★
积分 458
发帖 211
注册 2006-07-26 19:42
20年会员
UID 59307
状态 离线
这个题目有意思。

回 3 楼,配合 CHOICE.EXE 就很好了。
┌───────┐
├→学习→实践→┤
└───────┘
7 发表于 2009-06-04 09:39 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
积分 1,916
发帖 752
注册 2008-12-28 04:30
17年会员
UID 135147
性别 男
来自 广西
状态 离线
@echo off
goto :begin



批处理拼图
┍=┯=┯=┐
│!a1!│!a2!│!a3!│
┝=┿=┿=┥
│!a4!│!a5!│!a6!│
┝=┿=┿=┥
│!a7!│!a8!│!a9!│
┕=┷=┷=┙
用方向键控制
按 Esc 键退出
┍=┯=┯=┐
│!a1!│!a2!│!a3!│
┝=┿=┿=┥
│!a4!│!a5!│!a6!│
┝=┿=┿=┥
│!a7!│!a8!│!a9!│
┕=┷=┷=┙

:begin
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
setlocal enabledelayedexpansion
for %%a in (1 2 3 4 5 6 7 8) do set a%%a=%%a
set "a9= "
set/a m=3,n=3,chbe=9
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
set/a ran=!random!%%5+5
set aiall=9
for /l %%a in (0,1,%ran%) do (call :random)
call :change aiall
call :print
set total=0
:loop
ping -n 1 127.1 >nul
call in.com
if "%errorlevel%" equ "1" goto :quit
if not defined com%errorlevel% goto :loop
set comm=!com%errorlevel%!
%comm%
set/a chto=m*3+n-3
if !chto! equ !chbe! goto :loop
cls
for /f "tokens=1,2 delims=-" %%a in ("!a%chbe%!-!a%chto%!") do (set a!chbe!=%%b&set a!chto!=%%a)
set chbe=!chto!
set/a total+=1
call :print
if "!a1!!a2!!a3!!a4!!a5!!a6!!a7!!a8!!a9!" equ "12345678 " echo 厉害!用了!total!步。&pause
goto :loop

:quit
echo 谢谢使用,再见!
ping -n 2 127.1 >nul
goto :eof

:print
for /f "skip=2 delims=" %%a in (%~f0) do (
if "%%a" equ ":begin" goto :echoend
echo; %%a
)
:echoend
echo;
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

为了能用方向键控制,用debug生成了一个in.com 三方命令
可随机打乱,有两个图是准备做成两人 pk

[ Last edited by netbenton on 2009-6-6 at 00:03 ]
精简
=> 个人网志
8 发表于 2009-06-05 02:44 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
积分 2,362
发帖 1,133
注册 2008-02-02 21:36
18年会员
UID 110072
性别 男
状态 离线
又来网吧喽,时间不多~

@echo off
setlocal enabledelayedexpansion
mode con cols=35 lines=15
set /a num11=1,num12=2,num13=3
set /a num21=4,num22=8,num23=5
set /a num31=7,num32=6
set "num33= "
set blank=33
::目前空格所在位置blank=33
set /a ccw=+10,cca=+1,ccs=-10,ccd=-1
::移动操作数

:loop
cls
echo,
echo, %num11% %num12% %num13%
echo, %num21% %num22% %num23%
echo, %num31% %num32% %num33%
if "%num11%%num12%%num13%%num21%%num22%%num23%%num31%%num32%"=="12345678" (
echo,The end
pause>nul
exit
)
echo,&echo, q = exit
set /p inp="(w a s d) (q): "
if "%inp%"=="q" exit
if defined cc%inp% (set /a blanknext=blank+cc%inp%)
if defined num%blanknext% (
set /a num%blank%=num%blanknext%,blank=blanknext
set "num%blanknext%= "
)

goto :loop


[ Last edited by 523066680 on 2009-6-5 at 03:13 ]
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
moniuming +15 2009-06-07 11:57
9 发表于 2009-06-06 16:41 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
积分 1,916
发帖 752
注册 2008-12-28 04:30
17年会员
UID 135147
性别 男
来自 广西
状态 离线
拼图游戏做好了!
***开局随机打乱,并保证是可以拼成的。
***两人同时对战。
@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 ]
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
moniuming +15 2009-06-07 11:48
精简
=> 个人网志
10 发表于 2009-06-14 02:17 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
积分 2,362
发帖 1,133
注册 2008-02-02 21:36
18年会员
UID 110072
性别 男
状态 离线
今天上两元一个钟的 电脑,执行了楼上的代码,真赞啊~
论坛跳转: