[原创]中国象棋源码(主要实现自动走)

中国象棋

中国象棋简介:

作者:梁飞(网名:o_o)

本程序为BAS通用版游戏(未用199以外PEEK地址值)

这是一个测试版游戏,
由于程序源码8k大的限制,(>8k的程序运行很慢)
还有些功能未写完.


已有功能:


所有象棋棋规限制:
车炮直走,马踩日,象飞田,士斜插,将兵单移;
兵不退,将士限九宫,飞象不过河;
象田心蹩脚,马日边蹩脚,车炮不隔棋走棋,炮隔棋吃棋,将不空对帅,不吃自方棋。。。


当在棋规的限制下:
所选棋走法唯一时,电脑自动走好;
无路可走时,自动返回重新选棋。


使用双光标:
双方各控制一个移动光标,
移动时互不影响。
各控制键均可自行修改设定。


去掉的功能:
车马炮的自动走(很少用到)
滚动双屏模式(不好观棋)
快捷吃棋功能
如:(被删掉的“马走法唯一自动走”程序段)

890 .....ON K GOTO 1200,1300,1310,1500,1500,1500,1210
改成:
890 .....ON K GOTO 1200,1300,1310,1400,1500,1500,1210
在程序相应位置加入:
1400 Z=(P<10)*(Z(P+1,Q)=8):E=Z*(Q>2)*(B*Z(P+2,Q-1)<=8*B):F=Z*(Q<10)*(B*Z(P+2,Q+1)<=8*B)
1410 Z=(P>3)*(Z(P-1,Q)=8):G=Z*(Q>2)*(B*Z(P-2,Q-1)<=8*B):H=Z*(Q<10)*(B*Z(P-2,Q+1)<=8*B)
1420 Z=(Q<9)*(Z(P,Q+1)=8):I=Z*(P>2)*(B*Z(P-1,Q+2)<=8*B):J=Z*(P<11)*(B*Z(P+1,Q+2)<=8*B)
1430 Z=(Q<9)*(Z(P,Q-1)=8):M=Z*(P>2)*(B*Z(P-1,Q-2)<=8*B):N=Z*(P<11)*(B*Z(P+1,Q-2)<=8*B)
1440 Z=E+F+G+H+I+J+M+N:IF Z=0 THEN 800
1450 IF Z=1 THEN P=P+J+N+2*E+2*F-I-M-2*G-2*H:Q=Q+F+H+2*I+2*J-E-G-2*M-2*N:1600
但加上上面的代码后,源程序长度超过了8K,速度非常慢了。


未写完功能:
将军提示;
自杀提示;
绝杀判定(现在需把对方老将吃掉才判胜)。


PEEK使用:
①2000 POKE 199,0
2020 WHILE PEEK(199)=0
(也可删掉POKE 199,0 改为 WHILE PEEK(199)<128)
作用:用于当有按键时跳出WHILE循环。
②2270 ...POKE 199,141:INPUT "存档…";K$...
替换原来的:
2270 ...PRINT "存档…";...
作用:解决INPUT输入汉字后,后面的PRINT出乱码现象。(NC1020型)


各控制键和下法可按F3键查看帮助。


"中国象棋.BAS"是主程序;
"XQDATA.BAS.DAT"是数据文件。
(中间的.BAS后缀是为了上传所用)

源代码注释:

