Author Topic: Try an Othello game that was published in 1977  (Read 3770 times)

0 Members and 1 Guest are viewing this topic.

Offline justsomeguy

  • Newbie
  • Posts: 47
    • View Profile
Try an Othello game that was published in 1977
« on: May 10, 2021, 07:18:29 pm »
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-magazine-1977-10/page/n61/mode/2up

Code: QB64: [Select]
  1. 10 ' https://archive.org/details/byte-magazine-1977-10/page/n61/mode/2up
  2. 20 '
  3. 30 '
  4. 40 '
  5. 50 '
  6. 60 '
  7. 70 '
  8. 80 ' OTHELLO AUTHOR: RICHARD O. DUDA PLAYS THE GAME "OTHELLO" WITH TWO STRATEGIES:
  9. '   1. TAKE THE MAXIMUM NUMBER OF PIECES
  10. '   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)
  11. 90 ' I AND J ALWAYS USED FOR ROW/COLUMN INDICES
  12. 100 ' I4 AND J4 STORE INC'ENTS TO THE 8 NEIGHBORS
  13. 110 ' C$ AND D$ STORE CHARACTERS A-H,X,.,O FOR OUTPUT
  14. 120 DIM A(9, 9), I4(8), J4(8), C$(8), D$(2)
  15. 130 ' INITIAL GREETING
  16. 140 PRINT "GREETINGS FROM OTHELLO"
  17. 150 PRINT "DO YOU WANT INSTRUCTIONS (Y OR N) ";
  18. 160 INPUT X$
  19. 170 IF X$ = "N" THEN 390
  20. 180 IF X$ <> "Y" THEN 160
  21. 190 PRINT
  22. 200 PRINT "OTHELLO IS PLAYED ON AN 8 X 8 CHECKER BOARD,"
  23. 210 PRINT "ROWS NUMBERED 1 TO 8 AND COLUMNS A TO H."
  24. 220 PRINT "THE INITIAL CONFIGURATION IS ALL BLANK, EXCEPT"
  25. 230 PRINT "FOR THE CENTER FOUR SQUARES, WHICH FORM THE"
  26. 240 PRINT "PATTERN"
  27. 250 PRINT " 0 X"
  28. 260 PRINT " X 0"
  29. 270 PRINT
  30. 280 PRINT "TRY TO PLACE YOUR PIECE SO THAT IT 'OUTFLANKS'"
  31. 290 PRINT "MINE, CREATING A HORIZONTAL, VERTICAL, OR"
  32. 300 PRINT "DIAGONAL RUN OF MY PIECES BOUNDED AT EACH END"
  33. 310 PRINT "BY AT LEAST ONE OF YOURS. THIS WILL 'FLIP' MY"
  34. 320 PRINT "PIECES, TURNING THEM INTO YOURS."
  35. 330 PRINT "NOTE: YOU MUST CAPTURE AT LEAST ONE OF MY"
  36. 340 PRINT "PIECES IN THIS WAY IF IT IS AT ALL POSSIBLE."
  37. 350 PRINT "IF IT IS NOT POSSIBLE, YOU FORFEIT YOUR TURN BY"
  38. 360 PRINT "ENTERING 0,0 FOR YOUR (ROW,COL) MOVE."
  39. 370 PRINT
  40. 380 ' INITIALIZE
  41. 390 PRINT "SHOULD I WAIT BEFORE MAKING MY MOVES (Y OR N) ";
  42. 400 F2 = 0
  43. 410 INPUT X$
  44. 420 IF X$ = "N" THEN 460
  45. 430 IF X$ <> "Y" THEN 410
  46. 440 F2 = 1
  47. 450 PRINT "OK. TYPING ANY CHARACTER WILL LET ME GO."
  48. 460 PRINT "SHOULD I PLAY MY BEST STRATEGY (Y OR N)"
  49. 470 S2 = 0
  50. 480 INPUT X$
  51. 490 IF X$ = "N" THEN 520
  52. 500 IF X$ <> "Y" THEN 480
  53. 510 S2 = 2
  54. 520 B = -1
  55. 530 W = 1
  56. 540 D$(B + 1) = "X"
  57. 550 D$(0 + 1) = "."
  58. 560 D$(W + 1) = "0"
  59. 570 FOR K = 1 TO 8
  60.    580 READ I4(K)
  61. 590 NEXT K
  62. 600 DATA 0,-1,-1,-1,0,1,1,1
  63. 610 FOR K = 1 TO 8
  64.    620 READ J4(K)
  65. 630 NEXT K
  66. 640 DATA 1,1,0,-1,-1,-1,0,1
  67. 650 FOR K = 1 TO 8
  68.    660 READ C$(K)
  69. 670 NEXT K
  70. 680 DATA "A","B","C","D","E","F","G","H"
  71. 690 ' SET UP A NEW GAME
  72. 700 FOR I = 0 TO 9
  73.    710 FOR J = 0 TO 9
  74.        720 A(I, J) = 0
  75.    730 NEXT J
  76. 740 NEXT I
  77. 750 A(4, 4) = W
  78. 760 A(5, 5) = W
  79. 770 A(4, 5) = B
  80. 780 A(5, 4) = B
  81. 790 C1 = 2
  82. 800 H1 = 2
  83. 810 N1 = 4
  84. 820 Z = 0
  85. 830 ' HUMAN'S CHOICES
  86. 840 PRINT "DO YOU WANT TO HAVE X OR 0 ";
  87. 850 C = W
  88. 860 H = B
  89. 870 INPUT X$
  90. 880 IF X$ = "X" THEN 920
  91. 890 IF X$ <> "0" THEN 870
  92. 900 C = B
  93. 910 H = W
  94. 920 PRINT "DO YOU WANT TO GO FIRST (Y OR N) ";
  95. 930 INPUT X$
  96. 940 IF X$ = "N" THEN 1020
  97. 950 IF X$ <> "Y" THEN 930
  98. 960 ' PRINT INITIAL BOARD
  99. 970 GOSUB 3100
  100. 980 GOTO 1690
  101. 990 ' COMPUTER'S MOVE
  102. 1000 IF F2 = 0 THEN 1020
  103. 1010 INPUT X$
  104. 1020 B1 = -1
  105. 1030 I3 = J3 = 0
  106. 1040 T1 = C
  107. 1050 T2 = H
  108. 1060 ' SCAN FOR BLANK SQUARE
  109. 1070 FOR I = 1 TO 8
  110.    1080 FOR J = 1 TO 8
  111.        1090 IF A(I, J) <> 0 THEN 1380
  112.        1100 ' FOUND A BLANK SQUARE
  113.        1110 ' DOES IT HAVE AN OPPONENT AS A NEIGHBOR?
  114.        1120 GOSUB 2620
  115.        1130 IF F1 = 0 THEN 1380
  116.        1140 ' FOUND AN OPPONENT AS A NEIGHBOR
  117.        1150 ' HOW MANY OF HIS PIECES CAN WE FLIP?
  118.        1160 ' (DON'T DO IT NOW)
  119.        1170 U = -1
  120.        1180 GOSUB 2820
  121.        1190 ' EXTRA POINTS FOR BOUNDARY POSITION
  122.        1200 IF S1 = 0 THEN 1380
  123.        1210 IF (I - 1) * (I - 8) <> 0 THEN 1230
  124.        1220 S1 = S1 + S2
  125.        1230 IF (J - 1) * (J - 8) <> 0 THEN 1260
  126.        1240 S1 = S1 + S2
  127.        1250 ' IS THIS BETTER THAN THE BEST FOUND SO FAR?
  128.        1260 IF S1 < B1 THEN 1380
  129.        1270 IF S1 > B1 THEN 1340
  130.        1280 ' A TIE; RANDOM DECISION
  131.        1290 ' THE NEXT TWO EXECUTABLE STATEMENTS CAN BE DELETED
  132.        1300 ' FOR A VERSION OF BASIO WITHOUT RANDOM NUMBERS
  133.        1310 R = RND
  134.        1320 IF R > 0.5 THEN 1380
  135.        1330 ' YES
  136.        1340 B1 = S1
  137.        1350 I3 = I
  138.        1360 J3 = J
  139.        1370 ' END OF SCAN LOOP
  140.    1380 NEXT J
  141. 1390 NEXT I
  142. 1400 ' COULD WE DO ANYTHING?
  143. 1410 IF B1 > 0 THEN 1480
  144. 1420 ' NO
  145. 1430 PRINT "I HAVE TO FORFEIT MY MOVE"
  146. 1440 IF Z = 1 THEN 2190
  147. 1450 Z = 1
  148. 1460 GOTO 1690
  149. 1470 ' MAKE THE MOVE
  150. 1480 Z = 0
  151. 1490 PRINT "I WILL MOVE TO ";
  152. 1500 PRINT I3;
  153. 1510 PRINT ", ";
  154. 1520 PRINT C$(J3)
  155. 1530 I = I3
  156. 1540 J = J3
  157. 1550 U = 1
  158. 1560 GOSUB 2820
  159. 1570 C1 = C1 + S1 + 1
  160. 1580 H1 = H1 - S1
  161. 1590 N1 = N1 + 1
  162. 1600 PRINT "THAT GIVES ME ";
  163. 1610 PRINT S1;
  164. 1620 PRINT " OF YOUR PIECES"
  165. 1630 ' PRINT OUT BOARD
  166. 1640 GOSUB 3100
  167. 1650 ' TEST FOR END OF GAME
  168. 1660 IF H1 = 0 THEN 2190
  169. 1670 IF N1 = 64 THEN 2190
  170. 1680 ' HUMAN'S MOVE
  171. 1690 T1 = H
  172. 1700 T2 = C
  173. 1710 PRINT "YOUR MOVE -- (ROW, COL) ";
  174. 1720 INPUT I, X$
  175. 1730 IF I < 0 THEN 1720
  176. 1740 IF I > 8 THEN 1720
  177. 1750 IF I <> 0 THEN 1820
  178. 1760 PRINT "ARE YOU FORFEITING YOUR TURN (Y OR N)"
  179. 1770 INPUT X$
  180. 1780 IF X$ <> "Y" THEN 1710
  181. 1790 IF Z = 1 THEN 2190
  182. 1800 Z = 1
  183. 1810 GOTO 1000
  184. 1820 FOR J = 1 TO 8
  185.    1830 IF C$(J) = X$ THEN 1870
  186. 1840 NEXT J
  187. 1850 GOTO 1720
  188. 1860 ' CHECK IF BLANK
  189. 1870 IF A(I, J) = 0 THEN 1910
  190. 1880 PRINT "SORRY, THAT SQUARE IS OCCUPIED; TRY AGAIN."
  191. 1890 GOTO 1720
  192. 1900 ' CHECK FOR LEGAL NEIGHBOR
  193. 1910 GOSUB 2620
  194. 1920 IF F1 = 1 THEN 1970
  195. 1930 PRINT "SORRY, YOU ARE NOT NEXT TO ONE OF MY PIECES;"
  196. 1940 PRINT "TRY AGAIN"
  197. 1950 GOTO 1720
  198. 1960 ' CHECK IF LEGAL RUN
  199. 1970 U = -1
  200. 1980 GOSUB 2820
  201. 1990 IF S1 > 0 THEN 2030
  202. 2000 PRINT "SORRY, THAT DOESN'T FLANK A ROW; TRY AGAIN"
  203. 2010 GOTO 1720
  204. 2020 ' EVERYTHING LEGAL; MAKE HUMAN'S MOVE
  205. 2030 Z = 0
  206. 2040 PRINT "THAT GIVES YOU ";
  207. 2050 PRINT S1;
  208. 2060 PRINT " OF MY PIECES"
  209. 2070 U = 1
  210. 2080 GOSUB 2820
  211. 2090 H1 = H1 + S1 + 1
  212. 2100 C1 = C1 - S1
  213. 2110 N1 = N1 + 1
  214. 2120 '. PRINT OUT BOARD
  215. 2130 GOSUB 3100
  216. 2140 ' TEST FOR END OF GAME
  217. 2150 IF C1 = 0 THEN 2190
  218. 2160 IF N1 = 64 THEN 2190
  219. 2170 GOTO 1000
  220. 2180 ' END OF GAME WRAPUP
  221. 2190 PRINT
  222. 2200 PRINT "YOU HAVE ";
  223. 2210 PRINT H1;
  224. 2220 PRINT " PIECES AND I HAVE ";
  225. 2230 PRINT C1;
  226. 2240 PRINT " PIECES -- ";
  227. 2250 IF H1 = C1 THEN 2290
  228. 2260 IF H1 > C1 THEN 2310
  229. 2270 PRINT "SORRY, I WON THAT ONE."
  230. 2280 GOTO 2320
  231. 2290 PRINT "A TIE !I"
  232. 2300 GOTO 2500
  233. 2310 PRINT "YOU WON 1"
  234. 2320 C1 = C1 - H1
  235. 2330 IF C1 > 0 THEN 2350
  236. 2340 C1 = -C1
  237. 2350 C1 = (64 * C1) / N1
  238. 2360 PRINT "THAT WAS A ";
  239. 2370 IF C1 < 11 THEN 2490
  240. 2380 IF C1 < 25 THEN 2470
  241. 2390 IF C1 < 39 THEN 2450
  242. 2400 IF C1 < 53 THEN 2430
  243. 2410 PRINT "PERFECT GAME."
  244. 2420 GOTO 2500
  245. 2430 PRINT "WALKAWAY."
  246. 2440 GOTO 2500
  247. 2450 PRINT "FIGHT."
  248. 2460 GOTO 2500
  249. 2470 PRINT "HOT GAME !"
  250. 2480 GOTO 2500
  251. 2490 PRINT "SQUEAKER !!"
  252. 2500 PRINT
  253. 2510 PRINT "DO YOU WANT TO PLAY ANOTHER GAME (Y OR N) ";
  254. 2520 INPUT X$
  255. 2530 IF X$ = "Y" THEN 700
  256. 2540 IF X$ <> "N" THEN 2520
  257. 2550 PRINT "THANKS FOR PLAYING."
  258. 2560 STOP
  259. 2570 '
  260. 2580 ' SUBROUTINE TEST-FOR-PROPER-NEIGHBOR
  261. 2590 ' ASSUMES:
  262. 2600 ' I,J LOCATES A BLANK SQUARE
  263. 2610 ' YOU HOPE TO SEE AN ADJACENT T2 (. -T1)
  264. 2620 FOR I1 = -1 TO 1
  265.    2630 FOR J1 = -1 TO 1
  266.        2640 IF A(I + I1, J + J1) = T2 THEN 2710
  267.    2650 NEXT J1
  268. 2660 NEXT I1
  269. 2670 ' NO T2 FOUND; FAILURE
  270. 2680 F1 = 0
  271. 2690 RETURN
  272. 2700 ' SUCCESS
  273. 2710 F1 = 1
  274. 2720 RETURN
  275. 2730 ' SUBROUTINE SCORE-AND-UPDATE
  276. 2740 ' ASSUMES:
  277. 2750 ' (I,J) IS A TENTATIVE PLACE FOR A PIECE T1.
  278. 2760 ' WANT RUNS OF T2 . -T1, TERMINATED BY A T1.
  279. 2770 ' IF U IS TRUE (1), MARK THOSE RUNS AS T1'S.
  280. 2780 ' RETURN SUM OF ALL RUNS (T2'S ONLY) IN S1.
  281. 2790 ' MAIN PROGRAM CONTAINS THE FOLLOWING ARRAYS:
  282. 2800 ' i4: 0 -1 -1 -1  0  1 1 1
  283. 2810 ' J4: 1  1  0 -1 -1 -1 0 1
  284. 2820 S1 = 0
  285. 2830 FOR K = 1 TO 8
  286.    2840 I5 = I4(K)
  287.    2850 J5 = J4(K)
  288.    2860 I6 = I + I5
  289.    2870 J6 = J + J5
  290.    2880 S3 = 0
  291.    2890 IF A(I6, J6) <> T2 THEN 3070
  292.    2900 ' LOOP THROUGH THE RUN
  293.    2910 S3 = S3 + 1
  294.    2920 I6 = I6 + I5
  295.    2930 J6 = J6 + J5
  296.    2940 IF A(I6, J6) = T1 THEN 2970
  297.    2950 IF A(I6, J6) = 0 THEN 3070
  298.    2960 GOTO 2910
  299.    2970 S1 = S1 + S3
  300.    2980 IF U <> 1 THEN 3070
  301.    2990 ' UPDATE BOARD
  302.    3000 I6 = I
  303.    3010 J6 = J
  304.    3020 FOR K1 = 0 TO S3
  305.        3030 A(I6, J6) = T1
  306.        3040 I6 = I6 + I5
  307.        3050 J6 = J6 + J5
  308.    3060 NEXT K1
  309. 3070 NEXT K
  310. 3080 RETURN
  311. 3090 ' SUBROUTINE PRINT-BOARD
  312. 3100 PRINT
  313. 3110 PRINT "    A B C D E F G H"
  314. 3120 FOR I = 1 TO 8
  315.    3130 PRINT I;
  316.    3140 FOR J = 1 TO 8
  317.        3150 PRINT " ";
  318.        3160 PRINT D$(A(I, J) + 1);
  319.    3170 NEXT J
  320.    3180 PRINT
  321. 3190 NEXT I
  322. 3200 PRINT
  323. 3210 RETURN
  324. 3220 END

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Try an Othello game that was published in 1977
« Reply #1 on: May 11, 2021, 09:18:37 pm »
Cool classic. Ran just fine. Thank you for sharing.
Logic is the beginning of wisdom.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Try an Othello game that was published in 1977
« Reply #2 on: May 19, 2021, 02:27:38 pm »
Victory 64-0 by 5 steps or in 9 steps

Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline justsomeguy

  • Newbie
  • Posts: 47
    • View Profile
Re: Try an Othello game that was published in 1977
« Reply #3 on: May 19, 2021, 07:25:41 pm »
@DANILIN Cool thanks for that!