Richard Lee wrote: > 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)
Bonjour Looks OKish, but 7 comes after 6 :) Here are my thoughts: 1. 'and put it into array' doesn't belong here, it's part of the implementation 2. Do you really want to allow a cut? This is a computer that just shuffled the deck! 4. I don't understand '= player_total' etc. It looks like more implementation? 5. I don't gamble. Can't the check for 21 be generalised? Or is it special if it happens straight from the deal? 6.1 Insurance? You lost me. Is this the only point in the game where this can happen? After this you need to be much more concise. Look at > 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 This is your chance to make the solution easy to read, but you've written something that I, at least, struggle to understand. Is it something like Game over and bet again if dealer's face down is 10 6.2 This is way too complex isn't it. It's about ten steps on its own. What is 'give 4 choice as below'? And - sorry this makes my head hurt :-/ 'go back to STEP_ADD' You have labels in pseudocode?! 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/