C# Class PsHandler.PokerMath.Evaluator.Hand

Represents a Texas Holdem Hand
Inheritance: IComparable
Afficher le fichier Open project: kampiuceris/PsHandler

Méthodes publiques

Свойство Type Description
CLUB_OFFSET int
CardJoker int
CardMasksTable ulong[]
CardTable string[]
Clubs int
DIAMOND_OFFSET int
Diamonds int
HEART_OFFSET int
Hearts int
NCardsWJoker int
NumberOfCards int
Rank2 int
Rank3 int
Rank4 int
Rank5 int
Rank6 int
Rank7 int
Rank8 int
Rank9 int
RankAce int
RankJack int
RankKing int
RankQueen int
RankTen int
SPADE_OFFSET int
Spades int

Méthodes publiques

Méthode Description
BitCount ( ulong bitField ) : int

Fast Bitcounting method (adapted from snippets.org)

CardRank ( int card ) : int

Given a card value, returns it's rank

CardSuit ( int card ) : int

Given a card value, returns it's suit

CompareTo ( object obj ) : int

Used to compare one hand to another. This method allows normal compare functions to work as expected with a hand.

DescriptionFromHand ( string hand ) : string

Takes an string describing a hand and returns the description.

DescriptionFromHandValueInternal ( uint handValue ) : string
DescriptionFromMask ( ulong cards ) : string

Equals ( object obj ) : bool

Test for equality

Eval ( string hand ) : uint

Evaluates a hand (passed as a string) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.

Eval ( ulong cards ) : uint

Evaluates a hand (passed as a hand mask) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.

Eval ( ulong cards, int numberOfCards ) : uint

Evaluates a hand (passed as a hand mask) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.

Evaluate ( string pocketCardsStr, string boardStr, string deadStr ) : EvaluationPocket
EvaluateType ( ulong mask ) : HandTypes

Evaluates the card mask and returns the type of hand it is. This function is faster (but provides less information) than Evaluate or Evaluate.

EvaluateType ( ulong mask, int cards ) : HandTypes

This function is faster (but provides less information) than Evaluate or Evaluate.

GapCount ( ulong mask ) : int

Counts the number of empty space between adjacent cards. 0 means connected, 1 means a gap of one, 2 means a gap of two and 3 means a gap of three.

GetHashCode ( ) : int

Returns hash code

Hand ( ) : System

Default constructor

Hand ( string pocket, string board ) : System

Constructor

HandOdds ( string pockets, string board, string dead, long wins, long ties, long losses, long &totalHands ) : void

Used to calculate the wining information about each players hand. This function enumerates all possible remaining hands and tallies win, tie and losses for each player. This function typically takes well less than a second regardless of the number of players.

HandPlayerOpponentOdds ( string pocketcards, string boardcards, double &player, double &opponent ) : void

Given a set of pocket cards and a set of board cards this function returns the odds of winning or tying for a player and a random opponent.

HandPlayerOpponentOdds ( ulong ourcards, ulong board, double &player, double &opponent ) : void

Given a set of pocket cards and a set of board cards this function returns the odds of winning or tying for a player and a random opponent.

HandPotential ( ulong pocket, ulong board, double &ppot, double &npot ) : void

Returns the positive and negative potential of the current hand. This funciton is described in Aaron Davidson's masters thesis (davidson.msc.pdf).

HandType ( uint handValue ) : uint
Hands ( int numberOfCards ) : IEnumerable

Enables a foreach command to enumerate all possible ncard hands.

Hands ( ulong shared, ulong dead, int numberOfCards ) : IEnumerable

Enables a foreach command to enumerate all possible ncard hands.

IsConnected ( ulong mask ) : bool

Returns true if the cards in the two card hand are connected.

IsSuited ( ulong mask ) : bool

This function returns true if the cards in the hand are all one suit

Mask ( int index ) : ulong

This is a fast way to look up the index mask.

MaskToString ( ulong mask ) : string

Turns a card mask into the equivalent human readable string.

NextCard ( string cards, int &index ) : int

Parses Card strings (internal)

Outs ( ulong player, ulong board ) : int

Returns the number of outs possible with the next card.

OutsMask ( ulong player, ulong board ) : ulong

