Jun 98 Prog Challenge
Volume Number: 14
Issue Number: 6
Column Tag: Programmer's Challenge
June 1998 Programmers Challenge
by Bob Boonstra, Westford, MA
Blackjack
This month we welcome you to the Programmer's Challenge Casino, grease your palm
with 1000 Programmer's Challenge Credits (not to be confused with Challenge points)
furnished by the house, and invite you to spend a few milliseconds at our Challenge
Blackjack table.
The prototype for the code you should write is:
#if defined (__cplusplus)
#pragma enumsalwaysint on
typedef enum {kHiddenSuit=0,kClub,kDiamond,kHeart,kSpade} Suit;
typedef enum { kHiddenSpot=0,
kAce,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,kJack,kQueen,kKing
typedef struct Card { /* suit and spots for a card */
Suit suit;
Spot spot;
} Card;
kStandPat=0, /* no more cards for this hand */
kClaimBlackjack, /* if your initial cards are Ace and a face
card */
/* the following values request another card */
kSplitAndHitMe, /* only valid with initial pair showing */
kHitMe, /* request another card for this hand */
/* the following values request one more card */
kDoubleDownAndHitMe /* only valid with initial two cards */
typedef enum { /* results of your request for a card */
/* this result is possible anytime after a rule violation */
kIllegalPlay=-1, /* illegal play causes loss of your bet */
/* these results are possible after you request another card */
kNoResult=0, /* play again if you like */
kYouWin5CardCharlie, /* you have five cards and do not bust, you win
*/
kYouBust, /* your card puts you over 21, you lose */
/* this result is only possible after you kClaimBlackjack in the