『楼 主』:
人机对战游戏 [天罗地网]
这个代码不是我的原创,只是修改了别人的为我所用,研究代码的技巧,用你的轮造我之车。
从中学习和提高自己! 并感谢五子棋的作者!! 以下代码是个游戏,我取名叫“天罗地网”
胜利者请报个到...!
@echo off
::增加了难度
mode con cols=70 lines=14
title 走迷宫-天罗地网 QQ:251485609 by 2009.1 今天:%date%
setlocal enabledelayedexpansion
color 72
:fh
echo.
echo 游戏 [ 天罗地网 ]
echo.
echo 游戏规则:从棋盘中任意点出发,依次到达相对的两个边框后(每步前后
echo.
echo 必须相连不跳步),再返回原地出发点就算胜利!
echo.
echo (途中后有追兵前有堵击,你就等着瞧吧...)
echo.
echo 1、玩家先出发 2、追击方先堵击
echo.
echo QQ:251485609
set /p wjh= 请玩家选择:
if not "%wjh%" equ "1" if not "%wjh%" equ "2" cls&echo 错误!&pause&cls&goto fh
:dxz
echo.
echo 1、普通型 2、增加难度
echo.
set /p ndxz= 选择难度:
if not "%ndxz%" equ "1" if not "%ndxz%" equ "2" cls&echo 错误!&pause&cls&goto dxz
cls
mode con cols=80 lines=68
:: 定义图形界面中的启始变量
set 纵轴=B C D E F G H I J K L M N O P Q R
for %%i in (a %纵轴% S) do (
set /a n+=1
set zc1%%i=!n!
)
set n=
for %%i in (a %纵轴% S) do (
set /a n+=1
set zc2!n!=%%i
)
:tx
for %%i in (a %纵轴% S) do (
for /l %%j in (1,1,19) do (
set we%%i%%j=*
)
)
set A1=┏
set A19=┓
set S1=┗
set S19=┛
for /l %%i in (2,1,18) do set a%%i=┳
for /l %%i in (2,1,18) do set S%%i=┻
for %%i in (%纵轴%) do set %%i1=┣&set %%i19=┫
for %%i in (%纵轴%) do (
for /l %%j in (2,1,18) do (
set %%i%%j=╋
)
)
set sos=1
set bls=
call:txcx
::以上产生启始图形界面
::以下为交替程序
:hq
if "%wjh%"=="2" call:dn ● &goto bq
set /p ts= (输入时先字母后数字:如F6) 第%sos%手,请●方输入
if /i "%ts%"=="cxks" goto tx
if "!we%ts%!"=="*" (
set %ts%=●
set we%ts%=a
set /a sos+=1
set ss=%ts%
if "%sos%"=="1" set ss1=%ts%
) else (
echo 输入有误,请重新输入!
goto hq )
::刷新
call:txcx
:bq
if "%wjh%"=="1" call:dn ○ &goto hq
set /p ts= (输入时先字母后数字:如F6) 第%sos%手,请○方输入
if /i "%ts%"=="cxks" goto tx
if "!we%ts%!"=="*" (
set %ts%=○
set we%ts%=b
set /a sos+=1
set ss=%ts%
if "%sos%"=="2" set ss1=%ts%
) else (
echo 输入有误,请重新输入!
goto bq)
::刷新
call:txcx
goto hq
:txcx
::刷新棋盘
cls
echo 输入 cxks 重新开局
::写入顶行数字
set /p = <nul
for /l %%i in (1,1,8) do set /p=%%i <nul
for /l %%i in (9,1,19) do set /p=%%i <nul
echo.
::显示图形界面
for %%i in (A %纵轴%) do (
set /p =%%i<nul
for /l %%j in (1,1,18) do (
set /p =!%%i%%j!━<nul
)
echo !%%i19!
for /l %%j in (1,1,19) do (
set /p = ┃ <nul
)
echo.
)
set /p =S<nul
for /l %%i in (1,1,18) do set /p =!S%%i!━<nul
echo !S19!
::写入底行数字
set /p = <nul
for /l %%i in (1,1,8) do set /p=%%i <nul
for /l %%i in (9,1,19) do set /p=%%i <nul
echo.
::起点坐标判断
set zbwq=%ss1:~1,2%>nul 2>nul
set /a qzbq=%ss1:~1,2%-1>nul 2>nul
set /a hzbq=%ss1:~1,2%+1>nul 2>nul
set zmq=%ss1:~0,1%>nul 2>nul
set /a vr2q=zc1%zmq%-1>nul 2>nul
set /a vr1q=zc1%zmq%+1>nul 2>nul
set vr2q=!zc2%vr2q%!>nul 2>nul
set vr1q=!zc2%vr1q%!>nul 2>nul
::动态坐标判断
set zbw=%ss:~1,2%>nul 2>nul
set /a qzb=%ss:~1,2%-1>nul 2>nul
set /a hzb=%ss:~1,2%+1>nul 2>nul
set zm=%ss:~0,1%>nul 2>nul
set /a vr2=zc1%zm%-1>nul 2>nul
set /a vr1=zc1%zm%+1>nul 2>nul
set vr2=!zc2%vr2%!>nul 2>nul
set vr1=!zc2%vr1%!>nul 2>nul
if %sos% GTR 30 call:jszd
if %sos% GTR 30 call:jszd
goto :eof
::自动追击拦截
:dn
if %sos% equ 1 set ts=h8&goto wan
set pds=%ts%
set fy1=%pds:~0,1%
set fy2=%pds:~1%
:wa1
set /a ag1=zc1%fy1%+%random%%%3-%random%%%3
set ag2=!zc2%ag1%!
set /a fy=fy2+%random%%%3-%random%%%3
if "!we%ag2%%fy%!"=="*" (
set ts=%ag2%%fy%
if "%ndxz%"=="2" if %sos% GTR 50 call :dynq
)else goto wa1
:wan
set %ts%=%1
set we%ts%=%2
set /a sos+=1
set bls=%ts%
call:txcx
goto :eof
:dynq
if not "!%vr2%%ss:~1,2%!"=="╋" if not "!%zm%%qzb%!"=="╋" if not "!%zm%%hzb%!"=="╋" set ts=%vr1%%ss:~1,2%
if not "!%vr1%%ss:~1,2%!"=="╋" if not "!%zm%%qzb%!"=="╋" if not "!%zm%%hzb%!"=="╋" set ts=%vr2%%ss:~1,2%
if not "!%zm%%qzb%!"=="╋" if not "!%vr2%%zbw%!"=="╋" if not "!%vr1%%zbw%!"=="╋" set ts=%zm%%hzb%
if not "!%zm%%hzb%!"=="╋" if not "!%vr2%%zbw%!"=="╋" if not "!%vr1%%zbw%!"=="╋" set ts=%zm%%qzb%
goto :eof
::x左坐标%zm%%qzb% x右坐标%zm%%hzb% y上坐标%vr2%%ss:~1,2% y下坐标%vr1%%ss:~1,2%
::图形 !%zm%%qzb%! !%zm%%hzb%! !%vr2%%ss:~1,2%! !%vr1%%ss:~1,2%!
::胜利判断
:jszd
if "%ss%"=="%zmq%%qzbq%" goto wjsl
if "%ss%"=="%zmq%%hzbq%" goto wjsl
if "%ss%"=="%vr2q%%ss1:~1,2%" goto wjsl
if "%ss%"=="%vr1q%%ss1:~1,2%" goto wjsl
goto :eof
:wjsl
@echo off
mshta vbscript:createobject("sapi.spvoice").speak("wo, sheng, li, la,")(window.close)
@echo off
msg %username% / 第%sos%手,玩家胜利!记特等功一次。
增强版: 下载在第 14 楼。
完美版: 下载在第 16 楼。
人机对战游戏-跟踪追击 [天罗地网](自动进级完美版).bat : 下载在第 19 楼。 [ Last edited by ZJHJ on 2009-2-8 at 19:23 ]
此帖被 +21 点积分 点击查看详情 评分人:【 523066680 】 | 分数: +15 | 时间:2009-2-4 22:58 | 评分人:【 BC 】 | 分数: +2 | 时间:2009-2-4 23:53 | 评分人:【 wxcute 】 | 分数: +4 | 时间:2009-2-5 23:04 |
|
附件
1: 走迷宫-天罗地网.rar (2009-2-4 22:42, 1.83 K,下载次数: 26)
|