![Board logo](images/default/logo.gif)
标题: [游戏娱乐] 新推箱子bat,升级至3.0版 [打印本页]
作者: happy886rr 时间: 2016-9-5 00:01 标题: 新推箱子bat,升级至3.0版
[2016/9/11]升级Version3.0
新版推箱子升级Version3.0。集成了超难度的50多关,采用动态显示压缩算法,绘图性能是首版的5倍。增加非常多的辅助按键功能,增加自动化脚本。F键定义为保存用户自动化按键并退出;Q为退一步;R重置;M为设置一个记录点,然后当你走死后,直接按E键退回到M记录的锚点,非常有助于冲破难关。G为自动化脚本,按G后,自动推箱子。模块重复利用率极高,逻辑度非常复杂,已经无法继续增加新功能了。- WSAD 上下左右
- Q退步,M设置锚点,E恢复至锚点,R重置
- N下一关,F保存用户数据,G开启自动化脚本
复制代码
-----------------------------------------------------------------------------------------------------------------------------------------
[2016/9/5]首版Version1.0
研究了下推箱子,我用大量if取代for去完成运算和构图,将其分解为模块化的单元任务,逐个构造,最后融成一个可用的批处理。考虑了很多情况,所以既可单文件运行,也可读取同目录下的MapData.box文件运行。数千关,随机挑选。还有很多隐藏功能,比如可以设置F1=1,开启防闪显示。WSAD上下左右,N下一关,R重走。时间仓促,漏洞以后完善。当然此脚本稍加修改基本可以实现走迷宫、俄罗斯方块、贪吃蛇等的实现,只要替换数据处理部分即可。想玩特殊关卡的请下载地图附件
链接: https://pan.baidu.com/s/1QoICjZX_XkxFa7CILHw_gw?pwd=nk8q
兼容标准box地图文件,自动生成地图,机选可能会眼花。- ::**************推箱子使用说明**************
- REM WSAD 上下左右
- REM Q退步,M设置锚点,E恢复至锚点
- REM R重置,N下一关,F保存用户数据
- REM G开启自动推演
- cls
-
- ::**************Happy's 推箱子**************
- @echo off&title
- mode con cols=80 lines=22
- REM 窗体配色
- color 0F
- ::color F0
-
- REM 默认皮肤
- ::set "ELEMENTS=○□○╳▓▓我踩"
- set "ELEMENTS=○□○╳▓■我踩"
- ::set "ELEMENTS=○■○╳▓◆我★"
- ::set "ELEMENTS=○■○╳箱◆大踩"
- ::set "ELEMENTS=○■○╳▓□我踩"
-
- REM 防闪开关
- set F1=0
- ::set F1=1
- REM 自动脚本
- set AUTO=0
- ::set AUTO=1
-
- REM 计数面板
- set "READM1=POSITION:"
- set "READM3=STEPS:"
- set "READM5=ANCHOR:"
- set "READM7=MADE BY HAPPY"
- set "READM8= Version3.0"
-
- ::****************先导程序******************
- setlocal enabledelayedexpansion
- for /l %%i in (1,1,365) do (
- set "SPACE=!SPACE!"
- )
- for /l %%N in (0,1,7) do (
- set P%%N=!ELEMENTS:~%%N,1!
- )
- if exist "%~dp0UserData.ini" (
- set/a "AUTO=1,Mark8=1"
- set "ReadFile=%~dp0UserData.ini"
- ) else (
- set "ReadFile=%~f0"
- )
- for /f "tokens=1-5" %%A in ('findstr /rc:"^ *[0-9][0-9]* *[0-9][0-9]* *[0-7][0-7].*" "%ReadFile%"') do (
- set "LINES="
- for /l %%i in (1,1,%%A) do (set "LINES=!LINES!--")
- set/a "MapWidth=%%A,MapHeight=%%B,n+=1"
- if not "%%E"=="" (set/a n=%%E)
- set "HEAD=!LINES![LEVEL !n!]"
- set "MapData=%%C"
- set "MapDataBak=%%C"
- set "StepBak=%%D"
- call :MAIN
- )
- exit
-
-
- ::****************主体程序******************
- :MAIN
- setlocal
- if !n! leq 2 (set "AUTO=1") else (set "AUTO=0")
- if defined Mark8 (set "AUTO=1")
- if !AUTO! equ 1 (set "StepStr=!StepBak!")
- set/a "Check1=0,Mark2=0"
- if !F1! equ 1 cls
-
- REM 构建显存
- :DISRAM
- for /l %%j in (1,1,%MapHeight%) do (
- set "DISPLAY[%%j]="
- set "tmp=!MapData:~0,%MapWidth%!"
- for /l %%i in (1,1,%MapWidth%) do (
- set "POINT[%%i][%%j]=!tmp:~0,1!"
- set tmp=!tmp:~1!
- if !POINT[%%i][%%j]! equ 6 (set/a "X=%%i,Y=%%j")
- for %%P in (!POINT[%%i][%%j]!) do (
- set "DISPLAY[%%j]=!DISPLAY[%%j]!!P%%P!"
- )
- )
- set "MapData=!MapData:~%MapWidth%!"
- )
-
- :ANCHOR
- set "READM2= (!X!,!Y!) !AUTO!"
- set "READM4= !steps! "
- set "READM6= [!MarkSteps!] "
- if !F1! equ 1 (2>nul echo !SPACE!) else cls
-
- REM 绘图引擎
- echo;!HEAD!
- for /l %%j in (1,1,%MapHeight%) do (
- echo;!DISPLAY[%%j]:○= !│!READM%%j!
- )
- echo;!LINES!
-
- REM 检查过关
- if not defined Mark2 (
- if !POINT[%X%][%Y%]! neq 7 (
- for /l %%j in (1,1,%MapHeight%) do (
- for %%P in (!P3!) do (
- if not "!DISPLAY[%%j]:%%P=!"=="!DISPLAY[%%j]!" (set Check1=1)
- )
- )
- if not defined Check1 (
- echo 恭喜过关!
- choice /t 1 /d y /n >NUL
- goto NEXT
- ) else (
- set "Check1="
- )
- )
- )
-
- REM 按键反馈
- :CHOISE
- set Xp=!X!
- set Yp=!Y!
- if !AUTO! equ 1 (
- if "!StepStr:~%steps%,1!"=="1" (set/a Y-=1)
- if "!StepStr:~%steps%,1!"=="2" (set/a Y+=1)
- if "!StepStr:~%steps%,1!"=="3" (set/a X-=1)
- if "!StepStr:~%steps%,1!"=="4" (set/a X+=1)
- if "!StepStr:~%steps%,1!"=="D" (
- if defined Mark6 (set "Mark6=")
- for /f "tokens=1 delims=D" %%a in ("!StepStr!") do (
- set "StepStr=%%a"
- )
- set/a AUTO=0
- goto CHOISE
- )
- if defined Mark6 (choice /t 1 /d y /n >NUL)
- goto ANCHOR2
- )
- choice /C WSADRNQMEFG >NUL
- if %errorlevel% equ 1 (set/a Y-=1)
- if %errorlevel% equ 2 (set/a Y+=1)
- if %errorlevel% equ 3 (set/a X-=1)
- if %errorlevel% equ 4 (set/a X+=1)
- if %errorlevel% equ 5 (
- endlocal
- goto MAIN
- )
- if %errorlevel% equ 6 (
- goto NEXT
- )
- if %errorlevel% equ 7 (
- set/a Mark4+=1
- if !Mark4! equ 2 (
- set/a "X=Xp,Y=Yp"
- set "Mark4=1"
- goto CHOISE
- )
- set/a "Xp=X-dx,Yp=Y-dy,1/(dx+dy)" 2>NUL||goto CHOISE
- set/a "POINT[!Xp!][!Yp!]=POINTv0,POINT[!X!][!Y!]=POINTv1,POINT[!Xf!][!Yf!]=POINTv2"
- set/a "Mark3=1,steps-=1,Mark7=1"
- set "StepStr=!StepStr:~0,-1!"
- goto DISGPU
- )
- if %errorlevel% equ 8 (
- set/a "Mark5=1,MarkSteps=steps"
- for /l %%j in (1,1,%MapHeight%) do (
- for /l %%i in (1,1,%MapWidth%) do (
- set "POINT_M[%%i][%%j]=!POINT[%%i][%%j]!"
- )
- )
- goto CHOISE
- )
- if %errorlevel% equ 9 (
- if not defined Mark5 (goto CHOISE)
- for /l %%j in (1,1,%MapHeight%) do (
- set "tmp="
- for /l %%i in (1,1,%MapWidth%) do (
- set "tmp=!tmp!!POINT_M[%%i][%%j]!"
- )
- set "MapData=!MapData!!tmp!"
- )
- set/a "steps=MarkSteps.Mark7=1"
- set "StepStr=!StepStr:~0,%steps%!"
- goto DISRAM
- )
- if %errorlevel% equ 10 (
- echo %MapWidth% %MapHeight% %MapDataBak% %StepStr%D !n!>"%~dp0UserData.ini"
- exit
- )
- if %errorlevel% equ 11 (
- if defined Mark8 (
- echo 没有演示文件!
- choice /t 1 /d y /n >NUL
- set "Mark8="
- goto CHOISE
- )
- if "!StepBak!"=="" (
- echo 没有演示文件!
- choice /t 1 /d y /n >NUL
- goto CHOISE
- )
- set "MapData=!MapDataBak!"
- set "StepStr=!StepBak!"
- set/a "AUTO=1,Mark6=1,steps=0"
- goto DISRAM
- )
-
- :ANCHOR2
- REM 增量坐标
- set/a "dx=X-Xp,dy=Y-Yp,Xf=X+dx,Yf=Y+dy"
- set POINTv0=!POINT[%Xp%][%Yp%]!
- set POINTv1=!POINT[%X%][%Y%]!
- set POINTv2=!POINT[%Xf%][%Yf%]!
- set "Mark4="
-
- REM 数据一次处理
- if !POINTv1! equ 1 (
- set "Mark1=1"
- )
- if !POINTv1! equ 2 (
- set/a "POINT[!X!][!Y!]=6
- set "Mark2=1"
- )
- if !POINTv1! equ 3 (
- set/a "POINT[!X!][!Y!]=7"
- set "Mark2=1"
- )
- if !POINTv1! equ 4 (
- if !POINTv2! equ 1 (set "Mark1=1")
- if !POINTv2! equ 2 (
- set "Mark2=1"
- set/a "POINT[!X!][!Y!]=6,POINT[!Xf!][!Yf!]=4"
- )
- if !POINTv2! equ 3 (
- set "Mark2=1"
- set/a "POINT[!X!][!Y!]=6,POINT[!Xf!][!Yf!]=5"
- )
- if !POINTv2! equ 4 (set "Mark1=1")
- if !POINTv2! equ 5 (set "Mark1=1")
- )
- if !POINTv1! equ 5 (
- if !POINTv2! equ 1 (set "Mark1=1")
- if !POINTv2! equ 2 (
- set "Mark2=1"
- set/a "POINT[!X!][!Y!]=7,POINT[!Xf!][!Yf!]=4"
- )
- if !POINTv2! equ 3 (
- set "Mark2=1"
- set/a "POINT[!X!][!Y!]=7,POINT[!Xf!][!Yf!]=5"
-
- )
- if !POINTv2! equ 4 (set "Mark1=1")
- if !POINTv2! equ 5 (set "Mark1=1")
- )
-
- REM 数据二次处理
- if defined Mark1 (
- set/a "X=Xp,Y=Yp,Mark4=1"
- set "Mark1="
- goto CHOISE
- )
- set/a steps+=1
- if defined Mark2 (
- if !POINTv0! equ 7 (
- set/a "POINT[!Xp!][!Yp!]=3"
- ) else (
- set "POINT[!Xp!][!Yp!]=2"
- )
- set "Mark2="
- )
-
- REM 绘图加速引擎
- :DISGPU
- if !dy! equ 0 (
- if not defined Mark7 (
- if !dx! gtr 0 (
- set "StepStr=!StepStr!4"
- ) else (
- set "StepStr=!StepStr!3"
- )
- ) else (set "Mark7=")
-
- set "DISPLAY[%Yp%]="
- for /l %%i in (1,1,%MapWidth%) do (
- for %%P in (!POINT[%%i][%Y%]!) do (
- set DISPLAY[%Y%]=!DISPLAY[%Y%]!!P%%P!
- )
- )
- ) else (
- if not defined Mark7 (
- if !dy! gtr 0 (
- set "StepStr=!StepStr!2"
- ) else (
- set "StepStr=!StepStr!1"
- )
- ) else (set "Mark7=")
- for /l %%j in (!Yp!,!dy!,!Yf!) do (
- set "DISPLAY[%%j]="
- for /l %%i in (1,1,%MapWidth%) do (
- for %%P in (!POINT[%%i][%%j]!) do (
- set DISPLAY[%%j]=!DISPLAY[%%j]!!P%%P!
- )
- )
- )
- )
- if defined Mark3 (
- set/a "X=Xp,Y=Yp,Mark4=1"
- set "Mark3="
- )
- goto ANCHOR
-
- :NEXT
- endlocal
- goto :EOF
-
- REM 测试地图
- 8 8 0011111011122210124212111212232112222121112122210162211101111100 113114322441444311332213322443224411314D
- 8 8 0011111011122210124212111212232112322121114134210162211101111100 43441133311432244422331244111411332332244331144213322422441131114422422341131133224D
- 8 8 0111110001222100114121111222462112122121121323211222111111111000 422333114113321442232223311144311442212334224441122333214441133234144223344113311332243114433223222441233111411442221113322322244141132D
- 19 14 00000000000111111110000000000012233331111111111111223333112222122424222333311244414224212233331122422222421223333112442142424111111111224212222210000000112111111111000000012222122221100000001222224222110000000122441442261000000012222122221100000001111111111100000000
- 16 16 0011110000000000001221111111111100122224222424210012412421224221001224242212222111124121221111211614242422112221122224214122212112224222242424211111122111111111001222222100000000122222210000000013333331000000001333333100000000133333310000000011111111000000
- 17 14 0000000000111111100000000001223331000000111112233310000001222222323100000012211223331000000112112233310000011121111111100000124442110000011111224242111111122214242221222116242242222422421111111244242111110000012222221000000000111111110000
- 19 16 0111001111111111111116111122222221222112442224422424233311224441222242213331124222124424421333111122212242222133311222221242424213331122221111112111333111212212242422133311221121244242411331123312122422222213112331212444244421311111121222222212131000012111111111213100001222222222221310000111111111111111
- 19 15 000000000011110000000000111101221000000001112611142100000001122222242210000001122424411211000000122141122222100000012124244212111000001222421221242111111111222212244212221111121124222222222113222211122111111111332331011110000000133313100000000000013333310000000000001111111000000000000
- 17 13 11111111111111110122222222222222101212111111222221012122424242412210121222464222112111212242424111333112122242422113331121114442421133311222221211211333111111222112113331000011111222221110000000012222210000000000111111100
- 19 13 0001111111110000000001122211221111100011122222122122221111224214212212233321121241641121213132112212142212222323211242222421212131321122211221142423232112421222122141313211124224222422433321014211111122221122101221000011111111110111100000000000000
- 18 16 000000011111110000011111112222210000012222212464210000014421222111111111012111333333112221012224333333112121012111333333222221112221111211121411122142221224221210122424442212411210122242421114421210111112222242221210000011121112221210000000122222122210000000111111112210000000000000011110
- 17 16 00011111111000000000122212210000000001224222100000001112142221111000012242211422210000122126242124100001221222222421111011211114112222210124133333121222101224335532412111112213333312221001222111211111110012442212210000000122122222100000001111112221000000000000111110000000
- 14 15 111110000000001222110000000012222100111100124221111221001224424222410011162142222110012211224242110124221121123101221411422131011122243311310012222135333100124421333331001221111111110012210000000000111100000000
- 16 14 00011111111110000001332212221000000133222222100000013322122111100011111112212211001222222222222100122122112212211111211221111211122422111112122112124224221242211264224222122211111121121111111000012222100000000001111110000000
- 19 13 0000011111111111000000001223221222100000000121322226210000111112113312111100112212331112222211112421333222421224211222233211221121121111141141242122212100112122221424421210012242121221241121001222222222222222100122111111111112210011110000000001111
- 19 16 0011111100000000000001222611110000000011111242221000000001222112222111100000124212211222210000012421221111121000001124224222212100000112424211121210000011212242212121000001121214122212100000112111222121211111112242211112121333311222242222422233131111142241242223333112222222122112333311111111111111111111
- 19 16 0000111111111100000111112222222211110012222212224221621001211111114111122111121222211212214233112124222221221221311212422122222142331121221112112222213112111221221221423311212222122111122131121422242242214233112222421242421221311111241112222142331000122224421113333100012222221101111110001111111100000000
- 15 15 111111111000000122222221000000122222221111000112111121221000112161122221000124442422441000122121124221000122121122421111111122444241221012221122233331012122212133231012221212113331011111242213331000001122211111000000111110000
- 19 16 1111110000011110000122221111111221111112224122122422122211224224224212424221114242221261242222112242111111111112111212221333333312410121122123333331221012122243333333342101212421333323312210122424111141111241012422211124222422111242222242422422221112111111242111112112222222221222222211111111111111111111
- 19 14 00001111111000000000000122122111100000111112414212211000013321221221222100001332124142122411110132212222214221221013322241221242222101336122142142212210133212412222241221013321221441422122111332124122122414221133212212212221222111321111221111122210111100111100011111
- 19 16 1111111111111110000133333333332231111013333333333443122101111111111142122211122222242242222242111211112221224212211222222122211221211122412212112211121112421411122221112111112242122122111211111222242112122121101242212242242422210122422414442212221012212242222221111101261122122122100000111111111111110000
- 19 16 1111000000000000000122111111111111110012212223313333331001221212111112333100114122223333333310012221141111112211111242122222111111621114212422211111122112242144411222222211222222122221414111121111214444422221012122224222221222101212221122222222111121111114111111242112222222210000122211111111111000011111
- 15 12 011111110000000012212211111000112212213331110122412213332210124214423332210122412213332310122212411111111114222222242421112212244212221011111122114461000000122222211000000111111110
- 19 13 0111111111111111110013332221222212221111333332241121214211333333122422122221133333312212212122111111111124224242210012222214114211411011222422221242222101221121112122114210124244222224224221012422224114211111101111111226211000000000000111111000000
- 17 15 000000000111110000000011111222100000001124224221111111112422424211311222222244221133112211111121113321112122122221333211242221222213332116214211211113331111122424422113310001122424224333100001244224212231000012224242211110000111111222100000000000011111000
- 19 13 1111100000000000000122211000000000000012422111111111000001121212222222111111112122241416221222112212222224212224211221112111111111211122112335333332121111211253533535212111241111111111211421122422242242222422112212221222122212211111111111111111111
- 19 14 00000001111111111100000000122212222210111110012222242421012221111124112121101242112221211242210124226442121144421011211122212112222101121222111211111410112122222422133331012211121124213333111242224212221334321122112421221133332111111222111111333110000111110000111110
- 18 16 001111000000000000001221111111110000011221122122210000012241246422211110014224221242412211112241121424222221122122121222444221124222242241121111124242141221221000112211122111421000012213333222221000011113333331111000000133331111000000000133311000000000000133310000000000000111110000000000
- 13 15 000000111100000111112210000112222241000112422112111016424212422101111211222410013333142421001333312224100133332244211013332124222101111114242210000001222111000000142111000000012210000000001111000
- 12 15 111111111111112222211221112224222421111121124421122242122221124442121111122212124211122122122421124124122221122233121111111133242161133333124121113333122421111331122221111111111111
- 14 15 011111111100000133332221100001313122421100113333121261101233331221221112222214211421112111224222210142242424122101212242421121012211122112210122221121121101224212242210011142422211100001221111100000011110000000
- 19 16 1111111111110111111122212222121113333112224412226223333311222121112221233331112112111221223333101242422222121211110122424112212222221111121221111212112112212142221121222211242242212112122211121242422221212221012242112112121111101244222224422100000112112111242210000001222210122221000000111111011111100000
- 19 16 0000000000001111100111110011111122210012221111224242421001242221121121122110122242422222422421011124221121122222110012111112111114421011411111261122222101242211141112422110124221222111221110012442421222442100001222221222112210000111111133231110000000013333333331000000001333333333100000000111111111110000
- 19 15 111111111110000000013333332221111111111333333222122112221133111242222422222113332424212221122211333141111122221221111222212221422142100122442424224112210012242221414211421001112112122221122100012242421121111110001222242242210000000112221212221000000001111161111100000000000011100000000
- 19 16 0000000000000111111011111111111113333111222112222211333311224411224261133331122222244241223333112242112442121233311224211242212233331112111112111211311111222422421122232211241112212111112111122242221222222210012242142424111221001244412422210111100122221224421000000011111122211100000000000011111000000000
- 17 16 00001111111111110000012222222222110000122121442422100001421412211261000112112124212110001222421422121000012221242221210000112424222112100001221221122421000012222112441210111111442221222101333312211111111013133321100000000133332221000000001333322210000000011111111100000000
- 19 15 000000000001111100000000000001122211000000000001122222100000000001122442210000000001124422421000000000124222242100111100012224421111112211111111211222211322222222222244461131211111112112221113121111111321424111333333333332122221111111111111112242100000000000001122110000000000000011110
- 18 13 000001111111100000001111222222111111001222211242422261001211211414242411111233333312244211122233333312212221121233333314224221121433333324412421122211121114224211111224224224224210001224224224224210001111112221111110000000011111000000
- 19 11 00000000111111100000000111112212211110000012221222422221001111214421121122101122222212122112111122111241422422422113332222121122122211333122226212111211133312211122422422111111111011222122210000000000111111111
- 19 15 011111000000000000001222100000000000000121211111110000000012222224611111100001242114211122210000121111242222421000012111112122142111111221111211422222211224122422121121121122222222212133312111111122111223332210000011110121333121000000000012111212100000000001222222210000000000111111111
- 16 14 11111011110000001333101221111000133311122422100013333112422411101133331122242210111333211242421012112222122422101221121211121111124212142242222112242624222242211222124244242111122111111221110012110000111100001110000000000000
- 14 16 11111111110000122222222111101211111121221112124242422421122222221422211114224412211100122112124110001141222426100001224242111000012122242210000121122212100011221111121000122222222210001333333311100013333333100000111111111000
- 18 11 000000000111100000011111111122110000112242222224211111122211211222113331121442424414113331121222622212223331122412111442223331124224422421133331111422222221111111001221111111000000001111000000000000
- 13 16 0011111111100001535153510000135353531000015353535100001353535310000153535351000011122211100000012221000011111121111111222222222221124242424242111242424242110142424242410012224642221001221111122100111100011110
- 16 15 000000011110000000000001221100000000000122211000000000012442110000000111422421100011112222422210111221211111221012222121333342101212224233331210122421213533121011122111121112100011112642211411000001112422222100000001221122210000000111111111
- 19 16 0000001111111111110000001133222212221000001133524222242100001133531212124110000133531212124221011113331221222212101221121222222222210126424211122122211012422242221212221001114422212121212100001222422212121111100124121111122222210014222100012222121001221110001122222100122100000012222110011110000001111110
- 14 12 011111111100000122222221000001242442410000111212242100001312224421100013111222421000131324211211111333224112422113334222422221133111411121611331012222211111110111111100
- 20 15 111111111111111111111222211222122221222112242242222211242221112111112231111112110121122113333111121111211421113311222221122222213332312424211242112112321112111112124222213112121000124242122231111211001212211212112212211011111112241142224210000000112222224216100000000122112111111000000001111111000000
- 20 12 111111111111111111111222122221222122216112422222242224222121112111331121112222211222133331412241112112421333312242242421122213333121212424211222113311222141222111411222211221221411122242242222212212211222122221222122222111111111111111111111
- 20 12 111111111111111111111222261122222212221112222112222422224211122111333312121221111222133331212124222111121333122122222221112211312222242224211122424211122121211111242222222121242221111124224121212124211111222222222121221111111111111111111111
- 20 12 111111111111111111111221221122221222611111222242222124111221114124211412424222211222412222422222211112112224211122133331121241212121213333111222242421221333311111421112242133331111122124222222221111111222222121222211111111111111111111111111
- 20 12 111111111111111111111622222111222122122112121221224224222221111112222212424141211313312222114242222113333322224222122211133333222211141141111313312222422221222111111222221221422421111112212242222424211111122122122122122111111111111111111111
- 20 12 111111111111111111111133322211212222122113333222222222421121133331212141114222211333122221222222212111312214212222241121122122124242111224211222224224212212112111212112144124122121122122242421222222111222212222212212226111111111111111111111
- 20 12 111111111111111111111222122161211221111112121224222242211111121222211111124221111222122133331224422111411411333312222221122222213333114114111224422133331222222112422422122122111221111112242224222242211111121222212212221111111111111111111111
- 20 12 111111111111111111111212222212222222222112222222422112111211111112211222422422211133112212124212122113333224222221141211133332241111122214111133121221222122422111131212242224221261112242242122212211111122222221111111111111111111111111111111
- 20 12 111111111111111111111222221113311122222112442211133111224621122121133333312242211222221333333122422111112211133111111421122244421331222212211241222422422442142112212211242211221221124222242112422224211221221122221122122111111111111111111111
- 20 12 111111111111111111111222212212122122122112612121124222422211111121222212212422211222212112142112112112222224222422242221133111441124114211211331312212422242122113333124422211421111133331221111122222211333111222222221122111111111111111111111
- 20 12 111111111111111111111333312222222122122113333121242242222221133332112241212414211333122242224122422113311112212422244221122222211112111121111222222221222122222112112221222421242421121122224211242242211222226122222122212111111111111111111111
- 20 12 111111111111111111111333311122222222222113333111112122141211133331112221422422211333311122224221441111221111241221424221112211112242242212211622111141114112422111222222221221224221112221112212242211111111111122122122222111111111111111111111
- 20 12 111111111111111111111222221222226133311112222212222221133311121212114112112333311222421222444223333111141112442211121131122222422122221211111224221221112212122111214112222422442221122242112221221212211222221222212212222111111111111111111111
- 20 12 111111111111111111111222221221333162222112122222223333122221122422122213333122211211411112113333122112422242212213331221124421222122212442211112244412224422422112422122122221241221122241221222222242211221222212222122122111111111111111111111
- 20 12 111111111111111111111111161113113331122111111422331333122221111122223333331224211112242133333112121111224412111112242421112412422221122442211122122122221242242111222442111214112221112412222224242242111112222122221222211111111111111111111111
复制代码
作者: codegay 时间: 2016-9-5 04:48
加个重玩本关
作者: 523066680 时间: 2016-9-5 08:33
本帖最后由 523066680 于 2016-9-5 08:54 编辑
第一感觉,好久没看到有人用批处理做游戏啦,
打开一用,咦,用了什么黑科技,可以直接wasd而不用回车。
原来是choice,刚好我把choice放进环境变量的目录了所以直接见效。
加个信息:显示当前移动的步数
作者: aa77dd@163.com 时间: 2016-9-5 14:09
每一次移动用字母记录下来, u d l r 表示 上 下 左 右, 如果推了箱子, 则用大写字母表示 U D L R
建立堆栈(每一次移动都只用一个字符位), 把所有的移动都记录下来, 就可以做任意步 (若堆栈是一个变量, 步数不超出字符容纳上限) 的回退了
关卡数据可以用 Run length encoding 方式来压缩, 从而可以用很节省的方式直接保存在 CMD 文件内部
Run length encoding
http://www.sokobano.de/wiki/index.php?title=Level_format
作者: CrLf 时间: 2016-9-5 14:17
回复 4# aa77dd@163.com
每个箱子也要记录
作者: aa77dd@163.com 时间: 2016-9-5 15:03
回复 5# CrLf
不需要记录箱子位置,
定义坐标系
(x, y) x 正向右, y 正向下
比如 player 在 (x, y) 右移 并推动了箱子, 记录为 R, 移动后, player 的位置到了 (x+1, y), 也必有一个箱子从 (x+1, y) 被推动到了(x+2, y)
要回退这一次移动时, player 位置必在 (x+1, y), 需要把 player 回退到 (x, y), 因为记录是大写字母, 所以知道肯定有箱子被推动过了, 因为是向右推的, 所以那个箱子一定在 (x+2, y), 就把它还原到 (x+1, y) 即可
而如果 记录是 r 时, 小写字母表示没有推动过箱子, 那么只把 player 位置 回退到 (x, y) 即可.
作者: aa77dd@163.com 时间: 2016-9-5 15:24
本帖最后由 aa77dd@163.com 于 2016-9-5 19:25 编辑
不用字母而用数字 0 1 2 3 表示 上 下 左 右
如果推动了箱子, 就把数值 加上 4, 即, 4 5 6 7
在分析 记录 时, 设 t 为记录值 ,
t & 3 就得到方向,
t & 2 == 0 是纵向, 否则是横向
t & 1 == 1 是正向(右或者下), 否则是负向(左或者上)
t & 4 == 0 表示没有动箱子, 否则是动了箱子的
换言之, 就是用三个二进制位表示三种信息, 是否有动箱子, 是纵向还是横向, 是正向还是负向- @echo off
- <nul set /p "=[]"
- echo;
- pause
复制代码
作者: happy886rr 时间: 2016-9-5 16:35
回复 7# aa77dd@163.com
多谢大师指点。但是我觉得其实只用u d l r 这个四个表示 上 下 左 右就足够了,没必要U,DLR大写或正负步的支援。因为我可以用提前保存之前的地图数据。
比如我先保留了某刻的地图数据MapDataTemp,之后我又走了10步,这10步只用u d l r四个表示即可,因为这10步完全可以由先前的地图数据MapDataTemp只经过上、下、左、右、重现出来。
也就是说我没有必要根据现在的情况去推断上一步的情况,我可以提前保留之前的整张图数据,然后根据记录下的上、下、左、右交给批处理的数据处理部分(而不是choice.exe)重新走出来这几步,因此这几步仅仅只需二进制的00,01,10,11这四种表示,我选择0到F的16进制,那么一个16进制有4位,就可以表示两个走步,就实现了一个字符表示两步。txt一行能容纳1000多字符,也就是一行就能存下2000多步。比用大小写最少要节约30%~50%,而且还实现了走步回放。
作者: happy886rr 时间: 2016-9-11 22:18
回复 3# 523066680
感谢建议,已加入计步器
作者: happy886rr 时间: 2016-9-11 22:19
回复 2# codegay
3.0版已加入重玩本关。还有自动化脚本。
作者: asdfghjkl;' 时间: 2020-1-18 14:26
前两关为何自动?
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |