1 REM TACKER:  pngwen (Robert Lowe)
2 REM DATE:    08-Aug-16 16:59:12
3 REM CHECKED: bwbasic
10 REM PENNEY'S GAME
11 REM   BY ROBERT LOWE (PNGWEN) 8/8/2016
20 PRINT "WELCOME TO PENNEY'S GAME!"
30 PRINT "THE FIRST SEQUENCE TO APPEAR IN CONSECUTIVE COINFLIPS WINS."
40 PRINT "WE'LL PLAY BEST 3 OUT OF FIVE"
60 PRINT "WOULD YOU LIKE TO GO FIRST (Y/N)";
70 INPUT G$
80 IF LEFT$(G$,1)="Y" OR LEFT$(G$,1)="y" THEN 100
90 GOTO 200
100 REM PLAYER GOES FIRST
110 GOSUB 150
120 C$=MID$(P$,2,1)
130 IF C$="H" THEN C$="T":GOTO 140
135 C$="H"
140 C$=C$+LEFT$(P$,2)
145 PRINT "MY SEQUENCE: "+C$:GOTO 300
150 REM GET PLAYER SEQUENCE (AND VALIDATE!)
151 PRINT "USE H AND T TO ENTER A SEQUENCE OF FLIPS"
152 PRINT "YOUR SEQUENCE";:INPUT P$
160 HC=0:TC=0
170 FOR I = 1 TO LEN(P$)
175 IF MID$(P$,I,1) = "H" THEN HC=HC+1
176 IF MID$(P$,I,1) = "T" THEN TC=TC+1
177 NEXT I
180 IF LEN(P$)<>3 OR HC+TC <> 3 THEN PRINT "INVALID SEQUENCE":GOTO 151
190 RETURN
200 REM COMPUTER GOES FIRST
210 C$=""
220 FOR I = 1 TO 3
230 F = INT(2*RND()+1)
240 IF F = 1 THEN C$=C$+"H"
250 IF F = 2 THEN C$=C$+"T"
260 NEXT I
270 PRINT "MY SEQUENCE: "+C$
280 GOSUB 150
300 REM PLAY THE GAME
310 PW=0:CW=0:F$="":CW=0:FH$="":CW=0
320 FH$=""
325 PRINT "YOU: "+P$+" VS ME: "+C$+" ROUND "+STR$(PW+CW+1)
326 PRINT "   ";
330 F=INT(2*RND()+1)
340 IF F = 1 THEN F$="H"
350 IF F = 2 THEN F$="T"
360 PRINT F$;
370 FH$=RIGHT$(FH$+F$,3)
375 IF FH$ = P$ OR FH$=C$ THEN PRINT ""
380 IF FH$=P$ THEN PRINT "YOU WIN THIS ROUND!":PW=PW+1:GOTO 400
385 IF FH$=C$ THEN PRINT "I WIN THIS ROUND!":CW=CW+1:GOTO 400
390 GOTO 330
400 PRINT "SCORE: YOU " + STR$(PW) + "  ME " + STR$(CW)
410 IF PW+CW <> 5 THEN GOTO 320
420 IF PW > CW THEN PRINT "YOU WIN THE GAME!"
430 IF PW < CW THEN PRINT "I WIN THE GAME!"
440 PRINT "PLAY AGAIN";
450 INPUT G$
460 IF MID$(G$,1,1)="Y" OR MID$(G$,1,1)="y" THEN GOTO 10