Creates a Hand mask with the cards that will improve the specified players hand against a list of opponents or if no opponents are list just the cards that improve the players current had. Please note that this only looks at single cards that improve the hand and will not specifically look at runner-runner possiblities.

ParseCard ( string card ) : int

Reads an string definition of a card and returns the Card value.

ParseHand ( string hand ) : ulong

Parses an string description of a hand and returns a hand mask.

ParseHand ( string hand, int &cards ) : ulong

ParseHand ( string pocket, string board, int &cards ) : ulong

This static method parses the passed pocket cards and board and produces a card mask.

PocketHand169Type ( ulong mask ) : PocketHand169Enum

Given a pocket pair mask, the PocketPairType cooresponding to this mask will be returned.

RandomHands ( int ncards, double duration ) : IEnumerable

Iterates through random hands that meets the specified requirements until the specified time duration has elapse. Please note that this iterator requires interop. If you need and interop free hand evaluator you should remove this function along with the other interop functions in this file.

RandomHands ( int ncards, int trials ) : IEnumerable

Iterates through random hands with ncards number of cards. This iterator will return the number of masks specifed in trials. Masks can be repeated.

RandomHands ( ulong shared, ulong dead, int ncards, double duration ) : IEnumerable

Iterates through random hands that meets the specified requirements until the specified time duration has elapse. Please note that this iterator requires interop. If you need and interop free hand evaluator you should remove this function along with the other interop functions in this file.

RandomHands ( ulong shared, ulong dead, int ncards, int trials ) : IEnumerable

This function iterates through random hands returning the number of random hands specified in trials. Please note that a mask can be repeated.

ToString ( ) : string

Returns the string representing the hand.

TopCard ( System hv ) : uint
ValidateHand ( string hand ) : bool

This function takes a string representing a full or partial holdem hand and validates that the text represents valid cards and that no card is duplicated.

ValidateHand ( string pocket, string board ) : bool

This function takes a string representing pocket cards and a board and then validates that the text represents a valid hand.

operator ( ) : bool

Test for inequality.

Private Methods

Méthode Description
CardMask ( ulong cards, int suit ) : uint
DescriptionFromHandValue ( uint handValue ) : string
Eval ( string pocketCardsStr, IEnumerable boardStr, IEnumerable deadStr ) : int
FIFTH_CARD ( System hv ) : uint
FOURTH_CARD ( System hv ) : uint
GetRandomHand ( ulong dead, int ncards, Random rand ) : ulong

Returns a rand hand with the specified number of cards and constrained to not contain any of the passed dead cards.

HANDTYPE_VALUE ( HandTypes ht ) : uint
HandPotentialOpp ( ulong ourcards, ulong board, ulong oppcards, int index, int &HP ) : void

Internal function used by HandPotential.

MaskToDescription ( ulong mask ) : string
QueryPerformanceCounter ( long &lpPerformanceCount ) : bool
QueryPerformanceFrequency ( long &lpFrequency ) : bool
SECOND_CARD ( System hv ) : uint
SECOND_CARD_VALUE ( System c ) : uint
THIRD_CARD ( System hv ) : uint
THIRD_CARD_VALUE ( System c ) : uint
TOP_CARD_VALUE ( System c ) : uint
UpdateHandMask ( ) : void

Updates handmask and handval, called when card strings change

Method Details

BitCount() public static méthode

Fast Bitcounting method (adapted from snippets.org)
public static BitCount ( ulong bitField ) : int
bitField ulong ulong to count
Résultat int

CardRank() public static méthode

Given a card value, returns it's rank
public static CardRank ( int card ) : int
card int card value
Résultat int

CardSuit() public static méthode

Given a card value, returns it's suit
public static CardSuit ( int card ) : int
card int Card value
Résultat int

CompareTo() public méthode

Used to compare one hand to another. This method allows normal compare functions to work as expected with a hand.
public CompareTo ( object obj ) : int
obj object object to compare against
Résultat int

DescriptionFromHand() public static méthode

Takes an string describing a hand and returns the description.
public static DescriptionFromHand ( string hand ) : string
hand string the string describing the hand
Résultat string

DescriptionFromHandValueInternal() public static méthode

