`
javatar
  • 浏览: 1700505 次
  • 性别: Icon_minigender_1
  • 来自: 杭州699号
社区版块
存档分类
最新评论

智能五子棋 (NC1020型用)

阅读更多
智能五子棋 (NC1020型用)
此算法是friday所写,棋力比我还好!
在文曲星NC1020这种超低能的运算力的板子上每步也不超过5秒

5 CLEAR:DIM IL(4,2,2),M(16,16),BSX(16),BSY(16),RECORD(255):ID=0:CP=0:TS=0
10 GRAPH:POKE 29943,255:POKE 1024,0
20 LOCATE 2,5:PRINT "LINK ⑤":LOCATE 3,5:PRINT " 载入..."
30 BOX 30,13,130,49
32 BOX 28,11,132,51
35 OPEN "INTLIB" FOR RANDOM AS1:M=LOF(1):CLOSE 1
40 IF M=0 THEN LOCATE 3,7:PRINT "没有文件":FOR C=1 TO 2000:NEXT:GOTO 58
50 OPEN "INTLIB" FOR INPUT AS1
55 FOR K=0 TO 4:FOR K2=0 TO 2:FOR K3=1 TO 2:INPUT#1,IL(K,K2,K3):NEXT:NEXT:NEXT
56 CLOSE 1
58 IF PEEK(199)=159 THEN CP=1
59 LOCATE 3,7:PRINT "电脑执黑"
60 FOR X=0 TO 16:M(0,X)=3:M(X,0)=3:M(16,X)=3:M(X,16)=3:NEXT
62 LTX=15:LTY=15:RTX=1:RTY=1
65 FOR X=1 TO 15:FOR Y=1 TO 15:M(X,Y)=0:NEXT:NEXT
74 CLS
75 BOX 41,0,119,78,0,2
80 BOX 42,1,118,77
100 FOR X=0 TO 14
120 LINE 52+X*4,12,X*4+52,67
125 LINE 52,11+X*4,108,11+X*4
130 LINE 108-X*4,12,108-X*4,67
135 LINE 52,67-X*4,108,67-X*4
140 NEXT
150 CIRCLE 23,20,7,1:CIRCLE 23,60,7
151 BOX 21,17,20,19,1,0:BOX 25,17,26,19,1,0:LINE 22,24,24,24,0
152 LINE 22,24,20,22,0:LINE 24,24,26,22,0
153 BOX 21,57,20,59:BOX 25,57,26,59:LINE 22,64,24,64
160 LINE 22,64,20,62:LINE 24,64,26,62
170 IF REP OR PEEK(199)=240 THEN 7000
180 I=INT(RND(6)*50)+30
190 FOR K=1 TO I
200 LOCATE 3,3
210 IF K/2=INT(K/2)THEN PRINT "" ELSE PRINT ""
220 NEXT
230 LOCATE 2,17:IF I/2=INT(I/2)THEN PRINT "黑":F=0 ELSE PRINT "白":F=1
235 LOCATE 4,17:PRINT "先"
240 X=80:Y=39
241 IF F=0 THEN M(8,8)=2:LTX=7:LTY=7:RTX=9:RTY=9:TS=1:RECORD(1)=800391
242 IF F=0 THEN BOX X-2,Y-2,X+2,Y+2,1:GOSUB 1000:F=(F=0):LOCATE 3,3:PRINT ""
245 BOX X-1,Y-1,X+1,Y+1,0,2
250 POKE 199,0:WHILE PEEK(199)<>241
255 POKE 199,0:WHILE PEEK(199)<>141 AND PEEK(199)<>241
260 P=PEEK(199)-128
261 IF P=-128 THEN 288
262 N=0:IF P=29 THEN POKE 199,0:GOTO 5
265 BOX X-1,Y-1,X+1,Y+1,0,2
270 X=X+(P=22)*4*(X<108)-(P=23)*4*(X>52)
275 IF M((X-46)/4,(Y-6)/4)AND X<108 AND X>52 AND(P=22 OR P=23)THEN 270
280 Y=Y+(P=21)*4*(Y<66)-(P=20)*4*(Y>12)
282 IF M((X-46)/4,(Y-6)/4)AND Y<66 AND Y>12 AND(P=20 OR P=21)THEN 280
285 BOX X-1,Y-1,X+1,Y+1,0,2:IF PEEK(199)<>141 AND PEEK(199)<>241 THEN POKE 199,0
288 IF PEEK(199)=161 OR CP THEN ID=1:TS=TS-1:BOX X-1,Y-1,X+1,Y+1,0,2 ELSE ID=0
289 IF ID THEN POKE 199,0:GOSUB 6000:ID=0:F=(F=0):LOCATE 3,3:PRINT "":GOTO 350
290 N=N+1:LOCATE 1,16:IF N>600 THEN PRINT "醒醒!" ELSE PRINT " "
291 IF N>620 THEN N=580:PLAY "O3L100GDGDGDGDGDGDGD"
292 WEND:N=0
293 IF PEEK(199)=241 THEN 8000
294 IF M((X-46)/4,(Y-6)/4)THEN 380
295 F=(F=0):M((X-46)/4,(Y-6)/4)=1
298 LOCATE 3,3:PRINT ""
300 BOX X-1,Y-1,X+1,Y+1,0,2
310 BOX X-1,Y-1,X+1,Y+1,1,0
320 BOX X-2,Y-2,X+2,Y+2,F
330 GOSUB 1000
340 INDEX=1:XT=INT((X-46)/4):YT=INT((Y-6)/4)
345 GOSUB 9000
346 TS=TS+1:IF TS=225 THEN 700
347 RECORD(TS)=X*10000+Y*10
348 SJ=1:GOSUB 3000
350 IF SCORE>1000 THEN 500
360 GOSUB 6000
368 BOX X-1,Y-1,X+1,Y+1,0,2
370 F=(F=0)
380 WEND
390 END
500 REP=0:POKE 199,0:IF H1>1 OR H2>1 AND S=4 THEN F=(F=0)
510 FOR U=1 TO 5:BOX 43,2,117,76,1,2:FOR T=1 TO 900:NEXT:NEXT
540 LOCATE 2,17:IF F THEN PRINT "黑" ELSE PRINT "白"
550 LOCATE 3,17:PRINT "棋":LOCATE 4,17:PRINT "赢":RECORD(TS+1)=-1
560 IF F=0 THEN 570
561 LINE 21,22,25,22,0:BOX 20,62,26,64,1,0
562 LINE 22,62,24,62:LINE 22,62,20,64:LINE 24,62,26,64
563 LINE 20,18,20,19:DRAW 21,17:LINE 26,18,26,19:DRAW 25,17:GOTO 580
570 LINE 21,62,25,62:BOX 20,22,26,24,1,1
571 LINE 22,22,24,22,0:LINE 22,22,20,24,0:LINE 24,22,26,24,0
572 LINE 20,58,20,59,0:DRAW 21,57,0:LINE 26,58,26,59,0:DRAW 25,57,0:CP=0:TS=0
580 K$=INKEY$:IF K$="p" THEN REP=1
590 GOTO 60
700 LOCATE 2,17:PRINT "平":LOCATE 4,17:PRINT "局":CP=0:TS=0
710 K$=INKEY$:GOTO 60
1000 DRAW X-2,Y-2,0:DRAW X-2,Y+2,0:DRAW X+2,Y-2,0:DRAW X+2,Y+2,0:DRAW X-1,Y-1,0
1010 RETURN
3000 XT2=XT-1:SH=0:SCORE=0:TOT=0
3010 WHILE M(XT2,YT)=INDEX
3020 XT2=XT2-1
3025 TOT=TOT+1
3030 WEND
3040 IF M(XT2,YT)THEN SH=SH+1
3050 XT2=XT+1
3060 WHILE M(XT2,YT)=INDEX
3070 XT2=XT2+1:TOT=TOT+1
3080 WEND
3090 IF M(XT2,YT)THEN SH=SH+1
3095 SCORE=SCORE+IL(TOT,SH,SJ)
3100 TOT=0:YT2=YT-1:SH=0
3110 WHILE M(XT,YT2)=INDEX
3120 YT2=YT2-1
3125 TOT=TOT+1
3130 WEND
3140 IF M(XT,YT2)THEN SH=SH+1
3150 YT2=YT+1
3160 WHILE M(XT,YT2)=INDEX
3170 YT2=YT2+1
3175 TOT=TOT+1
3180 WEND
3190 IF M(XT,YT2)THEN SH=SH+1
3195 SCORE=SCORE+IL(TOT,SH,SJ)
3200 TOT=0:XT2=XT-1:YT2=YT-1:SH=0
3210 WHILE M(XT2,YT2)=INDEX
3220 XT2=XT2-1:YT2=YT2-1
3225 TOT=TOT+1
3230 WEND
3240 IF M(XT2,YT2)THEN SH=SH+1
3250 XT2=XT+1:YT2=YT+1
3260 WHILE M(XT2,YT2)=INDEX
3270 XT2=XT2+1:YT2=YT2+1
3275 TOT=TOT+1
3280 WEND
3290 IF M(XT2,YT2)THEN SH=SH+1
3295 SCORE=SCORE+IL(TOT,SH,SJ)
3300 TOT=0:XT2=XT+1:YT2=YT-1:SH=0
3310 WHILE M(XT2,YT2)=INDEX
3320 XT2=XT2+1:YT2=YT2-1
3325 TOT=TOT+1
3330 WEND
3340 IF M(XT2,YT2)THEN SH=SH+1
3350 XT2=XT-1:YT2=YT+1
3360 WHILE M(XT2,YT2)=INDEX
3370 XT2=XT2-1:YT2=YT2+1
3375 TOT=TOT+1
3380 WEND
3390 IF M(XT2,YT2)THEN SH=SH+1
3395 SCORE=SCORE+IL(TOT,SH,SJ)
3400 RETURN
6000 BX=0:BY=0:SMAX=0:G=0:BOX 6,3,35,8,0,2
6001 IF M THEN 6005
6002 BX=INT(RND(1)*15)+1:BY=INT(RND(5)*15)+1:IF M(BX,BY)THEN 6002
6005 FOR YC=LTY TO RTY
6010 FOR XC=LTX TO RTX
6016 IF M(XC,YC)THEN 6070
6020 SJ=1:INDEX=(ID=0)+1:XT=XC:YT=YC:GOSUB 3000
6030 ST=SCORE
6050 SJ=2:INDEX=(ID=1)+1:GOSUB 3000:SCORE=SCORE+ST
6060 IF SCORE=SMAX THEN G=G+1:G=G-(ABS(G-48))*(G>48):BSX(G)=XC:BSY(G)=YC
6065 IF SCORE>SMAX THEN SMAX=SCORE:G=1:BSX(1)=XC:BSY(1)=YC
6068 NEXT
6070 BOX 8,5,8+25*((YC-LTY)/(RTY-LTY)),6,1
6071 NEXT
6072 XZ=INT(RND(1)*G)+1:BX=BSX(XZ):BY=BSY(XZ)
6085 X=BX*4+48:Y=BY*4+7
6090 BOX X-1,Y-1,X+1,Y+1,1,0
6092 BOX X-2,Y-2,X+2,Y+2,(ID=0):GOSUB 1000
6095 M(BX,BY)=(ID=0)+1
6100 XT=BX:YT=BY:GOSUB 9000
6110 LOCATE ID*2+2,1:PRINT " "
6120 LOCATE 3,3:PRINT ""
6125 XT=BX:YT=BY:INDEX=(ID=0)+1:SJ=1:SCORE=0:GOSUB 3000
6126 TS=TS+1:IF TS=225 THEN 700
6127 RECORD(TS)=X*10000+Y*10+1
6130 IF SCORE>1000 THEN F=(F=0):GOTO 500
6148 BOX 6,3,35,9,1,0
6150 RETURN
7000 LOCATE 2,17:PRINT "重":LOCATE 4,17:PRINT "放"
7005 R=1:WHILE RECORD(R)>0:H=RECORD(R)
7010 C=H-INT(H/10)*10
7012 H=INT(H/10)
7015 Y=H-INT(H/1000)*1000
7020 X=INT(H/1000)
7030 GOSUB 7600
7035 LINE X,4,X,8:LINE 45,Y,49,Y
7036 LINE X-1,7,X+1,7:LINE X-2,6,X+2,6
7037 LINE 48,Y-1,48,Y+1:LINE 47,Y-2,47,Y+2
7040 K$=INKEY$
7041 IF K$="b" THEN GOSUB 7500:R=R-(R>1)
7042 IF K$<>"b" THEN R=R+1
7045 BOX 47,4,112,8,1,0:BOX 45,4,49,76,1,0
7050 WEND
7060 POKE 199,0:REP=0:K$=INKEY$
7070 GOTO 60
7500 BOX X-2,Y-2,X+2,Y+2,1,0:LINE X-2,Y,X+2,Y:LINE X,Y-2,X,Y+2
7510 FOR J=1 TO R-1
7520 H=RECORD(J):C=H-INT(H/10)*10
7521 H=INT(H/10)
7522 Y=H-INT(H/1000)*1000
7523 X=INT(H/1000)
7530 GOSUB 7600
7540 NEXT
7550 RETURN
7600 BOX X-1,Y-1,X+1,Y+1,1,0
7610 BOX X-2,Y-2,X+2,Y+2,C:GOSUB 1000
7620 RETURN
8000 CLS:PRINT "--- 智能五子棋 ---"
8010 PRINT "版本:1.9加强版","作者:fineday","日期:2004/6/14"
8020 K$=INKEY$:END
9000 IF XT<=LTX THEN LTX=XT-1
9010 IF LTX<1 THEN LTX=1
9020 IF XT>=RTX THEN RTX=XT+1
9030 IF RTX>15 THEN RTX=15
9040 IF YT<=LTY THEN LTY=YT-1
9050 IF LTY<1 THEN LTY=1
9060 IF YT>=RTY THEN RTY=YT+1
9070 IF RTY>15 THEN RTY=15
9080 RETURN

10 GRAPH:PRINT "--- 智能五子棋 ---"
20 LOCATE 2,5:PRINT "对应版本:1.9"
21 LOCATE 3,7:PRINT "按任意键":K$=INKEY$
29 LOCATE 3,7:PRINT "生成数据"
30 IL(0,0,1)=0
31 IL(0,0,2)=0
32 IL(0,1,1)=0
33 IL(0,1,2)=0
40 IL(1,0,1)=8
41 IL(1,0,2)=7
42 IL(1,1,1)=2
43 IL(1,1,2)=1
50 IL(2,0,1)=50
51 IL(2,0,2)=28
52 IL(2,1,1)=6
53 IL(2,1,2)=5
60 IL(3,0,1)=160
61 IL(3,0,2)=105
62 IL(3,1,1)=46
63 IL(3,1,2)=24
70 IL(4,0,1)=9500
71 IL(4,0,2)=4000
72 IL(4,1,1)=9500
73 IL(4,1,2)=4000
74 IL(4,2,1)=9500
75 IL(4,2,2)=4000
83 LOCATE 3,7:PRINT "写入文件":OPEN "INTLIB" FOR OUTPUT AS1
93 FOR A=0 TO 4
103 FOR B=0 TO 2
113 FOR C=1 TO 2
123 WRITE#1,IL(A,B,C)
133 NEXT
143 NEXT
153 NEXT
163 POKE 199,166:END





 
分享到:
评论

相关推荐

    文曲星 NC1020防真器 附带GMUD之英雄坛说

    文曲星 NC1020防真器 附带GMUD之英雄坛说

    LCD防真器

    在电子设备、仪表盘、智能家居等众多领域,液晶显示(LCD)因其低功耗、低成本等特性广泛应用,而LCD防真器的出现极大地提高了开发人员在设计阶段的工作效率。 LCD显示屏由于其独特的显示原理,与传统的RGB显示器...

    jswqx:文曲星模拟器

    对于文曲星模拟器而言,这意味着它需要理解并执行文曲星NC1020使用的指令集,并提供类似的用户界面和功能,如显示屏幕、按键操作和存储卡接口。 在"jswqx-master"这个压缩包文件中,我们可能找到以下内容: 1. 源...

    长青说安卓

    Android是由Google主导开发的一款开源操作系统,主要应用于移动设备,如智能手机和平板电脑。它以其开放性和丰富的应用生态系统,吸引了全球众多开发者和用户。"长青说安卓"可能是一个专门讲解Android开发的系列教程...

    文曲星LAVA小游戏及小程序合集

    16级灰度bmp图浏览器;CarzyBall;figure-maker;flashmaker画板;Justfly;Q版Dancer;Startstyle;WarCraft;暗棋;暗子象棋;白金贪吃蛇;冠军足球经理;欢乐五子棋等等还有很多

    3ds文曲星模拟器

    可以在3ds上运行文曲星模拟器

    6502汇编大奥秘

    专门针对使用6502 CPU的文曲星开发资料,经典机型如nc1020,nc3000,nc2600等

    jswqx:从 code.google.compjswqx 自动导出

    【标题】"jswqx: 从 code.google.compjswqx 自动导出" 指的是一个基于JavaScript开发的项目,它是一个文曲星模拟器,主要用于复现 NC1020 这款电子词典的功能。这个项目可能是从 code.google.com 的某个废弃或迁移的...

Global site tag (gtag.js) - Google Analytics