-
Notifications
You must be signed in to change notification settings - Fork 2
/
chomp.bas
105 lines (105 loc) · 2.62 KB
/
chomp.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
1 "CHOMP.BAS, from _BASIC Computer Games_ (1978), edited by David H. Ahl."
1 "Reproduced at https://www.atariarchives.org/basicgames/showpage.php?page=44"
1
1 "Adapted for Tiny BASIC in 2020."
1
10 PR SP(33);"CHOMP"
20 PR SP(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PR$PR$PR
40 DIM A(10,10)
110 PR "*** THE GAME OF CHOMP *** COPYRIGHT PCC 1973 ***"
110 PR
120 PR "THIS IS THE GAME OF CHOMP (SCIENTIFIC AMERICAN, JAN 1973)"
130 PR "DO YOU WANT THE RULES (1=YES, 0=NO!)";
140 IN R
150 IF R=0 GOTO 340
160 LET F=1
170 LET R=5
180 LET C=7
190 PR "CHOMP IS FOR 1 OR MORE PLAYERS (HUMANS ONLY)."
200 PR
210 PR "HERE'S HOW A BOARD LOOKS (THIS ONE IS 5 BY 7):"
220 GOSUB 540
230 PR
240 PR "THE BOARD IS A BIG COOKIE - R ROWS HIGH AND C COLUMNS"
250 PR "WIDE. YOU INPUT R AND C AT THE START. IN THE UPPER LEFT"
260 PR "CORNER OF THE COOKIE IS A POISON SQUARE (P). THE ONE WHO"
270 PR "CHOMPS THE POISON SQUARE LOSES. TO TAKE A CHOMP, TYPE THE"
280 PR "ROW AND COLUMN OF ONE OF THE SQUARES ON THE COOKIE."
290 PR "ALL OF THE SQUARES BELOW AND TO THE RIGHT OF THAT SQUARE"
300 PR "(INCLUDING THAT SQUARE, TOO) DISAPPEAR -- CHOMP!!"
310 PR "NO FAIR CHOMPING SQUARES THAT HAVE ALREADY BEEN CHOMPED,"
320 PR "OR THAT ARE OUTSIDE THE ORIGINAL DIMENSIONS OF THE COOKIE."
330 PR
340 PR "HERE WE GO..."
360 LET F=0
370 FOR I=1 TO 10
372 FOR J=1 TO 10
375 LET A(I,J)=0
377 NXT J
379 NXT I
380 PR
390 PR "HOW MANY PLAYERS";
400 IN P
410 LET X=0
420 PR "HOW MANY ROWS";
430 IN R
440 IF R <= 9 GOTO 470
450 PR "TOO MANY ROWS (9 IS MAXIMUM). NOW, ";
460 GOTO 420
470 PR "HOW MANY COLUMNS";
480 IN C
490 IF C <= 9 GOTO 530
500 PR "TOO MANY COLUMNS (9 IS MAXIMUM). NOW, ";
510 GOTO 470
530 PR
540 FOR I=1 TO R
550 FOR J=1 TO C
560 LET A(I,J)=1
570 NXT J
580 NXT I
590 LET A(1,1)=-1
610 PR
620 PR SP(7);"1 2 3 4 5 6 7 8 9"
630 FOR I=1 TO R
640 PR I;SP(5);
650 FOR J=1 TO C
660 IF A(I,J)=-1 GOTO 700
670 IF A(I,J)=0 GOTO 720
680 PR "* ";
690 GOTO 710
700 PR "P ";
710 NXT J
720 PR
730 NXT I
740 PR
750 IF F=0 GOTO 780
760 RET
780 LET X=X+1
790 LET W=X-X/P*P
800 IF W <> 0 GOTO 820
810 LET W=P
820 PR "PLAYER";W
830 PR "COORDINATES OF CHOMP (ROW,COLUMN)";
840 IN Y,Z
850 IF Y<1 GOTO 920
860 IF Y>R GOTO 920
870 IF Z<1 GOTO 920
880 IF Z>C GOTO 920
890 IF A(Y,Z)=0 GOTO 920
900 IF A(Y,Z)=-1 GOTO 1010
910 GOTO 940
920 PR "NO FAIR. YOU'RE TRYING TO CHOMP ON EMPTY SPACE!"
930 GOTO 820
940 FOR I=Y TO R
950 FOR J=Z TO C
960 LET A(I,J)=0
970 NXT J
980 NXT I
990 GOTO 610
1010 PR "YOU LOSE, PLAYER";W
1020 PR
1030 PR "AGAIN (1=YES, 0=NO!)";
1040 IN R
1050 IF R=1 GOTO 340
1060 END