Re: creating blackjack perl program (starts with pseudocode first)
[email protected] (Richard Lee)
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
Richard Lee wrote: > Rob Dixon wrote: >> >> I suggest you start by describing a very simple game that's not >> blackjack. One >> player gets dealt cards until he hits 21 or more. 21 is a win, more >> is a loss. >> >> Then add a dealer's hand. >> >> Then add face down cards >> >> Then add betting >> >> Then add, erm, insurance? >> >> Finish with the green baize ;) >> >> HTH, >> >> Rob >> > Hey, thanks for the quick feedback. I worked on from 1-6 and will work > on 7 tomorrow. See if this is any better > > > ### 52 cards in deck consist of 2-10 and J, Q, K(which all 3 of them > has value of 10) and A (which has either value of 1 or 11 ) and there > are 3 suits (diamond,clover,heart, > > requirements: 7 decks ( 52 X 7 = 364 ) # not sure 6 or 7 decks but > let's just say 7 for now > Player will have $500 and we will call that > bank. Each bet's minimum is $25 and maximum is $500 > > 1. Take 7 decks of cards one big pile and shuffle them > > 2. Have player cut the deck(must be in 2nd half of deck but cannot be > last 20% of the deck; somewhere between past 50% and before 80%) and > put a marker on it # so it knows where to stop > ### The reason, cutting > the deck after cards are shuffled is to make sure players do not know > when the deck ends > ### Meaning, if someone > was counting cards(sort of trying to memorize what cards already came > out, they can sort of guess > ### as decks are running > out. If you cut the deck, it's harder to guestimate, although counting > cards can still give player bit of advantage; it's still gambling and > probability > --- game starts--- > 3. Player places the bet which must be greater or equal to minimum > and less or equal to max and also his bank must have that amount in > order to bet > ( bank - bet ) > > 4.dealer deals a card > ### player and dealer each gets 2 cards. 2nd card that dealer gets > is face down so nobody knows the value of the card > first dealer will deal a face up card to player which we will call > player_total > > second, dealer will deal a face up card for dealer himself which we > will call dealer_total > > third, dealer will deal a face up card to player which we will call > player_next > > fourth dealer will deal a face down card for dealer himself which > we will call dealer_next > > 5.If player has blackjack( 10 + A ), add 1.5 x bet + bet to his bank > and bet again(go back to step 3) > > 6.If dealer has A in face up card, > offer insurance > if answer is yes > then player must bet additional 50% > of his current bet ( bet x .5 ) which we will call insurance_money > (bet x .5) = insurance_money > bank - insurance_money ### current > total bank after putting insurance > if answer is no > insurance_money is 0 > now check the face down card ( dealer_next ) > if dealer_next is 10 and insurance_money is 0 > player lose the bet and game over and > go back to step 3 and bet again > if dealer_next is not 10 and insurnace_money is 0 > game continues, go to step 7 > if dealer_next is 10 and insurance_money is > greater than 0 > add back player's bet and insurance > money to his bank > ( bank + bet + insurance_money) > game starts over and go back to step > 3 and bet again > if dealer_next is NOT 10 and insurance_money is > greater than 0 > player loses the insurance_money but > game continues , go to step 7 <---------------------- this was > corrected one correction above