Some (open source) poker software I'm working on

S

Subvertir

Rising Star
Bronze Level
Joined
Sep 13, 2009
Total posts
13
Chips
0
Hey guys,

I'm currently developing a port of the PokerEval library to Objective-C as well as a set of MacRuby bindings to accompany that project. My goal is to make the easiest-to-use and fastest poker utility library available by taking advantage of MacOS-specific features like Grand Central Dispatch. I'm also focused on developing features for less popular games that I prefer playing, like no limit 2-7 single/triple draw and badugi.

Nothing is in a state where it'd be usable to non-programmers, but it's non-commercial and 100% free to play around with.

Both projects are available under the GPLv3 at:

http://github.com/erudified/RubyGrinder
http://github.com/erudified/ObjectiveEval

They're very young, under a month old, but they're rapidly becoming usable. I'm trying to create Ruby on Rails like API for dealing with poker games - check out this example to see what I mean.

Code:
#!/usr/bin/env macruby
require "../lib/rubygrinder"
# Create and enumerate ev for all hands in a 9-handed texas holdem game

# These hashes represent our players
albert = { :pstar_name => "Albert", :ftilt_name => "Albert", :stack => 1000 }
bob    = { :pstar_name => "Bob   ", :ftilt_name => "Bob   ", :stack => 1000 }
carol  = { :pstar_name => "Carol ", :ftilt_name => "Carol ", :stack => 1000 } 
dave   = { :pstar_name => "Dave  ", :ftilt_name => "Dave  ", :stack => 1000 }
edward = { :pstar_name => "Edward", :ftilt_name => "Edward", :stack => 1000 }
fred   = { :pstar_name => "Fred  ", :ftilt_name => "Fred  ", :stack => 1000 }
gerald = { :pstar_name => "Gerald", :ftilt_name => "Gerald", :stack => 1000 }
hiro   = { :pstar_name => "Hiro  ", :ftilt_name => "Hiro  ", :stack => 1000 }
iota   = { :pstar_name => "Iota  ", :ftilt_name => "Iota  ", :stack => 1000 }

full_opts = {
  # cards are dealt to players in seats
  # the players perform actions on each round of betting
  :seats => [
    { :cards => ['9d','9h'], :person => albert },
    { :cards => ['2h','7s'], :person => bob    },
    { :cards => ['Ad','7d'], :person => carol  },
    { :cards => ['2d','9c'], :person => dave   },
    { :cards => ['3d','8c'], :person => edward },
    { :cards => ['As','Ac'], :person => fred   },
    { :cards => ['8s','8h'], :person => gerald },
    { :cards => ['7h','6h'], :person => hiro   },
    { :cards => ['6d','Qc'], :person => iota   }
  ],
  :board => {
    :flop  => ['6s','8d', 'Qh'],
    :turn  => ['Kh'],
    :river => ['Qd']
  },
  # The button is on carol
  :button_position => 2
}

# create a game instance
game = RubyGrinder::Poker::Games::Holdem.new(full_opts)
puts "Instantiated Holdem..." if game
# Take a look at what we've done so far
puts "Dealt #{game.deck.dealt.num_cards} hole cards..."
(0..game.seat.length-1).each{|i| 
  puts "#{game.seat[i].pstar_name} has cards: #{game.seat[i].cm}" 
}
puts "All dealt cards : #{game.deck.dealt}"
puts "Remaining cards : #{game.deck.remaining}"

}
When ran in a terminal, this code will output (edited slightly for formatting):

Code:
amnesiac:examples alex$ ./test.rb 
Instantiated Holdem...
Dealt 18 hole cards...
Albert has cards: 9d 9h 
Bob    has cards: 7s 2h 
Carol  has cards: Ad 7d 
Dave   has cards: 2d 9c 
Edward has cards: 3d 8c 
Fred   has cards: As Ac 
Gerald has cards: 8s 8h 
Hiro   has cards: 7h 6h 
Iota   has cards: 6d Qc 
All dealt cards : As 8s 7s Ad 9d 7d 6d 3d 2d Ac Qc 9c 8c 9h 8h 7h 6h 2h 
Remaining cards : Ks Qs Js Ts 9s 6s 5s 4s 3s 2s Kd Qd Jd Td 8d 5d 4d Kc Jc Tc 7c 6c 5c 4c 3c 2c Ah Kh Qh Jh Th 5h 4h 3h
 
