On Oct 22, 2005, at 8:14 PM, David Vincelli wrote: > I'm writing a little BlackJack program for fun and I'm at the point > where I have to decide which point value to assign to a hand. As you > know, an Ace may be worth 1 or 11 in this game - whatever is closer to > 21 without going over. > > Considering this, I know I have to come up with an algorithm that > first determines what the different point values may be (the extreme > case may be that a player got all four aces, now I'd have to determine > all combinations of the players cards). Actually, you can do it a little easier. Just count them all as 11 and if you're over 21, subtract 10 until you're out of aces, or you are under. Here's some sample code from my own version: class Card # ... def soften? if @face == "A" and @value == 11 @value = 1 true else false end end # ... end # ... class Player # ... def total count = @cards.inject(0) { |sum, card| sum + card.value } while count > 21 and @cards.any? { |card| card.soften? } count -= 10 end count end # ... end # ... __END__ Hope that helps. James Edward Gray II