
-----------------------------------
Mackie
Sun Apr 06, 2008 9:49 pm

A very crude Blackjack.
-----------------------------------
Here is a very crude blackjack, I'm just trying to learn ruby, so I thought it would be a fun project to try out. It's pretty crude, I'm actually making a really cool deck class for super-accurate shuffling, and probability.

I'd love feed back/things I did wrong. Trying to get out of the Turing mindset proves difficult.

# Mackie Drew
# Black Jack
# April 6th, 2008

# Set defaults
dealerCards = 

-----------------------------------
wtd
Mon Apr 07, 2008 12:42 am

RE:A very crude Blackjack.
-----------------------------------
def cls
        puts "\n" * 22
end 

def clear_screen
   22.times { puts }
end

-----------------------------------
wtd
Mon Apr 07, 2008 11:03 am

RE:A very crude Blackjack.
-----------------------------------
                if turnChoice.include?("1") :
                        playerCards += [rand(10)]
                        if total(playerCards) > 21 :
                                playAgain = "2"
                        end
                elsif turnChoice.include?("2") :
                        playAgain = "2"
                end 

Try making use of regular expressions instead of include?  :-)

-----------------------------------
Mackie
Mon Apr 07, 2008 1:16 pm

Re: RE:A very crude Blackjack.
-----------------------------------
def cls
        puts "\n" * 22
end 

def clear_screen
   22.times { puts }
end

Thanks wtd, I changed it, I just don't know if there is any advantage to the change. Is it just common practice to do it your way?

                if turnChoice.include?("1") :
                        playerCards += [rand(10)]
                        if total(playerCards) > 21 :
                                playAgain = "2"
                        end
                elsif turnChoice.include?("2") :
                        playAgain = "2"
                end 

Try making use of regular expressions instead of include?  :-)

I had a feeling someone was going to mention that. :P
I wasn't sure why regular expressions weren't working until later on, when i realized it added the eol character.

-----------------------------------
wtd
Mon Apr 07, 2008 2:09 pm

Re: RE:A very crude Blackjack.
-----------------------------------
def cls
        puts "\n" * 22
end 

def clear_screen
   22.times { puts }
end

Thanks wtd, I changed it, I just don't know if there is any advantage to the change. Is it just common practice to do it your way?

Which is more self-documenting?

-----------------------------------
ambok
Tue Nov 16, 2010 7:48 am

Re: A very crude Blackjack.
-----------------------------------
if turnChoice.include?("1") :
                        playerCards += [rand(10)]
                        if total(playerCards) > 21 :
                                playAgain = "2"
                        end
                elsif turnChoice.include?("2") :
                        playAgain = "2"
                end

-----------------------------------
Insectoid
Tue Nov 16, 2010 10:31 am

RE:A very crude Blackjack.
-----------------------------------
Check your date stamps bro.
