- UID
- 3517
- 精华
- 积分
- 959
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
本帖最后由 套路 于 2019-7-21 18:24 编辑
批处理关灯益智游戏重制版
- @echo off
- title 关灯
- setlocal enabledelayedexpansion
- set x=5
- set y=4
- set c1=█
- set c2=□
- set c3=□
- set c4=□
- set n=0
- :main
- set "v0= "
- for /l %%k in (1,1,%x%) do (
- set v0=!v0! %%k)
- for /l %%i in (1,1,%y%) do (
- for /l %%o in (1,1,%x%) do (
- set a%%o%%i=□))
- set /a j=x*y
- set /a n1=%random% %% %j%
- set /a num=%n1%+2
- :rd
- if %n%==%num% (
- set /a n=0
- goto ec
- ) else (
- set /a n+=1
- set /a rx=!random! %% !x!
- set /a ry=!random! %% !y!
- set /a rx=!rx!+1
- set /a ry=!ry!+1
- call set a%rx%%ry%=█
- goto rd)
- :ec
- cls
- for /l %%t in (1,1,%y%) do (
- for /l %%e in (1,1,%x%) do (
- if not !a%%e%%t!==□ (goto nx)))
- goto win
- :nx
- echo 关灯游戏规则:将所有█变成□
- for /l %%p in (1,1,%y%) do (
- set v%%p= %%p
- for /l %%u in (1,1,%x%) do (
- set "v%%p=!v%%p! !a%%u%%p!
- ))
- for /l %%r in (0,1,%y%) do (
- echo !v%%r!)
- echo 请输入坐标(都为0进入设置)
- set /p gx=列数:
- set /p gy=行数:
- if %gx%==0 if %gy%==0 (goto st)
- set /a gxc=gx+0
- set /a gyc=gy+0
- if %gx% lss 1 (goto error)
- if %gx% gtr %x% (goto error)
- if %gy% lss 1 (goto error)
- if %gy% gtr %y% (goto error)
- if %gx% neq %gxc% (goto error)
- if %gy% neq %gyc% (
- :error
- echo 错误:输入数字错误
- pause
- cls
- goto nx
- )
- cls
- goto cl
- :cl
- if !a%gx%%gy%!==□ (call set a%gx%%gy%=█) else (call set a%gx%%gy%=□)
- set /a cx1=gx+1,cx0=gx-1,cy1=gy+1,cy0=gy-1
- if %gx%==1 (
- if !a%cx1%%gy%!==□ (call set a%cx1%%gy%=█) else (call set a%cx1%%gy%=□)
- )
- if %gx%==%x% (
- if !a%cx0%%gy%!==□ (call set a%cx0%%gy%=█) else (call set a%cx0%%gy%=□)
- )
- if %gy%==1 (
- if !a%gx%%cy1%!==□ (call set a%gx%%cy1%=█) else (call set a%gx%%cy1%=□)
- )
- if %gy%==%y% (
- if !a%gx%%cy0%!==□ (call set a%gx%%cy0%=█) else (call set a%gx%%cy0%=□)
- )
- if not %gx%==1 if not %gx%==%x% (
- if !a%cx1%%gy%!==□ (call set a%cx1%%gy%=█) else (call set a%cx1%%gy%=□)
- if !a%cx0%%gy%!==□ (call set a%cx0%%gy%=█) else (call set a%cx0%%gy%=□)
- )
- if not %gy%==1 if not %gy%==%y% (
- if !a%gx%%cy1%!==□ (call set a%gx%%cy1%=█) else (call set a%gx%%cy1%=□)
- if !a%gx%%cy0%!==□ (call set a%gx%%cy0%=█) else (call set a%gx%%cy0%=□)
- )
- goto ec
- :st
- cls
- echo.
- echo. 游戏难度:
- echo. %c1%.普通[1]
- echo. %c2%.中等[2]
- echo. %c3%.困难[3]
- echo. %c4%.自定义[4]
- echo. ...返回[5]
- echo.
- set /p gs=请输入数字:
- set /a gsc=gs+0
- if %gs% lss 1 (goto error2)
- if %gs% gtr 5 (goto error2)
- if %gs% neq %gsc% (
- :error2
- echo 错误:输入数字错误
- pause
- goto st
- )
- if %gs%==5 (
- goto main
- )
- if %gs%==1 if %c1%==□ (
- set c1=█
- set c2=□
- set c3=□
- set c4=□
- set x=5
- set y=4
- goto st
- )
- if %gs%==2 if %c2%==□ (
- set c2=█
- set c1=□
- set c3=□
- set c4=□
- set x=7
- set y=6
- goto st
- )
- if %gs%==3 if %c3%==□ (
- set c3=█
- set c1=□
- set c2=□
- set c4=□
- set x=10
- set y=10
- goto st
- )
- if %gs%==4 (
- set c4=█
- set c1=□
- set c2=□
- set c3=□
- echo 请输入自定义行列数
- set /p x=列数:
- set /p y=行数:
- set /a xc=!x!+0
- set /a yc=!y!+0
- if !x! lss 3 (goto error3)
- if !y! lss 3 (goto error3)
- if !x! neq !xc! (goto error3)
- if !y! neq !yc! (
- :error3
- echo 错误:输入数字错误[注:最小不能小于3]
- pause
- set x=5
- set y=4
- cls
- goto st
- )
- goto st
- )
- goto st
- :win
- echo.
- echo.
- echo.
- echo 你赢了
- pause
- goto main
复制代码
...自定义列数大于10坐标数就对不准...不过也不会也没有人设置怎么高折磨自己吧。
游戏规则:点击一个方块,自身和附近方块会变成另一种颜色,当所有方块都为□时游戏胜利。
例如点击下方中间方块,如图变化。
□ □ □ □ █ □
□ █ □ --→ █ □ █
□ □ □ □ █ □
可惜bat没有自定义GUI,不然可以实现点击方块更加还原了(其实时懒得换一个语言)
游戏搬运于mc服务器hypixel的某个角落:
|
|