public static DescriptionFromHandValueInternal ( uint handValue ) : string
handValue uint
Résultat string

DescriptionFromMask() public static méthode

public static DescriptionFromMask ( ulong cards ) : string
cards ulong
Résultat string

Equals() public méthode

Test for equality
public Equals ( object obj ) : bool
obj object
Résultat bool

Eval() public static méthode

Evaluates a hand (passed as a string) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.
public static Eval ( string hand ) : uint
hand string hand string
Résultat uint

Eval() public static méthode

Evaluates a hand (passed as a hand mask) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.
public static Eval ( ulong cards ) : uint
cards ulong hand mask
Résultat uint

Eval() public static méthode

Evaluates a hand (passed as a hand mask) and returns a hand value. A hand value can be compared against another hand value to determine which has the higher value.
public static Eval ( ulong cards, int numberOfCards ) : uint
cards ulong hand mask
numberOfCards int number of cards in the hand
Résultat uint

Evaluate() public static méthode

public static Evaluate ( string pocketCardsStr, string boardStr, string deadStr ) : EvaluationPocket
pocketCardsStr string
boardStr string
deadStr string
Résultat EvaluationPocket

EvaluateType() public static méthode

Evaluates the card mask and returns the type of hand it is. This function is faster (but provides less information) than Evaluate or Evaluate.
public static EvaluateType ( ulong mask ) : HandTypes
mask ulong card mask
Résultat HandTypes

EvaluateType() public static méthode

This function is faster (but provides less information) than Evaluate or Evaluate.
public static EvaluateType ( ulong mask, int cards ) : HandTypes
mask ulong card mask
cards int number of cards in mask
Résultat HandTypes

GapCount() public static méthode

Counts the number of empty space between adjacent cards. 0 means connected, 1 means a gap of one, 2 means a gap of two and 3 means a gap of three.
public static GapCount ( ulong mask ) : int
mask ulong two card hand mask
Résultat int

GetHashCode() public méthode

Returns hash code
public GetHashCode ( ) : int
Résultat int

Hand() public méthode

Default constructor
public Hand ( ) : System
Résultat System

Hand() public méthode

Constructor
public Hand ( string pocket, string board ) : System
pocket string Pocket Cards
board string Board
Résultat System

HandOdds() public static méthode

Used to calculate the wining information about each players hand. This function enumerates all possible remaining hands and tallies win, tie and losses for each player. This function typically takes well less than a second regardless of the number of players.
public static HandOdds ( string pockets, string board, string dead, long wins, long ties, long losses, long &totalHands ) : void
pockets string Array of pocket hand string, one for each player
board string the board cards
dead string the dead cards
wins long An array of win tallies, one for each player
ties long An array of tie tallies, one for each player
losses long An array of losses tallies, one for each player
totalHands long The total number of hands enumarated.
Résultat void

HandPlayerOpponentOdds() public static méthode

Given a set of pocket cards and a set of board cards this function returns the odds of winning or tying for a player and a random opponent.
public static HandPlayerOpponentOdds ( string pocketcards, string boardcards, double &player, double &opponent ) : void
pocketcards string Pocket cards in ASCII
boardcards string Board cards in ASCII
player double Player odds as doubles
opponent double Opponent odds as doubles
Résultat void

HandPlayerOpponentOdds() public static méthode

Given a set of pocket cards and a set of board cards this function returns the odds of winning or tying for a player and a random opponent.
public static HandPlayerOpponentOdds ( ulong ourcards, ulong board, double &player, double &opponent ) : void
ourcards ulong Pocket mask for the hand.
board ulong Board mask for hand
player double Player odds as doubles
opponent double Opponent odds as doubles
Résultat void

HandPotential() public static méthode

Returns the positive and negative potential of the current hand. This funciton is described in Aaron Davidson's masters thesis (davidson.msc.pdf).
public static HandPotential ( ulong pocket, ulong board, double &ppot, double &npot ) : void
pocket ulong Hold Cards
board ulong Community cards
ppot double Positive Potential
npot double Negative Potential
Résultat void

HandType() public static méthode

public static HandType ( uint handValue ) : uint
handValue uint
Résultat uint

Hands() public static méthode

