Not being a poker aficionado, my question concerns Hand#accept, which says to accept either a single Card or an Array of Card into the hand. Would the Array of Card always be length 5, or could it be of length 2 or 3 or some other number? Could the size even be greater than 5?
In other words, Hand is highly generic in terms of the number of cards it will accept. With regard to accepting cards, it would work with a card game such as the Irish “Twenty Five,” where the rules say: “The dealer then deals five cards to each person, two at a time followed by three at a time or three at a time followed by two at a time” (http://www.pagat.com/spoil5/25.html).
As it happens, the tests do not actually check that there are five cards in the hand! It silently assumes that there are 5 cards.
The upshot of this is that a fancier dealer would probably regulate that everyone has the right number of cards. And if we had had time, the evaluation of cards for a particular game would have been a mix-in. OOPS!! Getting ahead of myself! Maybe I deliberately designed the class so as to help us understand mix-ins later.
test_310_hand_strength_120 is defined twice with the second version overwriting the first version
The second version of test_310_hand_strength_120 actually contains a straight if ace_low is allowed. So if my code has can_handle_ace_low=true, then it fails this test, because I think its a Straight and the tests expects a High Card result
Is test_320_hand_human_readable_010 missing an assert statement? - it doesn’t appear to do anything at the moment
In Card, we supposed to create a def for that satisfies “The passed-in object is assumed to expose a card_number method duck-style.”
Does this means “card_number” is expected to belong to the passed-in object? Or, via duck-style, check if “card_number” method is there? If the latter, then if the “card_number” is not present, then what do we supposed to return (since spaceship’s only valid return values are -1, 0, and 1)?
I hope to catch up on a number of little issues with Assignment #3, include the tests that exercise < =>. There is a 90% probability that the test on < => will go away . . .
October 9th, 2007 at 10:13 am
Not being a poker aficionado, my question concerns Hand#accept, which says to accept either a single Card or an Array of Card into the hand. Would the Array of Card always be length 5, or could it be of length 2 or 3 or some other number? Could the size even be greater than 5?
October 9th, 2007 at 2:09 pm
Great question.
The idea is that you would be able to accept any number of cards: 1 (as just a reference to a Card):
hand.accept( Card.new(0) )
or 1 inside of an Array — e.g.,
hand.accept( [ Card.new(0) ] )
Or multiple cards: 2, 3, 10, whatever:
hand.accept( [ Card.new(0), Card.new(1), Card.new(20) ] )
In other words, Hand is highly generic in terms of the number of cards it will accept. With regard to accepting cards, it would work with a card game such as the Irish “Twenty Five,” where the rules say: “The dealer then deals five cards to each person, two at a time followed by three at a time or three at a time followed by two at a time” (http://www.pagat.com/spoil5/25.html).
As it happens, the tests do not actually check that there are five cards in the hand! It silently assumes that there are 5 cards.
The upshot of this is that a fancier dealer would probably regulate that everyone has the right number of cards. And if we had had time, the evaluation of cards for a particular game would have been a mix-in. OOPS!! Getting ahead of myself! Maybe I deliberately designed the class so as to help us understand mix-ins later.
October 10th, 2007 at 12:19 pm
Any and all help with exception handling would be most appreciated! :} thanks
October 10th, 2007 at 2:40 pm
I’ll be talking about exceptions this evening . . .
October 12th, 2007 at 4:47 pm
Couple of possible issues with the tc_spot.rb:
test_310_hand_strength_120 is defined twice with the second version overwriting the first version
The second version of test_310_hand_strength_120 actually contains a straight if ace_low is allowed. So if my code has can_handle_ace_low=true, then it fails this test, because I think its a Straight and the tests expects a High Card result
Is test_320_hand_human_readable_010 missing an assert statement? - it doesn’t appear to do anything at the moment
October 12th, 2007 at 5:02 pm
…and in tc_hand.rb, def test_0195_hand_strength_025 generates a low ace straight flush, which the test expects to just be a flush.
October 12th, 2007 at 5:16 pm
Darryl: That sounds like a bug. I will look at it.
October 13th, 2007 at 10:43 pm
In Card, we supposed to create a def for that satisfies “The passed-in object is assumed to expose a card_number method duck-style.”
Does this means “card_number” is expected to belong to the passed-in object? Or, via duck-style, check if “card_number” method is there? If the latter, then if the “card_number” is not present, then what do we supposed to return (since spaceship’s only valid return values are -1, 0, and 1)?
October 13th, 2007 at 10:44 pm
The above comment is for the spaceship method in card.
October 14th, 2007 at 6:13 pm
I hope to catch up on a number of little issues with Assignment #3, include the tests that exercise < =>. There is a 90% probability that the test on < => will go away . . .
October 16th, 2007 at 9:39 am
Regarding the latest revision of assignment 3:
there’s a missing declaration in tc_hand.rb :
CARD = Card
October 16th, 2007 at 7:20 pm
Sagi: You are right, but if you use “rake test” it doesn’t cause an error, because the constants are defined in one of the other tests.
But I will fix it nonetheless.