1 DIM A(50),B(15)
2 DEF FNA(X)=INT(10*RND(X))
3 DEF FNB(X)=X-100*INT(X/100)
4 PRINT "WELCOME TO THE HALLDEN CASINO.  WE EACH HAVE $200"
5 PRINT "I WILL OPEN THE BETTING BEFORE THE DRAW; YOU OPEN AFTER"
6 PRINT "WHEN YOU FOLD, BET 0;  TO CHECK, BET .5"
7 PRINT "ENOUGH TALK -- LET'S GET DOWN TO BUSINESS"
8 PRINT
9 LET O=1
10 LET C=200
11 LET S=200
12 LET P=0
14 PRINT
15 IF C<=5 THEN 367
16 PRINT "THE ANTE IS $5.  I WILL DEAL"
17 PRINT
18 IF S>5 THEN 20
19 GOSUB 383
20 LET P=P+10
21 LET S=S-5
22 LET C=C-5
23 FOR Z=1 TO 10
24 GOSUB 174
25 NEXT Z
26 PRINT "YOUR HAND:"
27 LET N=1
28 GOSUB 185
29 LET N=6
30 LET I=2
31 GOSUB 217
32 PRINT
33 IF I<>6 THEN 47
34 IF FNA (0)<=7 THEN 37
35 LET X=11100
36 GOTO 42
37 IF FNA (0)<=7 THEN 40
38 LET X=11110
39 GOTO 42
40 IF FNA (0)>=1 THEN 45
41 LET X=11111
42 LET I=7
43 LET Z=23
44 GOTO 58
45 LET Z=1
46 GOTO 51
47 IF U>=13 THEN 54
48 IF FNA (0)>=2 THEN 50
49 GOTO 42
50 LET Z=0
51 LET K=0
52 PRINT "I CHECK"
53 GOTO 62
54 IF U<=16 THEN 57
55 LET Z=2
56 IF FNA (0)>=1 THEN 58
57 LET Z=35
58 LET V=Z+FNA(0)
59 GOSUB 348
60 PRINT  "I'LL OPEN WITH ";V
61 LET K=V
62 GOSUB 305
63 GOSUB 65
64 GOTO 82
65 IF I<>3 THEN 76
66 PRINT
67 PRINT "I WIN"
68 LET C=C+P
69 PRINT "NOW I HAVE $";C;"AND YOU HAVE $";S
70 PRINT "DO YOU WISH TO CONTINUE";
71 INPUT H$
72 IF H$="YES" THEN 12
73 IF H$="NO" THEN 410
74 PRINT "ANSWER YES OR NO"
75 GOTO 70
76 IF I<>4 THEN 81
77 PRINT
78 PRINT "YOU WIN"
79 LET S=S+P
80 GOTO 69
81 RETURN
82 PRINT
83 PRINT "NOW WE DRAW -- HOW MANY CARDS DO YOU WANT";
84 INPUT T
85 IF T=0 THEN 98
86 LET Z=10
87 IF T<4 THEN 90
88 PRINT "YOU CAN'T DRAW MORE THAN THREE CARDS"
89 GOTO 84
90 PRINT "WHAT ARE THEIR NUMBERS"
91 FOR Q=1 TO T
92 INPUT U
93 GOSUB 173
94 NEXT Q
95 PRINT "YOUR NEW HAND:"
96 LET N=1
97 GOSUB 185
98 LET Z=10+T
99 FOR U=6 TO 10
100 IF INT(X/10^(U-6))<>10*INT(X/10^(U-5)) THEN 102
101 GOSUB 173
102 NEXT U
103 PRINT
104 PRINT "I AM TAKING ";Z-10-T;"CARD" ;
105 IF Z=11+T THEN 109 
106 PRINT "S"
107 PRINT 
108 GOTO 110 
109 PRINT
110 LET N=6 
111 LET V=I
112 LET I=1
113 GOSUB 217
115 LET M=D 
116 IF V<>7 THEN 119 
117 LET Z=28 
118 GOTO 133 
119 IF I<>6 THEN 122 
120 LET Z=1
121 GOTO 133
122 IF U>=13 THEN 127
123 LET Z=2
124 IF FNA (0)<>6 THEN 126
125 LET Z=19
126 GOTO 133
127 IF U>=16 THEN 132
128 LET Z=19
129 IF FNA (0)<>8 THEN 131
130 LET Z=11
131 GOTO 133
132 LET Z=2
133 LET K=0
134 GOSUB 305
135 IF T<>.5 THEN 145
136 IF V=7 THEN 140
137 IF I<>6 THEN 140
138 PRINT "I'LL CHECK"
139 GOTO 146
140 LET V=Z+FNA(0)
141 GOSUB 348
142 PRINT "I'LL BET ";V
143 LET K=V
144 GOSUB 306
145 GOSUB 65
146 PRINT
147 PRINT "NOW WE COMPARE HANDS"
148 LET J$=H$
149 LET K$=I$
150 PRINT "MY HAND:"
151 LET N=6
152 GOSUB 185
153 LET N=1
154 GOSUB 217
155 PRINT
156 PRINT "YOU HAVE ";
157 LET K=D
158 GOSUB 369
159 LET H$=J$
160 LET I$=K$
161 LET K=M
162 PRINT "AND I HAVE ";
163 GOSUB 369
164 IF R>U THEN 67
165 IF U>R THEN 78
166 IF H$="A FLUS" THEN 170
167 PRINT "THE HAND IS DRAWN"
168 PRINT "ALL $";P;" REMAIN IN THE POT"
169 GOTO 14
170 IF FNB (M)>FNB (D) THEN 67
171 IF FNB (D)>FNB (M) THEN 78
172 GOTO 167
173 LET Z=Z+1
174 LET A(Z)=INT(1000*RND(0))
175 IF INT(A(Z)/100)>3 THEN 174
176 IF A(Z)-100*INT(A(Z)/100)>12 THEN 174
177 FOR K=1 TO Z-1
178 IF A(Z)=A(K) THEN 174
179 NEXT K
180 IF Z<=10 THEN 184
181 LET N=A(U)
182 LET A(U)=A(Z)
183 LET A(Z)=N
184 RETURN
185 FOR Z=N TO N+4
186 PRINT Z;"--  ";
187 GOSUB 195
188 PRINT " OF";
189 GOSUB 207
190 IF Z/2<>INT(Z/2) THEN 192
191 PRINT
192 NEXT Z
193 PRINT
194 RETURN
195 LET K=FNB (A(Z))
196 IF K<>9 THEN 198
197 PRINT "JACK";
198 IF K<>10 THEN 200
199 PRINT "QUEEN";
200 IF K<>11 THEN 202
201 PRINT "KING";
202 IF K<>12 THEN 204
203 PRINT "ACE";
204 IF K>=9 THEN 206
205 PRINT K+2;
206 RETURN
207 LET K=INT(A(Z)/100)
208 IF K<>0 THEN 210
209 PRINT " CLUBS",
210 IF K<>1 THEN 212
211 PRINT " DIAMONDS",
212 IF K<>2 THEN 214
213 PRINT " HEARTS",
214 IF K<>3 THEN 216
215 PRINT " SPADES",
216 RETURN
217 LET U=0
218 FOR Z=N TO N+4
219 LET B(Z)=FNB(A(Z))
220 IF Z=N+4 THEN 223
221 IF INT(A(Z)/100) <>INT(A(Z+1)/100) THEN 223
222 LET U=U+1
223 NEXT Z
224 IF U<>4 THEN 231
225 LET X=11111
226 LET D=A(N)
227 LET H$="A FLUS"
228 LET I$="H IN"
229 LET U=15
230 RETURN
231 FOR Z=N TO N+3
232 FOR K=Z+1 TO N+4
233 IF B(Z)<=B(K) THEN 239
234 LET X=A(Z)
235 LET A(Z)=A(K)
236 LET B(Z)=B(K)
237 LET A(K)=X
238 LET B(K)=A(K)-100*INT(A(K)/100)
239 NEXT K
240 NEXT Z
241 LET X=0
242 FOR Z=N TO N+3
243 IF B(Z)<>B(Z+1) THEN 247
244 LET X=X+11*10^(Z-N)
245 LET D=A(Z)
246 GOSUB 276
247 NEXT Z
248 IF X<>0 THEN 262
249 IF B(N)+3<>B(N+3) THEN 252
250 LET X=1111
251 LET U=10
252 IF B(N+1)+3<>B(N+4) THEN 262
253 IF U<>10 THEN 260
254 LET U=14
255 LET H$="STRAIG"
256 LET I$="HT"
257 LET X=11111
258 LET D=A(N+4)
259 RETURN
260 LET U=10
261 LET X=11110
262 IF U>=10 THEN 269
263 LET D=A(N+4)
264 LET H$="SCHMAL"
265 LET I$="TZ, "
266 LET U=9
267 LET X=11000
268 GOTO 274
269 IF U<>10 THEN 272
270 IF I=1 THEN 274
271 GOTO 275
272 IF U>12 THEN 275
273 IF FNB(D)>6 THEN 275
274 LET I=6
275 RETURN
276 IF U>=11 THEN 281
277 LET U=11
278 LET H$="A PAIR"
279 LET I$=" OF "
280 RETURN
281 IF U<>11 THEN 291
282 IF B(Z)<>B(Z-1) THEN 287
283 LET H$="THREE"
284 LET I$=" "
285 LET U=13
286 RETURN
287 LET H$="TWO P"
288 LET I$="AIR, "
289 LET U=12
290 RETURN
291 IF U<>12 THEN 296
292 LET U=16
293 LET H$="FULL H"
294 LET I$="OUSE, "
295 RETURN
296 IF B(Z)<>B(Z-1) THEN 301
297 LET U=17
298 LET H$="FOUR"
299 LET I$=" "
300 RETURN
301 LET U=16
302 LET H$="FULL H"
303 LET I$="OUSE, "
304 RETURN
305 LET G=0
306 PRINT "WHAT IS YOUR BET";
307 INPUT T
308 IF T-INT(T)=0 THEN 314
309 IF K<>0 THEN 312
310 IF G<>0 THEN 312
311 IF T=.5 THEN 341
312 PRINT "NO SMALL CHANGE, PLEASE"
313 GOTO 306
314 IF S-G-T>=0 THEN 317
315 GOSUB 383
316 GOTO 306
317 IF T<>0 THEN 320
318 LET I=3
319 GOTO 338
320 IF G+T>=K THEN 323
321 PRINT "IF YOU CAN'T SEE MY BET, THEN FOLD"
322 GOTO 306
323 LET G=G+T
324 IF G=K THEN 338
325 IF Z<>1 THEN 342
326 IF G>5 THEN 330
327 IF Z>=2 THEN 335
328 LET V=5
329 GOTO 342
330 IF Z=1 THEN 332
331 IF T<=25 THEN 335
332 LET I=4
333 PRINT "I FOLD"
334 RETURN
335 IF Z=2 THEN 343
336 PRINT "I'LL SEE YOU"
337 LET K=G
338 LET S=S-G
339 LET C=C-K
340 LET P=P+G+K
341 RETURN
342 IF G>3*Z THEN 335
343 LET V=G-K+FNA(0)
344 GOSUB 348
345 PRINT "I'LL SEE YOU, AND RAISE YOU ";V
346 LET K=G+V
347 GOTO 306
348 IF C-G-V>=0 THEN 366
349 IF G<>0 THEN 352
350 LET V=C
351 RETURN
352 IF C-G>=0 THEN 336
353 IF O/2<>INT(O/2) THEN 360
354 PRINT "WOULD YOU LIKE TO BUY BACK YOUR WATCH FOR $50";
355 INPUT J$
356 IF J$="NO" THEN 360
357 LET C=C+50
358 LET O=O/2
359 RETURN
360 IF O/3<>INT(O/3) THEN 367
361 PRINT "WOULD YOU LIKE TO BUY BACK YOUR TIE TACK FOR $50";
362 INPUT J$
363 IF J$="NO" THEN 367
364 LET C=C+50
365 LET O=O/3
366 RETURN
367 PRINT "I'M BUSTED.  CONGRATULATIONS"
368 STOP
369 PRINT H$;I$;
370 IF H$<>"A FLUS" THEN 375
371 LET K=INT(K/100)
372 GOSUB 208
373 PRINT
374 RETURN
375 LET K=FNB(K)
376 GOSUB 196
377 IF H$="SCHMAL" THEN 379
378 IF H$<>"STRAIG" THEN 381
379 PRINT " HIGH"
380 RETURN
381 PRINT "S"
382 RETURN
383 PRINT
384 PRINT "YOU CAN'T BET WHAT YOU HAVEN'T GOT"
385 IF O/2=INT(O/2) THEN 397
386 PRINT "WOULD YOU LIKE TO SELL YOUR WATCH";
387 INPUT J$
388 IF J$="NO" THEN 397
389 IF FNA(0)>=7 THEN 393
390 PRINT "I'LL GIVE YOU $75 FOR IT"
391 LET S=S+75
392 GOTO 395
393 PRINT "THAT'S A PRETTY CRUMMY WATCH - I'LL GIVE YOU $25"
394 LET S=S+25
395 LET O=O*2
396 RETURN
397 IF O/3=INT(O/3) THEN 409
398 PRINT  "WILL YOU PART WITH THAT DIAMOND TIE TACK";
399 INPUT J$
400 IF J$="NO" THEN  408
401 IF FNA(0)>=6 THEN 405
402 PRINT "YOU ARE NOW $100 RICHER"
403 LET S=S+100
404 GOTO 407
405 PRINT "IT'S PASTE.  $25"
406 LET  S=S+25
407 LET  O=O*3
408 RETURN
409 PRINT "YOUR WAD IS SHOT.  SO LONG, SUCKER"
410 END