Enables a foreach command to enumerate all possible ncard hands.
public static Hands ( int numberOfCards ) : IEnumerable
numberOfCards int the number of cards in the hand (must be between 1 and 7)
Résultat IEnumerable

Hands() public static méthode

Enables a foreach command to enumerate all possible ncard hands.
public static Hands ( ulong shared, ulong dead, int numberOfCards ) : IEnumerable
shared ulong A bitfield containing the cards that must be in the enumerated hands
dead ulong A bitfield containing the cards that must not be in the enumerated hands
numberOfCards int the number of cards in the hand (must be between 1 and 7)
Résultat IEnumerable

IsConnected() public static méthode

Returns true if the cards in the two card hand are connected.
public static IsConnected ( ulong mask ) : bool
mask ulong the hand to check
Résultat bool

IsSuited() public static méthode

This function returns true if the cards in the hand are all one suit
public static IsSuited ( ulong mask ) : bool
mask ulong hand to check for "suited-ness"
Résultat bool

Mask() public static méthode

This is a fast way to look up the index mask.
public static Mask ( int index ) : ulong
index int index of mask
Résultat ulong

MaskToString() public static méthode

Turns a card mask into the equivalent human readable string.
public static MaskToString ( ulong mask ) : string
mask ulong mask to convert
Résultat string

NextCard() public static méthode

Parses Card strings (internal)
public static NextCard ( string cards, int &index ) : int
cards string string containing hand definition
index int iterator into card string
Résultat int

Outs() public static méthode

Returns the number of outs possible with the next card.
public static Outs ( ulong player, ulong board ) : int
player ulong Players pocket cards
board ulong THe board (must contain either 3 or 4 cards)
Résultat int

OutsMask() public static méthode

Creates a Hand mask with the cards that will improve the specified players hand against a list of opponents or if no opponents are list just the cards that improve the players current had. Please note that this only looks at single cards that improve the hand and will not specifically look at runner-runner possiblities.
public static OutsMask ( ulong player, ulong board ) : ulong
player ulong Players pocket cards
board ulong The board (must contain either 3 or 4 cards)
Résultat ulong

ParseCard() public static méthode

Reads an string definition of a card and returns the Card value.
public static ParseCard ( string card ) : int
card string card string
Résultat int

ParseHand() public static méthode

Parses an string description of a hand and returns a hand mask.
public static ParseHand ( string hand ) : ulong
hand string string descripton of a hand
Résultat ulong

ParseHand() public static méthode

public static ParseHand ( string hand, int &cards ) : ulong
hand string
cards int
Résultat ulong

ParseHand() public static méthode

This static method parses the passed pocket cards and board and produces a card mask.
public static ParseHand ( string pocket, string board, int &cards ) : ulong
pocket string ASCII string representing pocket cards
board string ASCII string representing board
cards int Number of cards represented in mask
Résultat ulong

PocketHand169Type() public static méthode

Given a pocket pair mask, the PocketPairType cooresponding to this mask will be returned.
public static PocketHand169Type ( ulong mask ) : PocketHand169Enum
mask ulong
Résultat PocketHand169Enum

RandomHands() public static méthode

Iterates through random hands that meets the specified requirements until the specified time duration has elapse. Please note that this iterator requires interop. If you need and interop free hand evaluator you should remove this function along with the other interop functions in this file.
public static RandomHands ( int ncards, double duration ) : IEnumerable
ncards int The number of cards in the returned hand.
duration double The amount of time to allow the generation of hands to occur. When elapsed, the iterator will terminate.
Résultat IEnumerable

RandomHands() public static méthode

Iterates through random hands with ncards number of cards. This iterator will return the number of masks specifed in trials. Masks can be repeated.
public static RandomHands ( int ncards, int trials ) : IEnumerable
ncards int Number of cards required to be in the hand.
trials int Number of total mask to return.
Résultat IEnumerable

RandomHands() public static méthode

Iterates through random hands that meets the specified requirements until the specified time duration has elapse. Please note that this iterator requires interop. If you need and interop free hand evaluator you should remove this function along with the other interop functions in this file.
public static RandomHands ( ulong shared, ulong dead, int ncards, double duration ) : IEnumerable
shared ulong These cards must be included in the returned hand
dead ulong These cards must not be included in the returned hand
ncards int The number of cards in the returned random hand.
duration double The amount of time to allow the generation of hands to occur. When elapsed, the iterator will terminate.
Résultat IEnumerable

