The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Poker::TexasHold'em - Abstract state in a Hold'em game

SYNOPSIS

  use Games::Poker::TexasHold'em;
  my $game = Games::Poker::TexasHold'em->new(
        players => [
            { name => "lathos", bankroll => 500 },
            { name => "MarcBeth", bankroll => 500 },
            { name => "Hectate", bankroll => 500 },
            { name => "RichardIII", bankroll => 500 },
        ],
        button => "Hectate",
        bet => 10,
        limit => 50
  );
  $game->blinds; # Puts in both small and large blinds
  print $game->pot; # 15

  $game->call; # Hecate puts in 10
  $game->bet_raise(15) # RichardIII sees the 10, raises another 5
  ...

DESCRIPTION

This represents a game of Texas Hold'em poker. It maintains the state of the pot, who's in to what amount, who's folded, what the bankrolls look like, and so on. It's meant to be used in conjunction with Games::Poker::OPP, but can be used stand-alone as well for analysis.

METHODS

new

Starts a new game.

General information about the game

seat2name

Returns the name of the player at the specified seat. Seats are numbered from zero.

players

Returns the names of all players in the game.

bet

Returns the initial bet.

limit

Returns the raise limit or 0 for unlimited.

Information about the current state of play

next_to_play

Returns the name of the player who's next to act in the game.

stage

Returns the stage of play. (preflop, flop, turn, river, showdown)

bankroll

Returns the bankroll of a given player.

in

Returns the investment in the pot of a given player.

folded

Returns whether or not the given player has folded. Players may be specified by name or seat number.

pot

Returns the current amount of cash in the pot

pot_square

Returns whether or not the pot is square and the current stage should be ended.

board

Returns the current board, if you're using one; this is the set of things which have been passed in to "next_stage".

hole

Similar to board, this is an opaque area where you can store your hole cards in whatever format you want to, if you want to.

status

Returns a nice table summarizing what's going on in the game.

Actions

These actions all apply to he current person who is next to act. No playing out of turn! After an action, play is advanced to the next player except in the case of blinds.

blinds

Puts in both small and large blinds. Play is not advanced, because blinds are taken from the left of the button. It's all so confusing.

fold

Folds, taking the player out of the game.

check_call

Either checks, putting nothing in the pot, or calls, putting in however much the current player is short. Returns the amount put into the pot.

You can call the check or call methods if you feel happier with that, but they're identical.

bet_raise ($amount)

Bets, if there's currently no bet, or raises an amount up, up to the limit if there is one. The amount must include the call; that is, if you're short 10, you call

    $self->bet_raise(20);

to see the 10 and raise another 10. (You'll get an error if it's less than you're short.) If you don't say how much to raise, it'll be raised by the intial bet.

As with check and call, you can call this either as bet or raise if you prefer.

"Control" actions

These are actions taken by the server or "dealer" rather than an individidual player.

next_stage (@cards)

Checks that the pot is square, and if so, advances to the next stage. Returns 1 if an advance was made, otherwise 0. The optional "cards" argument is treated as an opaque array which is added to the current board.

AUTHOR

Simon Cozens, <simon@kasei.com>

COPYRIGHT AND LICENSE

Copyright 2003 by Simon Cozens

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.