Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (111 sloc) 2.72 KB
5 REM writecocofile -a ../emulators/mame/messwork.dsk gomoku.bas && ../emulators/mame/gomess.sh messwork.dsk -autoboot_delay 1 -autoboot_command 'LOAD"GOMOKU"\n'
10 REM GOMOKU
15 POKE &HFFD9,0 : WIDTH 80
20 GOSUB 750 : REM INITIALIZE
30 GOSUB 130 : REM PRINT BOARD
40 GOSUB 240 : REM HUMAN MOVE
50 GOSUB 130 : REM PRINT BOARD
60 GOSUB 320 : REM COMPUTER MOVE
65 SOUND 1,10
70 GOSUB 130
80 IF L>3 THEN PRINT : PRINT "I WIN!!" : END
90 GOTO 40
95 REM COUNT SEQUENCE, HOW MANY UNSEPERATED PIECES (Z) THERE ARE. K CONTAINS THE COUNT.
100 E=A : REM PRINT "A=";A;" N=";N;" Z=";Z;"K=";K
110 E=E+N
115 IF A(E)<>Z THEN RETURN
120 K=K+1 : GOTO 110
125 REM SHOW BOARD
130 CLS
135 PRINT "GOMOKU BASIC"
140 PRINT " 1 2 3 4 5 6 7 8"
160 FOR A=1 TO 8 : PRINT A;
170 FOR B=2 TO 9
180 PRINT CHR$(A(A*10+B));" ";
190 NEXT B
200 PRINT A
210 NEXT A
220 PRINT " 1 2 3 4 5 6 7 8"
230 RETURN
235 REM HUMAN MOVE
240 PRINT
250 INPUT "YOUR MOVE";G
270 G=G+1
280 IF G<12 OR G>89 OR A(G)<>46 THEN PRINT "INVALID" : GOTO 250
290 Z=H
300 A(G)=Z
310 RETURN
315 REM COMPUTER MOVE
320 A=G
330 L=0
335 PRINT : PRINT "MY MOVE..."
336 REM CHECK FOR A WIN
340 FOR X=1 TO 4 : K=0 : N=X(X)
350 GOSUB 100
360 N=-N : GOSUB 100
370 IF K>L THEN L=K
380 NEXT X
390 IF L>3 THEN PRINT : PRINT "YOU WIN!!" : END
400 T=1
410 IF T<>2 THEN Z=C
420 IF T=2 THEN Z=H
430 G=0 : H1=0 : L=0
440 FOR A=12 TO 89
450 M=0
460 IF A(A)<>46 THEN 570
470 FOR X=1 TO 4 : K=0 : N=X(X)
480 GOSUB 100
490 N=-N : GOSUB 100
500 IF K>L THEN H1=0 : L=K
510 IF L<>K THEN 540
520 IF T=1 AND L<4 OR (T=2 OR T=3) AND L<2 THEN 540
530 M=M+1
540 NEXT X
550 IF M<=H1 THEN 570
560 H1=M : G=A
570 NEXT A
580 IF H1<>0 THEN 650
590 T=T+1 : IF T<>4 THEN 410
595 REM RANDOMLY PICK A SPOT, OR CONCEDE IF WE ARE NOT ABLE TO GUESS AN OPEN SPOT
600 A=1
610 G=RND(77)+12 : REM G=INT(RND*77)+13
620 IF A(G)=46 THEN 650
630 A=A+1 : IF A<100 THEN 610
640 PRINT : PRINT "I CONCEDE THE GAME" : END
650 A(G)=C
660 Z=C : A=G : L=0
670 FOR X=1 TO 4
680 K=0
690 N=X(X)
700 GOSUB 100
710 N=-N : GOSUB 100
720 IF K>L THEN L=K
730 NEXT X
740 RETURN
745 REM INITIALIZE AND CHECK WHO MOVES FIRST
750 CLS
760 DIM A(100),X(4)
770 FOR C=1 TO 8
780 FOR B=2 TO 9
790 A(C*10+B)=46
800 NEXT B
810 NEXT C
820 FOR Q=1 TO 4
830 READ Z : X(Q)=Z
840 NEXT Q
850 DATA 1,9,10,11
860 H=ASC("H") : C=ASC("C")
862 DATA 0,0,0,0,0,0,0,0
870 PRINT "YOU WANT FIRST MOVE (Y OR N)?"
890 N=0
900 REM N=RND(100) : REM GENERATE RANDOM NUMBERS, POOR MANS RANDOMIZE
910 A$=INKEY$
920 IF A$<>"Y" AND A$<>"N" THEN 900
940 CLS
950 IF A$="Y" THEN RETURN
960 FOR J=1 TO RND(10) : REM INT(RND*12)+1
970 READ Z
980 NEXT J
990 A(Z) = C
1000 RETURN
1010 DATA 34,35,44,46,47,54,55,56,57,66
You can’t perform that action at this time.