HIMEM=8192
1 REM LARRY NELSON - FROM 1977
10 DIM D(5),C(14),A$(5)
20 PRINT "YAHTZEE FOR APPLE 1"
30 INPUT "INSTRUCTIONS Y/N",A$
40 IF A$="Y" THEN GOSUB 1000
50 FOR I=1 TO 13:C(I)=-1:NEXT I
55 C(14)=0
60 FOR J=1TO 13
70 FOR I=1 TO 5
80 D(I)=RND(6)+1
85 NEXT I
90 GOSUB 2000
100 FOR K=2 TO 1 STEP -1
110 PRINT K;:PRINT" ROLL";:IF K>1 THEN PRINT"S";
120 PRINT " LEFT." 
130 INPUT"DISCARD",B
140 IF B<1 OR B>6 THEN 200
150 L=1 
160 IF D(L)=B THEN D(L)=0
165 IF D(L)=0 THEN L=5
170 L=L+1
180 IF L<6 THEN 160
190 GOTO 130
200 FOR I=1 TO 5
210 IF D(I)>0 THEN 240
220 D(I)=RND(6)+1
240 NEXT I
250 GOSUB 2000
255 NEXT K
260 INPUT "SCORE WHAT CATEGORY",B
270 IF B<1 THEN 340
280 IFB>13 THEN 340
290 IF C(B)#-1 THEN 340
300 GOSUB 3000
310 NEXT J
320 PRINT "CONGRATULATIONS - YOU SCORED ";T+U+G
330 END
340 PRINT "YOU CAN'T DO THAT!"
350 GOTO 260
1000 REM INSTRUCTIONS
1010 PRINT "THIS GAME IS PLAYED JUST LIKE THE"
1020 PRINT "ORIGINAL GAME OF 'YAHTZEE'. THE COMPUTER"
1030 PRINT "WILL ROLL THE DICE AND KEEP THE SCORE."
1040 PRINT "YOU MAY DISCARD ANY OR ALL DICE BEFORE"
1050 PRINT "RE-ROLLING. JUST TYPE THE VALUE OF"
1060 PRINT "A DIE YOU WANT TO DISCARD."
1070 PRINT "TYPING A NUMBER BELOW 1 OR ABOVE 6 WILL START THE RE-ROLL."
1080 INPUT "CONTINUE",A$
1999 RETURN
2000 REM DRAW SCORECARD AND DICE
2010 PRINT"1-ACES";:IF C(1) =-1 THEN 2020
2015 TAB12:PRINT C(1);
2020 TAB 20:PRINT "7-3 OF A KIND";:IF C(7)=-1 THEN 2030
2025 TAB 35:PRINT C(7);
2030 PRINT:PRINT "2-TWOS";:IF C(2)=-1 THEN 2040
2035 TAB 12:PRINT C(2);
2040 TAB 20:PRINT "8-4 OF A KIND";:IF C(8)=-1 THEN2050
2045 TAB 35:PRINT C(8);
2050 PRINT:PRINT"3-THREES";:IF C(3)=-1 THEN 2060
2055 TAB12:PRINT C(3);
2060 TAB 20:PRINT "9-FULL HOUSE";:IF C(9)=-1 THEN 2070
2065 TAB35:PRINT C(9);
2070 PRINT:PRINT "4-FOURS";:IF C(4)=-1 THEN 2080
2075 TAB 12:PRINT C(4);
2080 TAB 20:PRINT "10-SM.STRGHT.";:IF C(10)=-1 THEN 2090
2085 TAB 35:PRINT C(10);
2090 PRINT:PRINT "5-FIVES";:IF C(5)=-1 THEN 2100
2095 TAB 12:PRINT C(5);
2100 TAB 20:PRINT "11-LG.STRGHT.";:IF C(11)=-1 THEN 2110
2105 TAB 35:PRINT C(11);
2110 PRINT:PRINT"6-SIXES";:IF C(6)=-1 THEN 2120
2115 TAB 12:PRINT C(6);
2120 TAB 20:PRINT "12-YAHTZEE";:IF C(12)=-1 THEN 2130
2125 TAB 35:PRINT C(12);
2130 PRINT:T=0
2140 FOR I=1 TO 6
2150 IF C(I)>-1 THEN T=T+C(I)
2160 NEXT I
2170 PRINT "SUB-TOTAL";:TAB 12:PRINT T;
2180 TAB 20:PRINT"13-CHANCE";:IF C(13)=-1 THEN 2185
2182 TAB 35:PRINT C(13);
2185 PRINT:PRINT "BONUS";:IF T<65 THEN 2200
2190 U=35:TAB 12:PRINT 35;
2200 TAB20:PRINT "YAHTZEE BONUS";:IF C(14)=0 THEN 2205
2202 TAB35:PRINT C(14)
2205 PRINT
2210 G=0: FOR I=7 TO 14
2220 IF C(I)>-1 THEN G=G+C(I)
2230 NEXT I
2240 PRINT "UPPER";:TAB 12:PRINT T+U;
2250 TAB 20:PRINT "LOWER";:TAB 35:PRINT G
2260 TAB 20:PRINT "TOTAL";
2270 TAB 35:PRINT T+U+G
2300 A$="-----"
2310 PRINT A$,A$,A$,A$,A$
2320 FOR I=1 TO 5
2325 TAB I*8-7
2330 IF D(I)=1 THEN PRINT "!   !";
2340 IF D(I)=2 OR D(I)= 3 THEN PRINT "!*  !";
2350 IF D(I)>3 THEN PRINT "!* *!";
2360 NEXT I:PRINT
2370 FOR I=1 TO 5
2375 TAB I*8-7
2380 IF D(I)MOD 2 THEN PRINT "! * !";
2390 IF D(I)=2 OR D(I)=4 THEN PRINT "!   !";
2400 IF D(I)=6 THEN PRINT "!* *!";
2410 NEXT I:PRINT
2420 FOR I= 1 TO 5
2425 TAB I*8-7
2430 IF D(I)>3 THEN PRINT "!* *!";
2440 IF D(I)=2 OR D(I)=3 THEN PRINT "!  *!";
2450 IF D(I)=1 THEN PRINT "!   !";
2460 NEXT I:PRINT
2470 PRINT A$,A$,A$,A$,A$
2480 RETURN
3000 REM SCORE CATEGORY E IS POINTER FOR SCORE & P IS SCORE RETURNED
3010 E=100*B+3000
3020 P=0:S=0
3030 GOSUB E
3040 C(B) = P
3050 IF C(12)<50 THEN 3099
3060 P=0:GOSUB 4200
3070 IF P=0 THEN 3099
3080 IF C(14)<0 THEN C(14)=0
3090 C(14)=C(14)+100
3099 RETURN
3100 REM ONES
3200 REM TWOS
3300 REM THREES
3400 REM FOURS
3500 REM FIVES
3600 REM SIXES
3610 FOR I=1 TO 5
3620 IF D(I)=B THEN P=P+B
3630 NEXT I
3640 RETURN
3700 REM 3 OF A KIND
3710 F=0
3720 GOSUB 4400
3730 FOR I=1 TO 3
3740 IF D(I)=D(I+2) THEN F=1
3750 NEXT I
3770 IF F=1 THEN 4300
3780 RETURN
3800 REM 4 OF A KIND
3810 GOSUB 4400
3820 IF D(1)=D(4) THEN 4300
3830 IF D(2)=D(5) THEN 4300
3840 RETURN
3900 REM FULL HOUSE
3910 GOSUB 4400
3920 IF (D(1)#D(2)) OR (D(4)#D(5)) THEN 3940
3930 IF (D(3) = D(1)) OR (D(3) = D(5)) THEN P=25 
3940 RETURN
4000 REM SMALL STRAIGHT
4010 GOSUB 4400
4020 FOR I=1 TO 4
4030 IF D(I)=3 THEN T1=1
4040 IF D(I+1)=4 THEN T2=1
4050 IF D(I)+1=D(I+1) THEN P1=P1+1
4060 NEXT I
4070 IF C(12)>0 THEN GOSUB 4230
4080 P1=P1*T1*T2: IF P1>0 OR P=50 THEN P=30
4090 RETURN
4100 REM LARGE STRAIGHT
4110 GOSUB 4400
4120 FORI=1 TO 4
4130 IF D(I)+1=D(I+1) THEN T3=T3+1
4140 NEXT I
4150 IF C(12)>0 THEN GOSUB 4230
4160 IF P=50 OR T3=4 THEN P=40
4170 RETURN
4200 REM YAHTZEE
4210 P=0
4220 GOSUB 4400
4230 IF D(1)=D(5) THEN P=50
4240 RETURN
4300 REM CHANCE
4310 FOR I=1 TO 5
4320 P=P+D(I)
4330 NEXT I
4340 RETURN
4400 REM SORT
4410 FOR H=1 TO 4
4420 FOR I=1 TO 4
4430 IF D(I)<= D(I+1) THEN 4470
4440 S=D(I)
4450 D(I)=D(I+1)
4460 D(I+1)=S
4470 NEXT I
4480 NEXT H
4490 RETURN