spiderman637

spiderman637

RIP Buck
Silver Level
Joined
Aug 5, 2009
Total posts
1,835
Chips
0
No idea what you are ding here in this strategy section. I think you should post this in some other section like technology...
Anyways good luck with whatever you are trying to archive bro...
 
Emrald Onyxx

Emrald Onyxx

Rock Star
Silver Level
Joined
Jan 23, 2009
Total posts
106
Chips
0
Just take it out into a field and...........

officespace1.jpg
 
S

Subvertir

Rising Star
Bronze Level
Joined
Sep 13, 2009
Total posts
13
Chips
0
No idea what you are ding here in this strategy section. I think you should post this in some other section like technology...
Anyways good luck with whatever you are trying to archive bro...

Sorry! Didn't realize that there was a technology section.
 
S

Subvertir

Rising Star
Bronze Level
Joined
Sep 13, 2009
Total posts
13
Chips
0
I guess this has been moved so it's cool to post an update? Hand evaluation works from Ruby now, you can add some code like this to the example:

Code:
# Okay... now let's see who has the best preflop hand.
ordered_hands = []
(0...game.seats.count).each{|x| 
  ordered_hands << [x,game.seats[x].holding.to_i(:std)] 
  ordered_hands = ordered_hands.sort_by{|a|a[1]}.reverse!
}

(0...ordered_hands.count).each{|x|
  puts game.seat[ordered_hands[x][0]].pstar_name + 
  " has cards: " + game.seat[ordered_hands[x][0]].holding.to_s + 
  "with value: " + ordered_hands[x][1].to_s
}
To get the value of each pair of hole cards represented as a 32-bit integer:

Code:
Fred   has cards: As Ac with value: 17563648
Albert has cards: 9d 9h with value: 17235968
Gerald has cards: 8s 8h with value: 17170432
Carol  has cards: Ad 7d with value: 806912
Iota   has cards: 6d Qc with value: 671744
Dave   has cards: 2d 9c with value: 458752
Edward has cards: 3d 8c with value: 397312
Hiro   has cards: 7h 6h with value: 344064
Bob    has cards: 7s 2h with value: 327680
You're probably thinking to yourself what's the point? And you'd be right if you thought that this was just for hold'em hand evaluation, but that's not the case at all. I plan to make this support every game available on Full Tilt or pokerstars, and as far as evaluating hands is concerned it's very close already.

Code:
# Get all possible values for seat 1's hole cards 

# Standard (holdem style) evaluation
game.seats[0].holding.to_i(:std)

# Low evaluation (worst hand scores highest)
game.seats[0].holding.to_i(:low)

# Low 8 evaluation (worst hand with 8 or lower qualifier)
game.seats[0].holding.to_i(:low8)

# Low 2-7 evaluation (ace always high 8 or lower qualifier)
game.seats[0].holding.to_i(:low27)

# Omaha hi/lo evaluation (8 or lower qualifier)
game.seats[0].holding.to_i(:omaha)

# Omaha hi 
game.seats[0].holding.to_i(:omaha_hi)

# Type evaluation (just the type of hand, no value)
# Returns an index into array of hand types from nothing to ace high straight flush
game.seats[0].holding.to_i(:type)

# Fast evaluator for 5-card hands (won't work with 2 cards)
game.seats[0].holding.to_i(:evx5)

# Fast evaluator for 7-card hands (won't work with 2 cards)
 game.seats[0].holding.to_i(:evx5)
So, once the enumerator is working (the enumerator is just a piece of code that enumerates all possible outcomes of a given scenario), it will just take a few minutes to put together something like PokerStove, except that it will run on MacOSX and support every game available on Full Tilt or Stars (except for badugi, which currently has no evaluator - I plan to make one).
 
ethon

ethon

Rock Star
Silver Level
Joined
Sep 2, 2009
Total posts
354
Chips
0
Hey, I'd be interested in helping with the development of this.
 
J

JEP712

Visionary
Silver Level
Joined
Nov 29, 2009
Total posts
538
Chips
0
Hey guys,

