Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,523 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,055 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



blackjack

 
Reply to this topicStart new topic

blackjack

3e33
post 16 May, 2007 - 12:54 PM
Post #1


New D.I.C Head

*
Joined: 16 May, 2007
Posts: 5


My Contributions


def shuffle
return deck.sort_by {rand}
end

def print_DECK(dk)
print "\n[ "
dk.each do |value|
print value," "
end
print "]\n\n"
end
def decode_suit_name(a_num)
which_suit = (a_num - 1) / 13
suit_name = SUITS[which_suit]
return suit_name
end

def decode_value_name(a_num)
which_value = (a_num - 1) % 13
value_name = VALUE_NAMES[which_value]
return value_name
end
my_deck = shuffle
print_DECK(my_deck)

DECK = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,3
0,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]
my_deck = shuffle
print_deck(my_deck)
SUITS = ["Spades", "Hearts", "Clubs", "Diamonds"]
VALUE_NAMES = ["Ace","2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]

card1 = CARD_VALUES(my_deck[0] - 1) % 13
suit1 = SUITS(my_deck[0] - 1) % 13

card2 = CARD_VALUES(my_deck[1] - 1) % 13
suit2 = SUITS(my_deck[1] - 1) % 13

card_dealt1 = "#{card1}, of #{suit1}"
card_dealt2 = "#{card2}, of #{suit2}"


x1 = my_deck[0]
x2 = my_deck[1]
total = x1 + x2

print "Dealt : #{x1} and : #{x2}\n\n Total = #{total}"
print "Do You Want A Hit? : "

hit = gets.to_i


i need some madd help!!!
User is offlineProfile CardPM

Go to the top of the page


Amadeus
post 16 May, 2007 - 03:58 PM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 11,894



Thanked 24 times

Dream Kudos: 25
My Contributions


Well, I'm not sure what 'madd' help may be, but can you elaborate as to the actual problem? All you've posted is code. Can you include any error messages you are receiving, or describe any undesired behaviour?
User is offlineProfile CardPM

Go to the top of the page

rahulbatra
post 17 May, 2007 - 04:28 AM
Post #3


D.I.C Head

Group Icon
Joined: 28 Dec, 2005
Posts: 156



Dream Kudos: 275
My Contributions


Well, the Ruby interpreter won't go any further after the second line since it doesn't know what is the 'deck' object. It would simply throw a 'undefined local variable or method' error. Could you make the code a little clearer with some explaination of what is your basic design and/or goals (besides the fact that its a blackjack simulation)? I admit I can't really figure out what you are trying to do here.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 03:19PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month