RandomHands() public static méthode

This function iterates through random hands returning the number of random hands specified in trials. Please note that a mask can be repeated.
public static RandomHands ( ulong shared, ulong dead, int ncards, int trials ) : IEnumerable
shared ulong Cards that must be in the hand.
dead ulong Cards that must not be in the hand.
ncards int The total number of cards in the hand.
trials int The total number of random hands to return.
Résultat IEnumerable

ToString() public méthode

Returns the string representing the hand.
public ToString ( ) : string
Résultat string

TopCard() public static méthode

public static TopCard ( System hv ) : uint
hv System
Résultat uint

ValidateHand() public static méthode

This function takes a string representing a full or partial holdem hand and validates that the text represents valid cards and that no card is duplicated.
public static ValidateHand ( string hand ) : bool
hand string hand to validate
Résultat bool

ValidateHand() public static méthode

This function takes a string representing pocket cards and a board and then validates that the text represents a valid hand.
public static ValidateHand ( string pocket, string board ) : bool
pocket string Pocket cards as a string
board string Board cards as a string
Résultat bool

operator() public static méthode

Test for inequality.
public static operator ( ) : bool
Résultat bool

Property Details

CLUB_OFFSET public_oe static_oe property

public static int CLUB_OFFSET
Résultat int

CardJoker public_oe static_oe property

public static int CardJoker
Résultat int

CardMasksTable public_oe static_oe property

This table is equivalent to 1UL left shifted by the index. The lookup is faster than the left shift operator.
public static ulong[] CardMasksTable
Résultat ulong[]

CardTable public_oe static_oe property

public static string[] CardTable
Résultat string[]

Clubs public_oe static_oe property

Represents the suit - Clubs
public static int Clubs
Résultat int

DIAMOND_OFFSET public_oe static_oe property

public static int DIAMOND_OFFSET
Résultat int

Diamonds public_oe static_oe property

Represents the suit - Diamonds
public static int Diamonds
Résultat int

HEART_OFFSET public_oe static_oe property

public static int HEART_OFFSET
Résultat int

Hearts public_oe static_oe property

Represents the suit - Hearts
public static int Hearts
Résultat int

NCardsWJoker public_oe static_oe property

public static int NCardsWJoker
Résultat int

NumberOfCards public_oe static_oe property

The total number of cards in a deck
public static int NumberOfCards
Résultat int

Rank2 public_oe static_oe property

Rank of a card with a value of two.
public static int Rank2
Résultat int

Rank3 public_oe static_oe property

Rank of a card with a value of three.
public static int Rank3
Résultat int

Rank4 public_oe static_oe property

Rank of a card with a value of four.
public static int Rank4
Résultat int

Rank5 public_oe static_oe property

Rank of a card with a value of five.
public static int Rank5
Résultat int

Rank6 public_oe static_oe property

Rank of a card with a value of six.
public static int Rank6
Résultat int

Rank7 public_oe static_oe property

Rank of a card with a value of seven.
public static int Rank7
Résultat int

Rank8 public_oe static_oe property

Rank of a card with a value of eight.
public static int Rank8
Résultat int

Rank9 public_oe static_oe property

Rank of a card with a value of nine.
public static int Rank9
Résultat int

RankAce public_oe static_oe property

Rank of a card showing an Ace.
public static int RankAce
Résultat int

RankJack public_oe static_oe property

Rank of a card showing a Jack.
public static int RankJack
Résultat int

RankKing public_oe static_oe property

Rank of a card showing a King.
public static int RankKing
Résultat int

RankQueen public_oe static_oe property

Rank of a card showing a Queen.
public static int RankQueen
Résultat int

RankTen public_oe static_oe property

Rank of a card with a value of ten.
public static int RankTen
Résultat int

SPADE_OFFSET public_oe static_oe property

public static int SPADE_OFFSET
Résultat int

Spades public_oe static_oe property

Represents the suit - Spades
public static int Spades
Résultat int