I'm currently developing a port of the PokerEval library to Objective-C as well as a set of MacRuby bindings to accompany that project. My goal is to make the easiest-to-use and fastest poker utility library available by taking advantage of MacOS-specific features like Grand Central Dispatch. I'm also focused on developing features for less popular games that I prefer playing, like no limit 2-7 single/triple draw and badugi.

Nothing is in a state where it'd be usable to non-programmers, but it's non-commercial and 100% free to play around with.

Both projects are available under the GPLv3 at:

http://github.com/erudified/RubyGrinder
http://github.com/erudified/ObjectiveEval

They're very young, under a month old, but they're rapidly becoming usable. I'm trying to create Ruby on Rails like API for dealing with poker games - check out this example to see what I mean.

Code:
#!/usr/bin/env macruby
require "../lib/rubygrinder"
# Create and enumerate ev for all hands in a 9-handed texas holdem game

# These hashes represent our players
albert = { :pstar_name => "Albert", :ftilt_name => "Albert", :stack => 1000 }
bob    = { :pstar_name => "Bob   ", :ftilt_name => "Bob   ", :stack => 1000 }
carol  = { :pstar_name => "Carol ", :ftilt_name => "Carol ", :stack => 1000 } 
dave   = { :pstar_name => "Dave  ", :ftilt_name => "Dave  ", :stack => 1000 }
edward = { :pstar_name => "Edward", :ftilt_name => "Edward", :stack => 1000 }
fred   = { :pstar_name => "Fred  ", :ftilt_name => "Fred  ", :stack => 1000 }
gerald = { :pstar_name => "Gerald", :ftilt_name => "Gerald", :stack => 1000 }
hiro   = { :pstar_name => "Hiro  ", :ftilt_name => "Hiro  ", :stack => 1000 }
iota   = { :pstar_name => "Iota  ", :ftilt_name => "Iota  ", :stack => 1000 }

full_opts = {
  # cards are dealt to players in seats
  # the players perform actions on each round of betting
  :seats => [
    { :cards => ['9d','9h'], :person => albert },
    { :cards => ['2h','7s'], :person => bob    },
    { :cards => ['Ad','7d'], :person => carol  },
    { :cards => ['2d','9c'], :person => dave   },
    { :cards => ['3d','8c'], :person => edward },
    { :cards => ['As','Ac'], :person => fred   },
    { :cards => ['8s','8h'], :person => gerald },
    { :cards => ['7h','6h'], :person => hiro   },
    { :cards => ['6d','Qc'], :person => iota   }
  ],
  :board => {
    :flop  => ['6s','8d', 'Qh'],
    :turn  => ['Kh'],
    :river => ['Qd']
  },
  # The button is on carol
  :button_position => 2
}

# create a game instance
game = RubyGrinder::Poker::Games::Holdem.new(full_opts)
puts "Instantiated Holdem..." if game
# Take a look at what we've done so far
puts "Dealt #{game.deck.dealt.num_cards} hole cards..."
(0..game.seat.length-1).each{|i| 
  puts "#{game.seat[i].pstar_name} has cards: #{game.seat[i].cm}" 
}
puts "All dealt cards : #{game.deck.dealt}"
puts "Remaining cards : #{game.deck.remaining}"

}
When ran in a terminal, this code will output (edited slightly for formatting):

Code:
amnesiac:examples alex$ ./test.rb 
Instantiated Holdem...
Dealt 18 hole cards...
Albert has cards: 9d 9h 
Bob    has cards: 7s 2h 
Carol  has cards: Ad 7d 
Dave   has cards: 2d 9c 
Edward has cards: 3d 8c 
Fred   has cards: As Ac 
Gerald has cards: 8s 8h 
Hiro   has cards: 7h 6h 
Iota   has cards: 6d Qc 
All dealt cards : As 8s 7s Ad 9d 7d 6d 3d 2d Ac Qc 9c 8c 9h 8h 7h 6h 2h 
Remaining cards : Ks Qs Js Ts 9s 6s 5s 4s 3s 2s Kd Qd Jd Td 8d 5d 4d Kc Jc Tc 7c 6c 5c 4c 3c 2c Ah Kh Qh Jh Th 5h 4h 3h

:eek: :confused: :stupid: :stupido2: :albertein
 
Top