标题: [其他] 五子棋(不用输入坐标) [打印本页]
作者: 嘟嘟猪 时间: 2008-10-1 21:16 标题: 五子棋(不用输入坐标)
可以直接用w,a,s,d控制坐标
但需要choice命令,choice下载地址:http://www.bathome.net/thread-1726-1-1.html
还未加入判断输赢的功能- @echo off
- title 五子棋单机版
- color 60
- mode con: cols=34 lines=18
- setlocal enabledelayedexpansion
- set f1t1=└
- set f16t1=┘
- set f1t16=┌
- set f16t16=┐
- FOR /L %%e IN (2,1,15) DO set f%%et1=┴
- FOR /L %%f IN (2,1,15) DO set f1t%%f=├
- FOR /L %%g IN (2,1,15) DO set f16t%%g=┤
- FOR /L %%h IN (2,1,15) DO set f%%ht16=┬
- FOR /L %%i IN (2,1,15) DO (
- FOR /L %%j IN (2,1,15) DO set f%%it%%j=┼
- )
- set xzh=8
- set xzz=8
- set noo=黑
- set er=a
- :xs
- cls
- echo %f1t16%%f2t16%%f3t16%%f4t16%%f5t16%%f6t16%%f7t16%%f8t16%%f9t16%%f10t16%%f11t16%%f12t16%%f13t16%%f14t16%%f15t16%%f16t16%
- echo %f1t15%%f2t15%%f3t15%%f4t15%%f5t15%%f6t15%%f7t15%%f8t15%%f9t15%%f10t15%%f11t15%%f12t15%%f13t15%%f14t15%%f15t15%%f16t15%
- echo %f1t14%%f2t14%%f3t14%%f4t14%%f5t14%%f6t14%%f7t14%%f8t14%%f9t14%%f10t14%%f11t14%%f12t14%%f13t14%%f14t14%%f15t14%%f16t14%
- echo %f1t13%%f2t13%%f3t13%%f4t13%%f5t13%%f6t13%%f7t13%%f8t13%%f9t13%%f10t13%%f11t13%%f12t13%%f13t13%%f14t13%%f15t13%%f16t13%
- echo %f1t12%%f2t12%%f3t12%%f4t12%%f5t12%%f6t12%%f7t12%%f8t12%%f9t12%%f10t12%%f11t12%%f12t12%%f13t12%%f14t12%%f15t12%%f16t12%
- echo %f1t11%%f2t11%%f3t11%%f4t11%%f5t11%%f6t11%%f7t11%%f8t11%%f9t11%%f10t11%%f11t11%%f12t11%%f13t11%%f14t11%%f15t11%%f16t11%
- echo %f1t10%%f2t10%%f3t10%%f4t10%%f5t10%%f6t10%%f7t10%%f8t10%%f9t10%%f10t10%%f11t10%%f12t10%%f13t10%%f14t10%%f15t10%%f16t10%
- echo %f1t9%%f2t9%%f3t9%%f4t9%%f5t9%%f6t9%%f7t9%%f8t9%%f9t9%%f10t9%%f11t9%%f12t9%%f13t9%%f14t9%%f15t9%%f16t9%
- echo %f1t8%%f2t8%%f3t8%%f4t8%%f5t8%%f6t8%%f7t8%%f8t8%%f9t8%%f10t8%%f11t8%%f12t8%%f13t8%%f14t8%%f15t8%%f16t8%
- echo %f1t7%%f2t7%%f3t7%%f4t7%%f5t7%%f6t7%%f7t7%%f8t7%%f9t7%%f10t7%%f11t7%%f12t7%%f13t7%%f14t7%%f15t7%%f16t7%
- echo %f1t6%%f2t6%%f3t6%%f4t6%%f5t6%%f6t6%%f7t6%%f8t6%%f9t6%%f10t6%%f11t6%%f12t6%%f13t6%%f14t6%%f15t6%%f16t6%
- echo %f1t5%%f2t5%%f3t5%%f4t5%%f5t5%%f6t5%%f7t5%%f8t5%%f9t5%%f10t5%%f11t5%%f12t5%%f13t5%%f14t5%%f15t5%%f16t5%
- echo %f1t4%%f2t4%%f3t4%%f4t4%%f5t4%%f6t4%%f7t4%%f8t4%%f9t4%%f10t4%%f11t4%%f12t4%%f13t4%%f14t4%%f15t4%%f16t4%
- echo %f1t3%%f2t3%%f3t3%%f4t3%%f5t3%%f6t3%%f7t3%%f8t3%%f9t3%%f10t3%%f11t3%%f12t3%%f13t3%%f14t3%%f15t3%%f16t3%
- echo %f1t2%%f2t2%%f3t2%%f4t2%%f5t2%%f6t2%%f7t2%%f8t2%%f9t2%%f10t2%%f11t2%%f12t2%%f13t2%%f14t2%%f15t2%%f16t2%
- echo %f1t1%%f2t1%%f3t1%%f4t1%%f5t1%%f6t1%%f7t1%%f8t1%%f9t1%%f10t1%%f11t1%%f12t1%%f13t1%%f14t1%%f15t1%%f16t1%
- title 用w,a,s,d键控制方向,按f下%noo%棋
- choice /c wasdf /n
- set tmmp=%errorlevel%
- if %er%==a goto ere
- if %xzh%==1 (
- if %xzz%==16 set f%xzh%t%xzz%=┌
- )
- if %xzh%==1 (
- if %xzz%==1 set f%xzh%t%xzz%=└
- )
- if %xzh%==16 (
- if %xzz%==1 set f%xzh%t%xzz%=┘
- )
- if %xzh%==16 (
- if %xzz%==16 set f%xzh%t%xzz%=┐
- )
- if %xzh%==1 (
- if %xzz% leq 15 (
- if %xzz% geq 2 set f%xzh%t%xzz%=├
- )
- )
- if %xzh%==16 (
- if %xzz% leq 15 (
- if %xzz% geq 2 set f%xzh%t%xzz%=┤
- )
- )
- if %xzz%==16 (
- if %xzh% leq 15 (
- if %xzh% geq 2 set f%xzh%t%xzz%=┬
- )
- )
- if %xzz%==1 (
- if %xzh% leq 15 (
- if %xzh% geq 2 set f%xzh%t%xzz%=┴
- )
- )
- if %xzz% leq 15 (
- if %xzh% leq 15 (
- if %xzz% geq 2 (
- if %xzh% geq 2 set f%xzh%t%xzz%=┼
- )
- )
- )
- :ere
- if %tmmp% neq 5 (
- if %tmmp%==1 set /a xzz=%xzz%+1&set er=s
- if %tmmp%==2 set /a xzh=%xzh%-1&set er=s
- if %tmmp%==3 set /a xzz=%xzz%-1&set er=s
- if %tmmp%==4 set /a xzh=%xzh%+1&set er=s
- )
- if %tmmp%==5 (
- if %noo%==黑 (
- set er=a
- set f%xzh%t%xzz%=●
- set noo=白
- goto xs
- )
- if %noo%==白 (
- set er=a
- set f%xzh%t%xzz%=○
- set noo=黑
- goto xs
- )
- )
- if %noo%==黑 set f%xzh%t%xzz%=¤
- if %noo%==白 set f%xzh%t%xzz%=¤
- goto xs
复制代码
[ 本帖最后由 嘟嘟猪 于 2008-10-1 22:05 编辑 ]
作者: pusofalse 时间: 2008-10-1 21:24
棋盘可以简化为:- for /l %%a in (16 -1 1) do (
- for /l %%i in (1 1 16) do (
- set/p=!f%%it%%a!<nul
- )
- echo.
- )
复制代码
另,指出一处小BUG:下过棋子的地方还能再下。
比如在坐标12处下过黑棋,再次移动到12处时,又可以下白棋。
还是说游戏的规则中可以这样玩?
[ 本帖最后由 pusofalse 于 2008-10-1 21:34 编辑 ]
作者: wxcute 时间: 2008-10-1 22:02
很不错,改进下就好玩了。
还有闪得挺厉害。
作者: 嘟嘟猪 时间: 2008-10-1 22:03 标题: 回复 2楼 的帖子
简化后棋盘显示较慢,还是我的电脑配置低
作者: pusofalse 时间: 2008-10-1 22:10
感觉从理论上来说set/p=<nul是比直接echo要慢,但如果效率差异过于明显,就要考虑是否是配置问题了~
争取改成精品~~^_^
作者: leoboy123 时间: 2008-10-1 22:11
期待成品.
大作啊!
作者: 嘟嘟猪 时间: 2008-10-1 22:18 标题: 感谢大家的鼓励
不过我国庆总共才放4天,作业有很多,可能不能花时间改进了,成品将会在寒假出炉
作者: lixiaodaoaaa 时间: 2008-10-2 03:08 标题: 确实非常厉害。。呵呵
。问下,如何改进成可以连机对打。那就很厉害了
能不能双人控制
或者和机器对战。。呵呵。就牛比的不得了了
不过能做出这样的作品,很不错了‘
疯狂的顶一下
作者: batman 时间: 2008-10-2 09:48
确实还有不少问题,建议楼主首先在代码简洁上多下点功夫,还有其实写电脑自己下比双人对弈要困难多了,楼主可去尝试写一下,不过不要过于投入,这东西太费脑力了。
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |