Files | Admin

Notes:

Release Name: ruby-poker-0.3.1

Notes:
= Poker library in Ruby

== Author

Rob Olson (rko618 [at] gmail)

== Description

Ruby-Poker handles the logic for getting the rank of a poker hand. It can also be used to compare two or more hands to determine which hand has the highest poker value.

Card representations can be passed to the PokerHand constructor as a string or an array. Face cards (cards ten, jack, queen, king, and ace) are created using their letter representation (T, J, Q, K, A).

== Install

    sudo gem install ruby-poker

== Examples

In this section some examples show what can be done with this class.

    require 'rubygems'
    require 'ruby-poker'
    
    hand1 = PokerHand.new("8H 9C TC JD QH")
    hand2 = PokerHand.new(["3D", "3C", "3S", "KD", "AH"])
    puts hand1                => 8h 9c Tc Jd Qh (Straight)
    puts hand1.just_cards     => 8h 9c Tc Jd Qh
    puts hand1.rank           => Straight
    puts hand2                => 3d 3c 3s Kd Ah (Three of a kind)
    puts hand2.rank           => Three of a kind
    puts hand1 > hand2        => true

== Duplicates

By default ruby-poker will not raise an exception if you add the same card to a hand twice. You can tell ruby-poker to not allow duplicates by doing the following

    PokerHand.allow_duplicates = false
    
Place that line near the beginning of your program. The change is program wide so once allow_duplicates is set to false, _all_ poker hands will raise an exception if a duplicate card is added to the hand.

== Compatibility

Ruby-Poker is compatible with Ruby 1.8 and Ruby 1.9.

== History

In the 0.2.0 release Patrick Hurley's Texas Holdem code from http://rubyquiz.com/quiz24.html was merged into ruby-poker.

== License

This is free software; you can redistribute it and/or modify it under the terms of the BSD license. See LICENSE for more details.


Changes: 2009-01-24 (0.3.1) * Bug [#23623] undefined method <=> for nil:NilClass 2008-12-30 (0.3.1) * Bug (#20407) Raise an exception when creating a new hand with duplicates * Added PokerHand#uniq method * Removed deprecated `Gem::manage_gems` from Rakefile 2008-05-17 (0.3.0) * Changed Card#== to compare based on card suit and face value. Before it only compared the face value of two cards. Warning: This change may potentially break your program if you were comparing Card objects directly. * Replaced `PokerHand#arranged_hand` with `PokerHand#sort_using_rank` which is more descriptive. This loosely corresponds to bug #20194. * Bug [#20196] 'rank' goes into an infinite loop. * Bug [#20195] Allows the same card to be entered into the hand. * Bug [#20344] sort_using_rank does not return expected results 2008-04-20 (0.2.4) * Modernized the Rakefile * Updated to be compatible with Ruby 1.9 2008-04-06 (0.2.2) * Fixed bug where two hands that had the same values but different suits returned not equal 2008-02-08 (0.2.1) * Cards can be added to a hand after it is created by using (<<) on a PokerHand * Cards can be deleted from a hand with PokerHand.delete() 2008-01-21 (0.2.0) * Merged Patrick Hurley's poker solver * Added support for hands with >5 cards * Straights with a low Ace count now * to_s on a PokerHand now includes the rank after the card list * Finally wrote the Unit Tests suite 2008-01-12 (0.1.2) * Fixed critical bug that was stopping the whole program to not work * Added some test cases as a result * More test cases coming soon 2008-01-12 (0.1.1) * Ranks are now a class. * Extracted card, rank, and arrays methods to individual files * Added gem packaging 2008-01-10 (0.1.0) * Initial version