Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Othello 1977 (ported by justsomeguy)
#1
Quote:While reading old computer magazines, I came across this Othello game published in 1977, and I was curious how backward compatible QB64 was. Apparently very!

This is a very old school game so no mouse clicky. It has instructions built-in, so It shouldn't be too hard to figure it out. I'm ashamed to say I have yet to be able to beat it, but I suck at these kind of games.

I used OCR to port this program in, so there a few misspellings and oddities.

The original article can be found here. -> https://archive.org/details/byte-magazin...1/mode/2up

Code: (Select All)
10 ' https://archive.org/details/byte-magazin...1/mode/2up
20 '
30 '
40 '
50 '
60 '
70 '
80 ' OTHELLO AUTHOR: RICHARD O. DUDA PLAYS THE GAME "OTHELLO" WITH TWO STRATEGIES:
' 1. TAKE THE MAXIMUM NUMBER OF PIECES
' 2. ADD A BONUS FOR OUTSIDE POSITION BOARD IS THE ARRAY A, BOUNDED BY 0'S (BLANKS) A = 0 FOR EMPTY SQUARE A = B FOR BLACK SQUARE -- X (INTERNALLY -1) A = W FOR WHITE SQUARE -- 0 (INTERNALLY +1)
90 ' I AND J ALWAYS USED FOR ROW/COLUMN INDICES
100 ' I4 AND J4 STORE INC'ENTS TO THE 8 NEIGHBORS
110 ' C$ AND D$ STORE CHARACTERS A-H,X,.,O FOR OUTPUT
120 Dim A(9, 9), I4(8), J4(8), C$(8), D$(2)
130 ' INITIAL GREETING
140 Print "GREETINGS FROM OTHELLO"
150 Print "DO YOU WANT INSTRUCTIONS (Y OR N) ";
160 Input X$
170 If X$ = "N" Then 390
180 If X$ <> "Y" Then 160
190 Print
200 Print "OTHELLO IS PLAYED ON AN 8 X 8 CHECKER BOARD,"
210 Print "ROWS NUMBERED 1 TO 8 AND COLUMNS A TO H."
220 Print "THE INITIAL CONFIGURATION IS ALL BLANK, EXCEPT"
230 Print "FOR THE CENTER FOUR SQUARES, WHICH FORM THE"
240 Print "PATTERN"
250 Print " 0 X"
260 Print " X 0"
270 Print
280 Print "TRY TO PLACE YOUR PIECE SO THAT IT 'OUTFLANKS'"
290 Print "MINE, CREATING A HORIZONTAL, VERTICAL, OR"
300 Print "DIAGONAL RUN OF MY PIECES BOUNDED AT EACH END"
310 Print "BY AT LEAST ONE OF YOURS. THIS WILL 'FLIP' MY"
320 Print "PIECES, TURNING THEM INTO YOURS."
330 Print "NOTE: YOU MUST CAPTURE AT LEAST ONE OF MY"
340 Print "PIECES IN THIS WAY IF IT IS AT ALL POSSIBLE."
350 Print "IF IT IS NOT POSSIBLE, YOU FORFEIT YOUR TURN BY"
360 Print "ENTERING 0,0 FOR YOUR (ROW,COL) MOVE."
370 Print
380 ' INITIALIZE
390 Print "SHOULD I WAIT BEFORE MAKING MY MOVES (Y OR N) ";
400 F2 = 0
410 Input X$
420 If X$ = "N" Then 460
430 If X$ <> "Y" Then 410
440 F2 = 1
450 Print "OK. TYPING ANY CHARACTER WILL LET ME GO."
460 Print "SHOULD I PLAY MY BEST STRATEGY (Y OR N)"
470 S2 = 0
480 Input X$
490 If X$ = "N" Then 520
500 If X$ <> "Y" Then 480
510 S2 = 2
520 B = -1
530 W = 1
540 D$(B + 1) = "X"
550 D$(0 + 1) = "."
560 D$(W + 1) = "0"
570 For K = 1 To 8
580 Read I4(K)
590 Next K
600 Data 0,-1,-1,-1,0,1,1,1
610 For K = 1 To 8
620 Read J4(K)
630 Next K
640 Data 1,1,0,-1,-1,-1,0,1
650 For K = 1 To 8
660 Read C$(K)
670 Next K
680 Data "A","B","C","D","E","F","G","H"
690 ' SET UP A NEW GAME
700 For I = 0 To 9
710 For J = 0 To 9
720 A(I, J) = 0
730 Next J
740 Next I
750 A(4, 4) = W
760 A(5, 5) = W
770 A(4, 5) = B
780 A(5, 4) = B
790 C1 = 2
800 H1 = 2
810 N1 = 4
820 Z = 0
830 ' HUMAN'S CHOICES
840 Print "DO YOU WANT TO HAVE X OR 0 ";
850 C = W
860 H = B
870 Input X$
880 If X$ = "X" Then 920
890 If X$ <> "0" Then 870
900 C = B
910 H = W
920 Print "DO YOU WANT TO GO FIRST (Y OR N) ";
930 Input X$
940 If X$ = "N" Then 1020
950 If X$ <> "Y" Then 930
960 ' PRINT INITIAL BOARD
970 GoSub 3100
980 GoTo 1690
990 ' COMPUTER'S MOVE
1000 If F2 = 0 Then 1020
1010 Input X$
1020 B1 = -1
1030 I3 = J3 = 0
1040 T1 = C
1050 T2 = H
1060 ' SCAN FOR BLANK SQUARE
1070 For I = 1 To 8
1080 For J = 1 To 8
1090 If A(I, J) <> 0 Then 1380
1100 ' FOUND A BLANK SQUARE
1110 ' DOES IT HAVE AN OPPONENT AS A NEIGHBOR?
1120 GoSub 2620
1130 If F1 = 0 Then 1380
1140 ' FOUND AN OPPONENT AS A NEIGHBOR
1150 ' HOW MANY OF HIS PIECES CAN WE FLIP?
1160 ' (DON'T DO IT NOW)
1170 U = -1
1180 GoSub 2820
1190 ' EXTRA POINTS FOR BOUNDARY POSITION
1200 If S1 = 0 Then 1380
1210 If (I - 1) * (I - 8) <> 0 Then 1230
1220 S1 = S1 + S2
1230 If (J - 1) * (J - 8) <> 0 Then 1260
1240 S1 = S1 + S2
1250 ' IS THIS BETTER THAN THE BEST FOUND SO FAR?
1260 If S1 < B1 Then 1380
1270 If S1 > B1 Then 1340
1280 ' A TIE; RANDOM DECISION
1290 ' THE NEXT TWO EXECUTABLE STATEMENTS CAN BE DELETED
1300 ' FOR A VERSION OF BASIO WITHOUT RANDOM NUMBERS
1310 R = Rnd
1320 If R > 0.5 Then 1380
1330 ' YES
1340 B1 = S1
1350 I3 = I
1360 J3 = J
1370 ' END OF SCAN LOOP
1380 Next J
1390 Next I
1400 ' COULD WE DO ANYTHING?
1410 If B1 > 0 Then 1480
1420 ' NO
1430 Print "I HAVE TO FORFEIT MY MOVE"
1440 If Z = 1 Then 2190
1450 Z = 1
1460 GoTo 1690
1470 ' MAKE THE MOVE
1480 Z = 0
1490 Print "I WILL MOVE TO ";
1500 Print I3;
1510 Print ", ";
1520 Print C$(J3)
1530 I = I3
1540 J = J3
1550 U = 1
1560 GoSub 2820
1570 C1 = C1 + S1 + 1
1580 H1 = H1 - S1
1590 N1 = N1 + 1
1600 Print "THAT GIVES ME ";
1610 Print S1;
1620 Print " OF YOUR PIECES"
1630 ' PRINT OUT BOARD
1640 GoSub 3100
1650 ' TEST FOR END OF GAME
1660 If H1 = 0 Then 2190
1670 If N1 = 64 Then 2190
1680 ' HUMAN'S MOVE
1690 T1 = H
1700 T2 = C
1710 Print "YOUR MOVE -- (ROW, COL) ";
1720 Input I, X$
1730 If I < 0 Then 1720
1740 If I > 8 Then 1720
1750 If I <> 0 Then 1820
1760 Print "ARE YOU FORFEITING YOUR TURN (Y OR N)"
1770 Input X$
1780 If X$ <> "Y" Then 1710
1790 If Z = 1 Then 2190
1800 Z = 1
1810 GoTo 1000
1820 For J = 1 To 8
1830 If C$(J) = X$ Then 1870
1840 Next J
1850 GoTo 1720
1860 ' CHECK IF BLANK
1870 If A(I, J) = 0 Then 1910
1880 Print "SORRY, THAT SQUARE IS OCCUPIED; TRY AGAIN."
1890 GoTo 1720
1900 ' CHECK FOR LEGAL NEIGHBOR
1910 GoSub 2620
1920 If F1 = 1 Then 1970
1930 Print "SORRY, YOU ARE NOT NEXT TO ONE OF MY PIECES;"
1940 Print "TRY AGAIN"
1950 GoTo 1720
1960 ' CHECK IF LEGAL RUN
1970 U = -1
1980 GoSub 2820
1990 If S1 > 0 Then 2030
2000 Print "SORRY, THAT DOESN'T FLANK A ROW; TRY AGAIN"
2010 GoTo 1720
2020 ' EVERYTHING LEGAL; MAKE HUMAN'S MOVE
2030 Z = 0
2040 Print "THAT GIVES YOU ";
2050 Print S1;
2060 Print " OF MY PIECES"
2070 U = 1
2080 GoSub 2820
2090 H1 = H1 + S1 + 1
2100 C1 = C1 - S1
2110 N1 = N1 + 1
2120 '. PRINT OUT BOARD
2130 GoSub 3100
2140 ' TEST FOR END OF GAME
2150 If C1 = 0 Then 2190
2160 If N1 = 64 Then 2190
2170 GoTo 1000
2180 ' END OF GAME WRAPUP
2190 Print
2200 Print "YOU HAVE ";
2210 Print H1;
2220 Print " PIECES AND I HAVE ";
2230 Print C1;
2240 Print " PIECES -- ";
2250 If H1 = C1 Then 2290
2260 If H1 > C1 Then 2310
2270 Print "SORRY, I WON THAT ONE."
2280 GoTo 2320
2290 Print "A TIE !I"
2300 GoTo 2500
2310 Print "YOU WON 1"
2320 C1 = C1 - H1
2330 If C1 > 0 Then 2350
2340 C1 = -C1
2350 C1 = (64 * C1) / N1
2360 Print "THAT WAS A ";
2370 If C1 < 11 Then 2490
2380 If C1 < 25 Then 2470
2390 If C1 < 39 Then 2450
2400 If C1 < 53 Then 2430
2410 Print "PERFECT GAME."
2420 GoTo 2500
2430 Print "WALKAWAY."
2440 GoTo 2500
2450 Print "FIGHT."
2460 GoTo 2500
2470 Print "HOT GAME !"
2480 GoTo 2500
2490 Print "SQUEAKER !!"
2500 Print
2510 Print "DO YOU WANT TO PLAY ANOTHER GAME (Y OR N) ";
2520 Input X$
2530 If X$ = "Y" Then 700
2540 If X$ <> "N" Then 2520
2550 Print "THANKS FOR PLAYING."
2560 Stop
2570 '
2580 ' SUBROUTINE TEST-FOR-PROPER-NEIGHBOR
2590 ' ASSUMES:
2600 ' I,J LOCATES A BLANK SQUARE
2610 ' YOU HOPE TO SEE AN ADJACENT T2 (. -T1)
2620 For I1 = -1 To 1
2630 For J1 = -1 To 1
2640 If A(I + I1, J + J1) = T2 Then 2710
2650 Next J1
2660 Next I1
2670 ' NO T2 FOUND; FAILURE
2680 F1 = 0
2690 Return
2700 ' SUCCESS
2710 F1 = 1
2720 Return
2730 ' SUBROUTINE SCORE-AND-UPDATE
2740 ' ASSUMES:
2750 ' (I,J) IS A TENTATIVE PLACE FOR A PIECE T1.
2760 ' WANT RUNS OF T2 . -T1, TERMINATED BY A T1.
2770 ' IF U IS TRUE (1), MARK THOSE RUNS AS T1'S.
2780 ' RETURN SUM OF ALL RUNS (T2'S ONLY) IN S1.
2790 ' MAIN PROGRAM CONTAINS THE FOLLOWING ARRAYS:
2800 ' i4: 0 -1 -1 -1 0 1 1 1
2810 ' J4: 1 1 0 -1 -1 -1 0 1
2820 S1 = 0
2830 For K = 1 To 8
2840 I5 = I4(K)
2850 J5 = J4(K)
2860 I6 = I + I5
2870 J6 = J + J5
2880 S3 = 0
2890 If A(I6, J6) <> T2 Then 3070
2900 ' LOOP THROUGH THE RUN
2910 S3 = S3 + 1
2920 I6 = I6 + I5
2930 J6 = J6 + J5
2940 If A(I6, J6) = T1 Then 2970
2950 If A(I6, J6) = 0 Then 3070
2960 GoTo 2910
2970 S1 = S1 + S3
2980 If U <> 1 Then 3070
2990 ' UPDATE BOARD
3000 I6 = I
3010 J6 = J
3020 For K1 = 0 To S3
3030 A(I6, J6) = T1
3040 I6 = I6 + I5
3050 J6 = J6 + J5
3060 Next K1
3070 Next K
3080 Return
3090 ' SUBROUTINE PRINT-BOARD
3100 Print
3110 Print " A B C D E F G H"
3120 For I = 1 To 8
3130 Print I;
3140 For J = 1 To 8
3150 Print " ";
3160 Print D$(A(I, J) + 1);
3170 Next J
3180 Print
3190 Next I
3200 Print
3210 Return
3220 End
Reply




Users browsing this thread: 2 Guest(s)