I wrote this program because I was bored.  I do really dumb things when I'm
bored.  This particular diversion took about a month to write and debug.  As
the name implies, this program plays poker.  The dealer (calculator) plays
five card draw with whoever is on the other end of the keyboard.  You start
out with $200 and bet your way from there in $5 increments.  You can keep
playing until you are broke, the calculator is extraordinarily rich and can
never go broke (my solution to a bug I couldn't fix).  The computer will occ-
asionally call your bluff, so you can't pull TOO many over it.  For those of
you who like to tinker, the algorithm that the calculator uses to bet is the
file is the program CBID.  You can increase or decrease the difficulty by
modifying this program.  I quit fiddling with it after it got to a certain
level of difficulty.  I apologize for the lack of checksums, but I've had this
and a few other programs in text files on my computer for several months now
and just don't have time to type it back into my HP just to find the sums. If
anyone does type it in (and it works properly!) would they please send me the
checksums for archival purposes?  I can be found on the net at DESTILL@MTUS5.
CTS.MTU.EDU.  Thanks.
 
This file may be distributed freely as long as it is distributed in its
entirety.  If you wish to publish or modify parts of the file, just e-mail
your request and it will probably be granted.  Written by David Still.
 
==============================================================================
 
  POKER
<< { { } { } } DUP 'ch' STO
'ph' STO 0 'POT' STO CLLCD 200
'PLAYER' STO
1 CF SHUFFLE
WHILE PLAYER 0 > 1 FC? AND
REPEAT 2 CF 3 CF { { } { } }
DUP 'ch' STO 'ph' STO 'PLAYER'
5 STO- 10 'POT' STO 0 'f1' STO
  WHILE f1 2 <
  REPEAT 'f1' 1 STO+ 2 'bid'
  STO 0 'f2' STO MKHAND
    WHILE f2 3 <
    REPEAT 'f2' 1 STO+ 134 CHR
    "   " + 36 CHR + PLAYER
    ->STR + "  POT ="
+ 36 CHR + POT ->STR + 3 DISP
3 LINV "Bid/Call/Drop" 2 DISP
DO
  DO
  UNTIL KEY
  END 'k' STO
UNTIL k "B" == PLAYER BID bid
GET > AND k "C" >= k "D" <=
AND OR IF DUP NOT
  THEN ERRBELL
  END
END
IF k "B" ==
THEN 'PLAYER' BID bid GET STO-
'POT' BID bid GET STO+ PBID
  IF BID bid GET PLAYER >=
  THEN BID PLAYER POS 'bid' STO
  END 'POT' BID bid GET STO+
  'PLAYER' BID bid GET STO- BID
  bid GET CBID
  IF BID bid GET PLAYER >
  THEN BID PLAYER POS 'bid' STO
  END
    IF bid 1 ==
  THEN DROP 2 'f1' STO 3 'f2'
  STO "I fold." 2 DISP 1 400
    START
    NEXT 2 SF 'PLAYER' POT STO+
  ELSE 'POT' STO+
  IF bid 2 ==
  THEN "I call." 2 DISP 3 'f2'
  STO 1 400
    START
    NEXT
ELSE "I'll raise you " BID bid
GET ->STR + 2 DISP 'POT' BID
bid GET STO+ 1 400 START
      NEXT
    END
  END
ELSE 3 'f2' STO
  IF k "C" ==
  THEN 'POT' BID bid GET STO+
  'PLAYER' BID bid GET STO-
  ELSE 2 SF 2 'f1' STO
  END
END
  END
IF 1 f1 == 1 FC? AND
  THEN 134 CHR "   " + 36 CHR
  + PLAYER ->STR + "  POT=" +
  36 CHR +
POT ->STR + 3 DISP 3 LINV PDISC
CDISC "I discarded " d ->STR +
2 DISP 1 100
START
NEXT
  END
  END ""
  IF 2 FC?
  THEN "Me= " cht + 2 DISP
    IF ch HNVAL ph HNVAL <
    THEN 'PLAYER' POT STO+
    "You win." +
    ELSE "I win." +
    END
  END " Continue?(Y/N)" + DUP
  2 DISP 134 CHR "   " + 36
  CHR + PLAYER
->STR + 3 DISP 3 LINV
  DO
    DO
    UNTIL KEY
    END 'k' STO
  UNTIL k "Y" == k "N" == OR
  IF DUP NOT
  THEN ERRBELL
  END
END " " + k + 2 DISP
IF k "N" ==
THEN 1 SF
END
  END
  IF PLAYER 0 ==
  THEN CLLCD " You're out of
  money" 1 DISP 1 LINV
  END { bid suit ch ph cht pht
  k DECK PLAYER POT f1 f2 d }
  PURGE
  >>
 
  LINV
<< LCD-> -> a lcd
  << lcd 1 a 1 - 137 * SUB lcd
  a 1 - 137 * 1 + a 137 * SUB
  NOT + lcd a
137 * 1 + 548 SUB + ->LCD
  >>
>>
 
  CBID
<< ch HNVAL .25 * 3 + bid 2 -
.65 * - 1 f1 == + RAND 2 * + IP
IF DUP 7 >
THEN DROP 7
END
IF DUP 1 <
THEN DROP 1
END bid 7 == + 'bid' STO
>>
 
  CDISC
<< ch 1 GET -> card
  << { } 1 13
  FOR j 0 1 card SIZE
    FOR k card k GET j == +
    NEXT +
  NEXT { } -> hand disc
    <<
    WHILE disc SIZE 3 < hand 1
    POS AND
    REPEAT disc card hand 1
    POS POS + 'disc' STO hand
    DUP 1 POS 0 PUT
'hand' STO
    END
    IF disc SIZE ch HNVAL 6 <
    AND THEN ch disc DISCRD
    'ch' STO END disc SIZE 'd'
    STO >>
  >>
>>
 
  PBID
<< 2 CF 3 'bid' STO
WHILE 2 FC?
REPEAT "Enter bid (+/-) " BID
bid GET ->STR + 2 DISP
  DO
    DO
    UNTIL KEY
    END 'k' STO
  UNTIL k "+" == k "-" == OR k
  "ENTER" == OR
  END {
  << bid 1 - DUP 3 < 5 * +
  'bid' STO >>
  << bid 1 + DUP 7 > 5 * -
  'bid' STO >>
  << 2 SF
  >> } { "-" "+" "ENTER" } k
  POS GET EVAL
END >>
 
  PDISC
<< "How many cards (0-3)?" 2
DISP DO
  DO
  UNTIL KEY
  END 'k' STO
UNTIL k "0" >= k "3" <= AND
  IF DUP NOT
  THEN ERRBELL
  END
END "Discard " k + " cards." +
DUP 2 DISP { 0 } -> discard
<< IF k "0" <>
   THEN 1 k STR->
     FOR j
DO
  DO
  UNTIL KEY
  END 'k' STO
UNTIL k "1" >= k "5" <= AND 1
discard SIZE
  FOR m discard m GET ->STR k
  <> AND NEXT DUP
  IF NOT
  THEN ERRBELL
  END
END k + DUP 2 DISP discard k
STR-> + 'discard' STO
NEXT DROP discard 2 4 SUB ph
SWAP DISCRD 'ph' STO
ELSE 2 DISP
  END >>
>>
 
  BID { -5 0 5 10 15 20 25 }
 
  DISCR
<< SWAP LIST-> DROP -> discard
card suit
  << 1 discard SIZE
  FOR j card discard j GET 0
  PUT suit discard j GET 0 PUT
  'suit' STO 'card' STO
  NEXT 1 discard SIZE
  FOR j card 1 card 0 POS 1 -
  SUB card card 0 POS 1 + card
  SIZE SUB +
'card' STO suit 1 suit 0 POS 1
- SUB suit suit 0 POS 1 + suit
SIZE SUB + 'suit'
STO
  NEXT card suit 2 ->LIST
  >>
>>
 
   HNVAL
<< 0 'hi' STO 0 's' STO LIST->
DROP -> card suit
  << 1 CF 2 CF 1 13
  FOR j 0 1 5
    FOR k j card k GET == +
    NEXT -> a
    <<
IF a 2 == s 2 == AND
THEN 5 's' STO j 'hi' STO
END
IF a 3 == s 2 == AND a 2 == s
3 == AND OR
THEN 1 SF
END
IF a s >=
THEN a 's' STO j 'hi' STO
END
    >>
  NEXT
  IF 1 FS?
  THEN 6 's' STO
  END 1 2 5
  FOR j suit j GET suit j 1 -
  GET == *
  NEXT
  IF 1 ==
  THEN 8 's' 2 SF STO
  END 1 2 5
  FOR j card j GET card j 1 -
  GET - *
  NEXT
  IF 1 ==
  THEN 7
  IF 2 FS?
  THEN 2 +
  END 's' STO
END { 0 1 3 4 2 5 6 7 8 } s
GET hi 14 / +
  >> { s hi } PURGE
>>
 
  MKHAND
<< IF ph 1 GET SIZE 5 <
   THEN 1 5 ph 1 GET SIZE -
FOR j ph LIST-> DROP DEAL ROT
SWAP + ROT ROT + SWAP 2 ->LIST
'ph' STO NEXT
    END
  IF ch 1 GET SIZE 5 <
  THEN 1 5 ch 1 GET SIZE -
    FOR j ch LIST-> DROP DEAL
    ROT SWAP + ROT ROT + SWAP
    2 ->LIST 'ch' STO NEXT
  END 1 4
  FOR j j 1 + 5
    FOR k ph 1 GET j GET ph 2
    GET j GET ph 1 GET k GET
    ph 2 GET k GET ch
1 GET j GET ch 2 GET j GET ch
1 GET k GET ch 2 GET k GET ->
pca psa pcb psb cca
csa ccb csb
<< IF pca pcb >
THEN ph LIST-> DROP k psa PUT
j psb PUT SWAP k pca PUT j pcb
PUT SWAP 2 ->LIST
'ph' STO
END
IF cca ccb >
THEN ch LIST-> DROP k csa PUT
j csb PUT SWAP k cca PUT j ccb
PUT SWAP 2 ->LIST
'ch' STO
END >>
  NEXT
NEXT "" "" 'pht' STO 'cht' STO
1 5
FOR j 1 2
  FOR k pht CARDS k GET ph k
  GET j GET GET + 'pht' STO
  cht CARDS k GET
ch k GET j GET GET + 'cht' STO
  NEXT
NEXT "You= " pht + 4 DISP
>>
 
  DEAL
<< WHILE 1 4
FOR j DECK j GET SIZE
NEXT + + + NOT
   REPEAT SHUFFLE
   END RAND 4 * 1 + IP 'suit'
   STO
WHILE DECK suit GET SIZE 0 ==
REPEAT RAND 4 * IP 1 + 'suit'
STO END RAND DECK suit GET
SIZE * 1 + IP -> card
<< DECK suit GET card GET suit
DECK DUP suit GET DUP 1 card 1
- SUB SWAP card 1 + OVER SIZE
SUB + suit SWAP PUT 'DECK' STO
  >>
>>
 
  SHUFFLE
<< "Shuffling..." 1 DISP 1 4
FOR j { } 1 13
  FOR k k +
  NEXT
NEXT 4 ->LIST 'DECK' STO
IF ph 1 GET SIZE 0 >
THEN 1 ph 1 GET SIZE
  FOR j ph 2 GET j GET DUP
  DECK SWAP GET ph 1 GET j GET
  POS -> k l
  << DECK DUP k GET DUP 1 l 1
  - SUB SWAP l 1 + 13 SUB + k
  SWAP PUT 'DECK' STO >>
  NEXT
END
IF ch 1 GET SIZE 0 >
THEN 1 ch 1 GET SIZE
  FOR j ch 2 GET j GET DUP
  DECK SWAP GET ch 1 GET j GET
  POS -> k l << DECK DUP k GET
  DUP 1 l 1 - SUB SWAP l 1 +
  13 SUB + k SWAP PUT
'DECK' STO >>
NEXT
END "Poker by D. Still" 1 DISP
>>
 
CARDS { { "2" "3" "4" "5" "6"
"7" "8" "9" "10" "J" "Q" "K"
"A" } { "d " "c " "h " "s " } }                                                                                                  
/---------------------------------------------------------------------\
|             >>>>> BIG DEAL! <<<<<            | Why ask why?         |
| Now I have a signature file, too!            | Get smashed out of   |
| **** Dave Still ******* DESTILL@MTUS5 ****   | your mind instead.   |
| Life is like a dill pickle                   | Because some things  |
| ...........I hate dill pickles...            | never change.        |
\---------------------------------------------------------------------/
