Multiple Tic-Tac-Toe Written by mjhayes@cs.buffalo.edu September 17, 1997 This program uses the graphics from Reversi. You can substitute any cartridge with a cursor, but you will need to find the location of the cursor and set a value to N before the last line. Before the game starts, a tan grid will be set up with fifteen black spaces. Both players share the left keypad. Use buttons 2, 4, 6, and 8 on the left keypad to move the cursor, and Enter to drop a piece. This is the traditional game of Tic-Tac-Toe, but there are fifteen boards, and a player may place a piece anywhere on any of the fifteen boards. Player one is blue, and player two is red. The color of the cursor indicates whose turn it is. The game ends and scores are tallied when all but one space are occupied (One space is left out so both players get an equal number of turns). After the scores are tallied, the scores and the winner are displayed. Press RTN to play again. The algorithm for tallying scores is not very efficient, and it takes about three minutes to tally scores. I challenge all of you to rewrite this program so it doesn't take as long to tally scores. Any takers? 10 SET A$="PLAYER ONE WINS." 20 SET B$="PLAYER TWO WINS." 30 SET C$="HIT RTN TO RESTART." 40 D=2 ; The cursor is a hi-res sprite. 50 CALL SHOW ; Display the cursor. 60 FM(0)=0 ; Two numbers will be displayed in one row, in regular notation, with two places to the right of the decimal point. 70 FM(4)=4 ; Display text in dark green. 80 PRIN"MULTIPLE TIC-TAC-TOE" 90 PRIN"BY MIKE HAYES" 100 PRIN"DOLM: 8/28/1998" ; Display credits. RUN 10 CLR 20 F=0 30 G=0 ; Reset the scores. 40 DATA 0,0,0,3 50 FOR B=0 TO 219 ; Draw the boards.{ 60 READ I 70 BK(B)=I ; Draw the vertical stripes. 80 NEXT B 90 FOR B=0 TO 2 100 J=(B*80)+60 110 K=J+19 120 FOR I=J TO K 130 BK(I)=3 ; Draw the horizontal stripes. 140 NEXT I 150 NEXT B ; } 160 XP(0)=80 170 YP(0)=80 ; Put the cursor into position. 180 FOR I=0 TO 66 ; Each player takes 67 turns. 190 CO(0)=9 ; Blue player goes first. 200 CALL HAND ; Poll the left hand controller. 210 IF(H=2)YP(0)=YP(0)-8 ; Was the 2 key pressed? 220 IF(H=4)XP(0)=XP(0)-8 ; Was the 4 key pressed? 230 IF(H=6)XP(0)=XP(0)+8 ; Was the 6 key pressed? 240 IF(H=8)XP(0)=XP(0)+8 ; Was the 8 key pressed? 250 B=(YP(0)*2.5)-20 260 B=B+(XP(0)/8)-1 ; Calculate the block to draw. 270 IF(H<110)GOTO 200 ; Was Enter pressed? 280 IF(BK(B)>0)GOTO 200 ; Was it a valid move? 290 BK(B)=CO(0)-8 ; Draw the block. 300 IF(CO(0)>9)GOTO 330 ; Whose turn is it? 310 CO(0)=10 320 GOTO 200 330 NEXT I 340 XP(0)=0 ; Hide the cursor. 350 FOR B=1 TO 21 ; Calculate the scores. 360 IF(B=2)B=19 370 FOR I=0 TO 216 380 J=I+B 390 K=J+B 400 IF(BK(J)=BK(I))GOTO 440 410 NEXT I 420 NEXT B 430 GOTO 490 440 IF(BK(K)= BK(J))GOTO 460 450 GOTO 410 460 IF(BK(K)=1)F=F+1 470 IF(BK(K)=2)G=G+1 480 GOTO 410 490 CLR 500 PRIN "SCORES:",F,G 510 IF(F=G)PRIN "NOBODY WINS." 520 IF(F>G)PUT A$ 530 IF(F