creating blackjack perl program (starts with pseudocode first)

[email protected] (Richard Lee)
Newsgroups perl.beginners
Message-ID <[email protected]>
hi guys,

Just for learning purpose and also for my enjoyment, I wanted to combine 
my fav game(blackjack) and my love for perl.
I wanted to re-invent the wheel to help me and train myself to think 
like programmar........

First I wanted to create a pseudocode code since I wanted to use it 
later to also try to write in c and ruby if I can.

Here is what I have so far.
I will come back with more complete pseudocode before trying this out in 
perl..
Any feedback is welcome.!

ps: I am sure it's a big mess as this is my first attempt to do 
Pseudo.......

--------------- create blackjack ------------------------

requirements: 7 decks ( 52 X 7 = 364 )   # not sure 6 or 7 decks but 
let's just say 7 for now

1. Take 7 decks of cards and shuffle them and put it into array
2. Have player cut the deck(must be in 2nd half of array but cannot be 
last 20%) and put a marker on it  # so it knows where to stop
--- game starts---
3. place a bet  ( bank - bet )
4.deal a card
   -deal a face up card to player       = player_total
   -deal a face up card to dealer       = dealer_total
   -deal a face up card to player       = player_next
   -deal a face down card to dealer  = dealer_next

5.If player has blackjack( 10 + A ), pay 1.5 of bets and end of this 
game and go back to step 3.

6.If dealer has A in face up card, offer insurance

   Check to see if face down card(dealer_next) of dealer is 10, if it is 
game over (minus the money from player unless insurance was taken) and 
go back to step 3
                         if face down card is not 10(dealer_next) , 
continue game. (if insurance was offered,  minus the money from player )

6.If player does not have blackjack and if it's first time, give 4 
choice as below. If 2nd time or more, give only a) or b) choices
   a)Hit
   b)Stand
   c)double
   d)split
 
   if a)
                      if total is more than 21,
                            if you are from c)
                                 subtract his bet(x2) from his total money
                            else
                                 subtract his bet from his total money
                            game over and go back to step 3
                      if total is less than 21, go back to 6 unless you 
are from c)
          
   if b)
                    open the other dealer's face down card
                    STEP_ADD: add dealer_next to dealer_total
                    if value is over 17 and less than 22
                               Compare dealer's total to player's total
                               if player has larger value
                                       add his bet to his total money
                               if player has less value
                                      subtract his bet to his total money
                    if value is less than 17,
                               go back to STEP_ADD

  if c)          
                   go to a), indicate that you are from c)

  if d)
                   send each card to a)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.