1 REM 作者:梁飞(网名:o_o)
10 CLEAR:DIM Z(13,12),L$(21),N$(2),P(4),Q(4),D(21) //定义数组
20 GRAPH:OPEN "XQ-FILE" FOR RANDOM AS #1 LEN=91:FIELD#1,1 AS I$,90 AS J$ //打开数据文件
30 GET#1,12:FOR E=1 TO 21:D(E)=ASC(MID$(J$,E+68,1)):L$(E)=MID$(J$,2*E-1,2):NEXT //读取各控制键D(1)--D(21)
50 K=16:GOSUB 2000:D=ASC(INKEY$):IF D=32 THEN Z=0:120 //开始动画(若按空格键跳过选择框)
100 K=20:GOSUB 2100:IF Z THEN 190 ELSE K=13:GOSUB 2300
120 GOSUB 160:GET#1,Z+1:B=ASC(I$)-0.5:GOTO 250 //选棋局
160 GET#1,14:N$(1)=MID$(J$,6*Z+1,6):GET#1,15:N$(2)=MID$(J$,6*Z+1,6):RETURN
170 K=I+13:GOSUB 2300:K$=RIGHT$(N$(I),4):GOSUB 2250:N$(I)=Z$(Z)+Z$ //换人,选人头及输名称
180 LSET I$=CHR$(Z):LSET J$=N$(I):PUT#1,I+13:RETURN
190 Z=0:GOSUB 160:K=19:GOSUB 2100:IF Z=0 THEN I=1:GOSUB 170:I=2:GOSUB 170
200 K=21:GOSUB 2100:B=Z-0.5:GET#1,1
250 CLS:LOCATE 3,8:PRINT "载入…":E=0:FO=0:P(1)=4:Q(1)=6:P(2)=9:Q(2)=6:LH=0 //载入数据及初始化
280 FOR P=2 TO 11:FOR Q=2 TO 10:E=E+1:Z(P,Q)=ASC(MID$(J$,E,1)):NEXT:NEXT
300 CLS:PRINT RIGHT$(N$(1),4),LEFT$(N$(1),2),"F3:","帮助" //画棋盘
310 LOCATE 1,17:PRINT RIGHT$(N$(2),4):LOCATE 2,19:PRINT LEFT$(N$(2),2)
320 LINE 39,31,57,49:LINE 39,49,57,31:LINE 102,31,120,49:LINE 102,49,120,31
330 FOR E=39 TO 111 STEP 18:BOX E,4,E+9,76:NEXT
340 FOR E=4 TO 76 STEP 9:LINE 39,E,75,E:LINE 84,E,120,E:NEXT:LK=1:LJ=0
350 FOR P=2 TO 11:FOR Q=2 TO 10:IF Z(P,Q)=8 GOTO 450 //初始化各棋子
400 X=9*P+21:Y=9*Q-14:CIRCLE X,Y,4,1,1:IF Z(P,Q)>8 THEN CIRCLE X,Y,3,1,0
420 ON Z(P,Q)GOTO 500,520,540,560,580,600,620,750,510,530,550,570,590,610,630
450 NEXT:NEXT:LK=0:GOSUB 991:GOSUB 992:GOTO 750
500 P(3)=P:Q(3)=Q:LINE X-3,Y-1,X+3,Y-1,0:LINE X-2,Y-3,X+3,Y+2,0:LINE X+2,Y-3,X-3,Y+2,0 //500--630画14种棋子
501 LINE X-3,Y,X+3,Y:LINE X,Y+1,X,Y+4,0:LINE X-2,Y+3,X+1,Y+3,0:GOTO 700
510 P(4)=P:Q(4)=Q:LINE X-1,Y+2,X,Y+2:LINE X-2,Y+1,X+2,Y+1:DRAW X+3,Y+2
511 LINE X-2,Y-1,X+3,Y-1:BOX X-1,Y-2,X+1,Y:GOTO 700
520 LINE X+1,Y-3,X+1,Y+3,0:LINE X-1,Y,X+3,Y,0:LINE X-2,Y-2,X-2,Y+2,0:GOTO 700
530 LINE X,Y-2,X,Y+2:LINE X+2,Y-1,X+2,Y+1:LINE X-2,Y,X+2,Y:GOTO 700
540 LINE X-4,Y,X-1,Y,0:LINE X+2,Y-3,X+2,Y+3,0:LINE X-3,Y+2,X+2,Y-3,0:LINE X+4,Y-1,X+4,Y+1,0
541 LINE X+1,Y+2,X+1,Y+3,0:LINE X-1,Y+2,X-1,Y+3,0:LINE X-4,Y-1,X-2,Y-3,0
542 LINE X+1,Y,X+3,Y,0:LINE X-2,Y-1,X-1,Y-2,0:DRAW X+3,Y-2,0:DRAW X+1,Y-3,0:GOTO 700
550 LINE X-1,Y,X-1,Y+3:LINE X-2,Y+1,X+2,Y+1:LINE X,Y+2,X+1,Y+3:DRAW X+1,Y
551 BOX X-2,Y-2,X+2,Y-1:GOTO 700
560 DRAW X+3,Y-2,0:BOX X,Y-1,X+3,Y+1,0,0:LINE X-3,Y+2,X,Y+2,0:LINE X-2,Y-2,X-2,Y,0
561 DRAW X-3,Y+1,0:GOTO 700
570 BOX X-2,Y-1,X,Y+1:LINE X,Y-2,X+2,Y-2:LINE X+1,Y,X+1,Y+2:DRAW X-2,Y+2:DRAW X+2,Y-1
571 GOTO 700
580 LINE X+2,Y-3,X+2,Y+3,0:LINE X,Y-2,X,Y+2,0:LINE X-2,Y-3,X-2,Y+3,0:LINE X+1,Y,X-3,Y,0
581 DRAW X+3,Y-1,0:DRAW X+1,Y-2,0:GOTO 700
590 LINE X-2,Y-2,X-2,Y+3:LINE X,Y-1,X,Y+2:LINE X+2,Y-2,X+2,Y+2:DRAW X-3,Y+1
591 LINE X-2,Y,X+3,Y:DRAW X-1,Y+2:GOTO 700
600 LINE X-1,Y-2,X+3,Y-2,0:LINE X-3,Y-1,X-2,Y-1,0:LINE X+1,Y-1,X+3,Y+1,0:DRAW X-1,Y+1,0
601 BOX X,Y+1,X+2,Y+3,0,0:DRAW X+2,Y-3,0:DRAW X-2,Y-3,0:LINE X-2,Y+1,X-2,Y+3,0:GOTO 700
610 LINE X-4,Y+2,X+1,Y+2:LINE X+1,Y+1,X+2,Y+1:LINE X-2,Y-1,X+2,Y-1
611 DRAW X-1,Y+3:DRAW X+2,Y+3:LINE X-2,Y+1,X-1,Y:LINE X-1,Y-2,X,Y-2:DRAW X+2,Y-2:GOTO 700
620 LINE X+2,Y-3,X+2,Y+3,0:LINE X-2,Y+3,X-2,Y-3,0:LINE X,Y-3,X+3,Y,0:LINE X-1,Y,X+1,Y+2,0
621 DRAW X,Y-1,0:DRAW X,Y+3,0:DRAW X-3,Y,0:GOTO 700
630 LINE X-1,Y-2,X-1,Y+2:LINE X+1,Y-2,X+1,Y+3:LINE X-3,Y,X-2,Y+1:DRAW X,Y+2
631 DRAW X,Y:LINE X+2,Y+1,X+3,Y+2:LINE X+2,Y-1,X+3,Y-2
700 IF LK GOTO 450 //判定是否处于初始化状态
710 IF LJ=0 GOTO 720 //判定是否处于悔棋状态
711 IF LJ=1 AND KJ<>8 THEN LJ=2:P=RP:Q=RQ:Z(P,Q)=KJ:400 //悔棋时,若有吃棋,恢复所吃棋。
715 GOSUB 990:GOSUB 991:LJ=0
720 GOSUB 992:B=-B
750 GOSUB 990:P=P(1.5+B):Q=Q(1.5+B):GOSUB 990:GOTO 810
800 BEEP
810 LOCATE 2,3:PRINT L$(12+8*B):LOCATE 2,17:PRINT L$(12-8*B):LQ=0:GOSUB 1100 //显示举手,GOSUB1100读键
850 Z=0:K=Z(P,Q)-8*B-4:IF K<1 OR K>7 THEN 800 //未选中自方棋重选
860 FOR E=P(3)+1 TO P(4)-1:Z=Z+(Z(E,Q(3.5-B))<>8):NEXT
870 IF K>1 THEN C=(Q(3)=Q(4))*(Q=Q(3))*(P>P(3))*(P<P(4))*(Z=1):IF(K<5)*(C<>0) THEN 800 //判定走棋后是否对将是C=1否C=0
880 LOCATE 2,10+14*B:PRINT L$(Z(P,Q))
890 W=P:V=Q:LJ=0:LQ=1:ON K GOTO 1200,1300,1310,1500,1500,1500,1210 //跳转到各自的走法(顺序:将士象马车炮兵)
900 GOSUB 992:GOSUB 990:P(1.5-B)=RW:Q(1.5-B)=RV:IF LQ THEN GOSUB 993 //悔棋子程序
910 W=RP:V=RQ:FO=FO-1:P=RW:Q=RV:Z(P,Q)=KI:LJ=1:LH=0:GOTO 1900
990 X=P:Y=Q:GOTO 995 //画光标子程序
991 X=P(1.5+B):Y=Q(1.5+B):GOTO 995
992 X=P(1.5-B):Y=Q(1.5-B):GOTO 995
993 X=W:Y=V
995 X=9*X+17:Y=9*Y-18:BOX X,Y,X+8,Y+8,1,2:RETURN
1000 D=ASC(INKEY$):D=D-(D-31)*(D=D(21)):IF(D>26)*(D<31)+(D=31)*(LH=1)THEN 1030 //所有读键共用子程序
1010 B=-B:GOSUB 1140:B=-B:IF DA+DB+DC+DD THEN 1050
1020 RETURN
1030 POP:POP:P(1.5+B)=P:Q(1.5+B)=Q:ON D-26 GOTO 2500,2530,2550,2400,900
1050 GOSUB 992:P(1.5-B)=P(1.5-B)+DA-DB:P(1.5-B)=P(1.5-B)-(P(1.5-B)>11)*10+(P(1.5-B)<2)*10
1060 Q(1.5-B)=Q(1.5-B)+DC-DD:Q(1.5-B)=Q(1.5-B)-(Q(1.5-B)>10)*9+(Q(1.5-B)<2)*9:GOSUB 992
1070 GOTO 1000
1100 GOSUB 990:GOSUB 1000:GOSUB 990:GOSUB 1140 //光标移动及选定读键子程序
1110 P=P+DA-DB:Q=Q+DC-DD:P=P-(P>11)*10+(P<2)*10:Q=Q-(Q>10)*9+(Q<2)*9:IF D<>D(1.5+B)THEN 1100
1120 RETURN
1140 DA=(D=D(3.5+B)):DB=(D=D(5.5+B)):DC=(D=D(7.5+B)):DD=(D=D(9.5+B)):RETURN
1150 GOSUB 1000:RETURN
1200 C=(Z=1)*(Q(3)=Q(4))*(Z(P-2*B,Q(3))<>8):E=(B<0)*C //将的自动走算法
1201 F=(B>0)*C:G=(Z=0)*(Q(3.5+B)=Q(3.5-B)-1):H=(Z=0)*(Q(3.5+B)=Q(3.5-B)+1)
1205 E=(E=0)*(P<7.5+7*B):F=(F=0)*(P>5.5+7*B):G=(G=0)*(Q<7):H=(H=0)*(Q>5):GOTO 1240
1210 C=(C=0)*((P>=6+2*B)*(P<=7+2*B)=0) //兵的自动走算法
1211 E=(B<0)*(P<11):F=(B>0)*(P>2)
1212 G=(Q<10)*C:H=(Q>2)*C
1240 E=E*(B*Z(P+1,Q)<=8*B):F=F*(B*Z(P-1,Q)<=8*B)
1245 G=G*(B*Z(P,Q+1)<=8*B):H=H*(B*Z(P,Q-1)<=8*B)
1250 ON E+F+G+H+1 GOTO 800,1290 //走法为0时,回800句重选棋,走法唯一跳过读键自动走
1260 GOSUB 1150:GOSUB 1140:IF D=D(1.5+B)THEN 810 //读键选定走棋方向(再次按确认键,取消选定)
1270 IF E*DA+F*DB+G*DC+H*DD=0 THEN 1260
1280 E=E*DA:F=F*DB:G=G*DC:H=H*DD
1290 P=P+E-F:Q=Q+G-H:GOTO 1600
1300 IF(Q<>6)THEN IF B*Z(6.5+7*B,6)<=8*B THEN P=6.5+7*B:Q=6:1600 ELSE 800 //士的自动走算法
1302 E=(B*Z(P-1,Q-1)<=8*B):F=(B*Z(P+1,Q-1)<=8*B)
1303 G=(B*Z(P-1,Q+1)<=8*B):H=(B*Z(P+1,Q+1)<=8*B):GOTO 1350
1310 E=(P>4.5+5*B)*(Q>2)*(Z(P-1,Q-1)=8)*(B*Z(P-2,Q-2)<=8*B) //象的自动走算法
1312 F=(P<8.5+5*B)*(Q>2)*(Z(P+1,Q-1)=8)*(B*Z(P+2,Q-2)<=8*B)
1313 G=(P>4.5+5*B)*(Q<10)*(Z(P-1,Q+1)=8)*(B*Z(P-2,Q+2)<=8*B)
1314 H=(P<8.5+5*B)*(Q<10)*(Z(P+1,Q+1)=8)*(B*Z(P+2,Q+2)<=8*B)
1350 ON E+F+G+H+1 GOTO 800,1390 //走法为0时,回800句重选棋,走法唯一跳过读键自动走
1360 GOSUB 1150:IF D=D(1.5+B)THEN 810 //读键选定走棋方向(再次按确认键,取消选定)
1370 DA=(D=D(11.5+B)):DB=(D=D(13.5+B)):DC=(D=D(15.5+B)):DD=(D=D(17.5+B))
1375 IF E*DA+F*DB+G*DC+H*DD=0 THEN 1360
1380 E=E*DA:F=F*DB:G=G*DC:H=H*DD
1390 P=P-E+F-G+H:Q=Q-E-F+G+H:IF K=3 THEN P=2*P-W:Q=2*Q-V
1395 GOTO 1600
1400---1490 //车马炮的自动走算法(写不下,删掉了)
1500 GOSUB 993
1505 GOSUB 1100:IF P=W AND Q=V THEN GOSUB 993:GOTO 810 //GOSUB1100读键选落棋位,在原位取消选定
1510 IF B*Z(P,Q)>8*B THEN GOSUB 993:GOTO 850 //落在自方棋上,取消原选定,直接改选落棋位上的棋(可能你选了车后,又想选其它棋,这样就不要回原位去取消选定了。
1520 IF K>4 GOTO 1550
1530 E=ABS(P-W):F=ABS(Q-V) //判定马的落的落棋位是否为日及蹩脚(通过Z=1否则Z=0)
1540 Z=((E=2)*(F=1)+(E=1)*(F=2))*(Z(W+(P=W+2)-(P=W-2),V+(Q=V+2)-(Q=V-2))=8):GOTO 1590
1550 E=SGN(P-W)+SGN(Q-V):F=0 :IF(P=W)*(C=0)+(Q=V)=0 GOTO 1505 //判定车炮是否直走及中间是否隔棋
1560 IF P=W AND ABS(Q-V)>1 THEN FOR H=V+E TO Q-E STEP E:F=F+(Z(P,H)<>8):NEXT
1570 IF Q=V AND ABS(P-W)>1 THEN FOR H=W+E TO P-E STEP E:F=F+(Z(H,Q)<>8):NEXT
1580 IF K=6 THEN Z=(F=1)*(Z(P,Q)<>8)*(C=0)+(F=0)*(Z(P,Q)=8)ELSE Z=(F=0)
1590 IF Z=0 GOTO 1505 //如果上面的判定不通过,则跳到1505重选落棋位
1600 FO=FO+1:IF Z(P,Q)=5-8*B GOTO 2560 //若吃到的棋为对方将军判胜!(所有走法合总到此)
1610 RP=P:RQ=Q:RW=W:RV=V:KI=Z(W,V):KJ=Z(P,Q):Z(P,Q)=KI:P(1.5+B)=P:Q(1.5+B)=Q:LH=1:GOSUB 992
1900 X=9*W+21:Y=9*V-14:BOX X-4,Y-4,X+4,Y+4,1,0:LINE X-4,Y,X+4,Y:LINE X,Y-4,X,Y+4 //删除原棋位棋子子程序
1910 Z(W,V)=8:E=(X=39)+(X=84)-(X=75)-(X=120):IF E THEN LINE X-E,Y,X-4*E,Y,0
1920 F=(Y=4)-(Y=76):IF F THEN LINE X,Y-F,X,Y-4*F,0
1930 E=(X=39)+(X=102)-(X=57)-(X=120):F=(Y=31)-(Y=49):IF E*F THEN LINE X,Y,X+4*E,Y+4*F
1940 IF(Y=40)*((X=48)+(X=111))THEN LINE X-4,Y+4,X+4,Y-4:LINE X-4,Y-4,X+4,Y+4
1950 GOTO 400 //整个程序到此循环到400画棋。
2000 POKE 199,0:GET#1,K:E=ASC(I$):CLS:PRINT " ",J$; //开始与结束动画
2010 BOX 11,12,148,66:BOX 4,5,155,73,E,E+1:BOX 10,7,149,10,1,2:BOX 10,68,149,71,1,2:X=0:Y=0
2020 WHILE PEEK(199)=0:X=X+1:X=X-5*(X>5):Y=(Y=0):E=32*Y+15:F=47-32*Y:G=13*X:H=28*X
2040 LINE 141-G,63,129-G,63,2:LINE 133-G,61,121-G,61,2
2050 BOX H-18,68,H+9,71,1,2:BOX 177-H,7,150-H,10,1,2:BOX 129,F,144,F+16,1,2
2060 BOX 6,G-6,9,G+6,1,2:BOX 150,84-G,153,72-G,1,2:BOX 15,E,31,E+16,1,2
2070 BOX 16*X+24,30,16*X+39,48,1,2:WEND:RETURN
2100 GET#1,K:I=ASC(I$):CLS:PRINT J$;:K=K-17 //双选框子程序
2105 IF K=2 OR K=4 THEN LOCATE K,3:PRINT N$(1):LOCATE K,13:PRINT N$(2)
2110 BOX 4,8,155,75,1,2:BOX 6,10,159,79,1,2:BOX 14,45,65,64,1,2:BOX 15,46,68,67,1,2
2120 BOX 94,45,145,64,1,2:BOX 95,46,148,67,1,2:Z=1
2130 FOR E=17 TO 63 STEP 2:DRAW E+Z*80,47:DRAW E+Z*80,63:NEXT:FOR E=48 TO 62 STEP 2
2140 DRAW 16+Z*80,E:DRAW 64+Z*80,E:NEXT:BOX 96-Z*80,47,144-Z*80,63,0,0
2160 GOSUB 2200:IF D=27 THEN IF I=3 THEN 2590 ELSE Z=I-1:2180
2170 ON(F=0)+(D=13)GOTO 2160,2180:Z=(Z=0):GOTO 2130
2180 BOX 16+Z*80,47,64+Z*80,63,0,0:BOX 16+Z*80,47,67+Z*80,66,1,2
2190 FOR E=1 TO 500:NEXT:RETURN
2200 D=ASC(INKEY$):F=(D=21)+(D=22)+(D=14)-(D=20)-(D=23)-(D=19):RETURN //双选框和多选框共用读键子程序
2220 BOX 19,15,128,79 //多选框的边框
2230 BOX 20,16*E-16,127,16*E-2,1,2:BOX 18,14,129,31
2240 BOX 132,15,150,32,1,2:BOX 131,14,149,31,0,2:RETURN
2250 TEXT:INPUT "名称:";Z$:IF Z$="" THEN Z$=K$:PRINT "用原名";K$:GOSUB 2190:GOSUB 2190 //输入为空保持原名(输入名称子程序)
2260 WHILE LEN(Z$)<4:Z$=Z$+" ":WEND:Z$=LEFT$(Z$,4):GRAPH //长度<4补空格,>4取前4个字节
2270 LOCATE 3,7:POKE 199,141:INPUT "存档…";K$:RETURN
//原来是LOCATE 3,7:PRINT "存档…":RETURN,改成这样是为了解决输入汉字,后面的PRINT出错问题。
2300 GET#1,K:F=4-2*(K>13):FOR E=0 TO 10:Z$(E)=MID$(J$,137-34*F+F*E,F):NEXT:Z=ASC(I$):CLS //多选框子程序
2310 LOCATE 2,4:PRINT "<";Z-1;"> ";Z$(Z);TAB (18);CHR$(31)+CHR$(31):W=Z:Q=Z:E=2:GOSUB 2230
2320 GOSUB 2200:ON(F=0)+(D=13)+2*(D=27)GOTO 2320,2360,2590:GOSUB 2220:Z=Z+F:E=E+F:V=E
2330 Z=Z+10*(Z<1)-10*(Z>10):E=E+(E<2)-(E>5):W=W+(E<V)-(E>V):W=W+10*(W<1)-10*(W>10)
2340 FOR P=2 TO 5:Q=W+P-2-10*(W>12-P):LOCATE P,4:PRINT "<";Q-1;"> ";Z$(Q);
2350 NEXT:GOSUB 2220:GOTO 2320
2360 RETURN
2400 CLS:K=27 //求助功能子程序
2420 GET#1,K:F=ASC(I$):PRINT J$;:LOCATE 1,9:LINE 1,14,159,14:LINE 146,15,146,79
2430 BOX 147,17,159,79,1,0:BOX 148,11*F+6,159,11*F+12,1:BOX 149,11*F+5,158,11*F+13,0,2
2450 D=ASC(INKEY$):IF D=27 THEN 300
2455 IF K=27 THEN K=28:2420
2460 Z=K:K=K+(F<6)*(D=21)-(F>1)*(D=20)+(7-F)*(D=22)-(F+5)*(D=23)+(D=13)
2470 K=K+18*(K<28):K=K-18*(K>45):IF K=Z THEN BEEP:2450 ELSE 2420
2500 K=23:GOSUB 2100:IF Z=0 THEN 300 //未下完跳出提示程序段
2510 K=22:GOSUB 2100 :IF Z=0 THEN 2600 ELSE 2590
2530 K=26:GOSUB 2100 :IF Z THEN 2600 ELSE 300
2550 K=25:GOSUB 2100 :IF Z THEN 200 ELSE 300
2560 CLS:GET#1,18:PRINT J$;:LOCATE 3,3:PRINT N$(1.5+B):LOCATE 2,13:PRINT FO //判胜显示
2570 LOCATE 4,13:PRINT N$(1.5-B):D=ASC(INKEY$)
2580 K=24:GOSUB 2100 :IF Z THEN 200
2590 K=17:GOSUB 2000:CLOSE#1:END //程序结束画面
2600 K=13:GOSUB 2300:K$=Z$(Z):GOSUB 2250:Z$(Z)=Z$ //存档子程序
2610 LSET I$=CHR$(Z):I=0:GOSUB 2650:I=1:GOSUB 2640:I=2:GOSUB 2640
2620 F$="":FOR P=2 TO 11:FOR Q=2 TO 10:F$=F$+CHR$(Z(P,Q)):NEXT:NEXT
2630 LSET I$=CHR$(B+0.5):LSET J$=F$:PUT#1,Z+1:GOTO 2590
2640 GET#1,I+13:FOR E=0 TO 10:Z$(E)=MID$(J$,6*E+1,6):NEXT:Z$(Z)=N$(I)
2650 F$="":FOR E=0 TO 10:F$=F$+Z$(E):NEXT:LSET J$=F$:PUT#1,I+13:RETURN
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值