Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0020/learn1.gam
There are 2 other files named learn1.gam in the archive. Click here to see a list.
100' NAME--LEARN1
110'
120' DESCRIPTION--LEARNS TO PLAY GAME OF "21".
130'
140' SOURCE--UNONOWN
150'
160' INSTRUCTIONS--TYPE "RUN" TO PLAY AND "LIST" FOR INSTRUCTIONS.
170'
180'
190' * * * * * * * MAIN PROGRAM * * * * * * * * * *
200'
210 REM THIS PROGRAM LEARNS TO PLAY THE GAME OF "21". STARTING WITH
220 REM SOME NUMBER (TRADITIONALLY , BUT NOT NECESSARILY, 21),
230 REM EACH PLAYER IN TURN SUBTRACTS A NUMBER BETWEEN 1 AND 4 FROM
240 REM THE STARTING NUMBER/ THE OBJECT IS NOT TO TAKE THE LAST NUMBER.
250 REM THIS PROGRAM LEARNS , STARTING FROM A CONDITION OF COMPLETE
260 REM STUPIDITY, TO PLAY A PERFECT GAME.
270 REM THE PROGRAM WILL PLAY WITH ANY NUMBER BETWEEN 1 AND 25.
280 REM IT LEARNS VERY SLOWLY, SO THAT A NUMBER BETWEEN FIVE AND TEN
290 REM IS MOST PRACTICAL. YOU MAY SELECT THE NUMBER TO BE PLAYED WITH
300 REM AT THE ONSET OF PLAY. YOU MUST ALSO SELECT THE "LEARNING
310 REM PARAMETER", WHICH DETERMINES THE SPEED OF LEARNING. A PARAMETER
320 REM OF 1 YIELDS NO LEARNING - 2 IS A REASONABLE NUMBER. TRY EXPERI-
330 REM MENTING WITH DIFFERENT VALUES. THE STARTING NUMBER AND LEARNING
340 REM PARAMETER MUST BE ENTERED, SEPARATED BY A COMMA, WHEN THE PROGRAM
350 REM REQUESTS THEM. THE PROGRAM WILL ALSO OFFER TO PRINT OUT THE
360 REM PROBABILITY MATRIX, WHICH DETERMINES THE PROBABILITY OF MAKING
370 REM ANY MOVE IN ANY SITUATION. IT IS INTERESTING TO WATCH THIS
380 REM MATRIX CHANGE AS PLAY PROGRESSES.
390 PRINT "IF YOU WANT INSTRUCTIONS 'LIST' THIS PROGRAM."
400 DIM P(25,4), Q(50)
410 FOR N = 2 TO 25
420 FOR M = 1 TO 4
430 LET P(N,M) = .25
440 NEXT M
450 NEXT N
460 LET P(1,1)=1
470 LET P(1,2) =0
480 LET P(1,3)=0
490 LET P(1,4) =0
500 PRINT
510 PRINT "HOW LARGE A NUMBER AND LEARNING PARAMETER SHALL WE PLAY WITH";
520 INPUT M,K
530 IF M>25 THEN 550
540 GOTO 570
550 PRINT "NUMBER TOO LARGE= TRY AGAIN."
560 GOTO 520
570 LET N = M
580 LET S=-1
590 PRINT
600 PRINT "SHALL I GO FIRST";
610 INPUT X$
620 IF X$="YES" THEN 830
630 IF X$="NO" THEN 660
640 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
650 GOTO 610
660 PRINT "MAKE A MOVE"
670 INPUT A
680 IF A=0 THEN 710
690 IF A>4 THEN 710
700 GOTO 730
710 PRINT "ILLEGAL MOVE. TRY AGAIN."
720 GOTO 670
730 LET N= N-A
740 IF N=0 THEN 760
750 GOTO 800
760 PRINT "I WIN"
770 LET L=K
780 GOSUB 1080
790 GOTO 570
800 IF N>0 THEN 830
810 LET N = N+A
820 GOTO 710
830 GOTO840
840 REM MOVE MAKER
850 LET B=RND
860 LET U = 0
870 FOR C=1 TO 4
880 LET U = U +P(N,C)
890 IF B<U THEN 930
900 NEXT C
910 PRINT "HELP 1"
920 GOTO 1360
930 LET N = N-C
940 IF N<0 THEN 960
950 GOTO 980
960 LET N=N+C
970 GOTO 850
980 PRINT"MY MOVE IS "C" "N" REMAINS."
990 LET S=S+2
1000 LET Q(S) =N+C
1010LET Q(S+1) = C
1020 IF N=0 THEN 1040
1030 GOTO 660
1040 LET L=1/K
1050 PRINT "YOU WIN."
1060 GOSUB 1080
1070 GOTO 570
1080 LET A = -1
1090 LET A= A+2
1100 IF A>S THEN 1220
1110 LET E=Q(A)
1120 LET F=Q(A+1)
1130 LET P(E,F) = P(E,F)*L
1140 LET T = 0
1150 FOR R=1 TO 4
1160 LET T = T +P(E,R)
1170 NEXT R
1180 FOR D= 1 TO 4
1190LET P(E,D)=P(E,D)/T
1200 NEXT D
1210 GOTO 1090
1220 PRINT "SHALL I PRINT THE PROBABILITY MATRIX";
1230 INPUT X$
1240 IF X$="NO" THEN 1350
1250 IF X$="YES" THEN 1280
1260 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
1270 GOTO 1230
1280 PRINT
1290 PRINT " MOVE"
1300 PRINT "NUMBER","1","2","3","4"
1310 FOR N= 1 TO M
1320 PRINT N, P(N,1),P(N,2),P(N,3),P(N,4)
1330 NEXT N
1340 PRINT
1350 RETURN
1360END