- hand_evaluator.zip
- Hand Evaluator
- Applications
- Benchmark
- MultiOddsApp
- MultiOddsGrid
- MultiOppOdds
- OddsGrid
- OddsGridApp
- bin
- Debug
- ZedGraph.dll
- Release
- ZedGraph.dll
- HandEvaluator.sln
- HandEvaluator
- Samples
- PocketHandExamples
- WinOddsExhaustive
- WinOddsMonteCarlo
- WinOddsMultipleOpponents
- WinOddsMultipleOpponentsTable
- WinOddsMultipleThreads
|
using System;
using System.Collections.Generic;
using HoldemHand;
namespace WinOddsExhaustive
{
class Program
{
static void Main(string[] args)
{
// This code calculates the probablity of As Ks winning against
// another random hand.
ulong pocketmask = Hand.ParseHand("As Ks"); // Hole hand
ulong board = Hand.ParseHand(""); // No board cards yet
long wins = 0, ties = 0, count = 0; // Iterate through all possible opponent hole cards
double start = Hand.CurrentTime;
// Iterate through all possible opponent hands
foreach (ulong oppmask in Hand.Hands(0UL, board | pocketmask, 2))
{
// Iterate through all possible board cards
foreach (ulong boardmask in Hand.Hands(board, pocketmask | oppmask, 5))
{
// Evaluate the player and opponent hands and tally the results
uint pocketHandVal = Hand.Evaluate(pocketmask | boardmask, 7);
uint oppHandVal = Hand.Evaluate(oppmask | boardmask, 7);
if (pocketHandVal > oppHandVal)
{
wins++;
}
else if (pocketHandVal == oppHandVal)
{
ties++;
}
count++;
}
}
// Prints: Win 67.0446323092352%
Console.WriteLine("Win {0}%, Elapsed Time {1}",
(((double)wins) + ((double)ties) / 2.0) / ((double)count) * 100.0,
Hand.CurrentTime-start);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I work at Tektronix in Beaverton OR. I've been programming for fun since 1975 (I started while in a Computer Explorer Scout group in Spokane WA). I've been programming in C since 1979 and I've been working professionally since 1983.
I really enjoy www.codeproject.com. It has saved me an incredible amount of time. I only hope my small contributions have given back some of what I've taken.