Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 3:40 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: HS & HS2 Calculation :
PostPosted: Wed Sep 04, 2013 6:17 pm 
Offline
Junior Member

Joined: Wed Sep 04, 2013 6:05 pm
Posts: 47
Hey Guyz,

My next question is regarding the calculation oh HS2.

From

Quote:
To determine the hand strength squared value, the program
performs two card roll outs up to the river for the different hands. Considering the
first roll out for hand A, it randomly deals the missing board cards. Since the actual
situation takes place in the second round, i.e. the flop, the program simulates
adding another turn and river card. Afterwards, it determines the resulting river hand strength for combination A. It assumes a uniform distribution of opponent
hole cards, enumerates all of them and checks how often it would win, lose or
tie. The resulting river hand strength of the first roll out is 0.1. The turn and river
cards are simulated again and the river hand strength is calculated once more, for
example 0.9.
HS = 0,9 + 0,1 =0,5
---------
2

HS = 0,9² + 0,1² =0,41
---------
2


What are the 0,9 and 0,1 values ?

This how I calculate HS : PreFlop_HandStrength = ((float)totalWins+((float)totalTies/2))/(totalShowdowns);

And by the way ho should I calculate the HS2 ???

Thank you for your help.

PS : I have searched in the archive forum but the search engine doesn't work anymore...

MrNice


Top
 Profile  
 
PostPosted: Wed Sep 04, 2013 9:55 pm 
Offline
Junior Member

Joined: Mon Aug 12, 2013 7:28 pm
Posts: 16
Ok, let's say you want to compute the E[HS2] of your 2 hole cards.
Code:
foreach combination of flop,turn,river
{
    reset win,tie,loss
    foreach combination of the 2 opponent hole cards
    {
        update win,tie,loss
    }
    hs = (win+tie/2)/(win+tie+loss)
    hs2 += hs*hs
}
hs2 /= number of iterations

So the 0.9 and 0.1 squared are the square in my code (hs*hs)


Top
 Profile  
 
PostPosted: Thu Sep 05, 2013 6:02 am 
Offline
Site Admin
User avatar

Joined: Sun Feb 24, 2013 9:39 pm
Posts: 642
MrNice wrote:
PS : I have searched in the archive forum but the search engine doesn't work anymore...

viewtopic.php?p=3095&f=21#p3095


Top
 Profile  
 
PostPosted: Thu Sep 05, 2013 8:50 am 
Offline
Junior Member

Joined: Wed Sep 04, 2013 6:05 pm
Posts: 47
Hi Spears,

thanks for your help :D

That's good that you have give a second life to the forum :D


Top
 Profile  
 
PostPosted: Fri Sep 06, 2013 11:12 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
I am also trying to figure out how to compute EHS2, so I will just hijack this thread instead of starting a new one. Hope you excuse. (better to have it in one place, I think)

Quote:
Ok, let's say you want to compute the E[HS2] of your 2 hole cards.

Code:

foreach combination of flop,turn,river
{
reset win,tie,loss
foreach combination of the 2 opponent hole cards
{
update win,tie,loss
}
hs = (win+tie/2)/(win+tie+loss)
hs2 += hs*hs
}
hs2 /= number of iterations


So the 0.9 and 0.1 squared are the square in my code (hs*hs)


Should you really do the 'hs2 /= number of iterations' division? Hasn't that already been done when you divide by (win+tie+loss) ?

Also, if I understand correctly, the above calculation is for 2 players. For more than 2 players, the calculation should take the number of tied players into account. Like this:
Code:
hs = (win+tie/numberOfTiedPlayers)/(win+tie+loss)

Having read this page: http://www.codingthewheel.com/archives/multiway-ranged-isometric-equity-calculation-in-poker-1/
I think the value 'hs' with this formula is also called 'Equity'. (could someone please correct me if I am wrong?)

I have also seen another formula for EHS that is quite different: (source: http://poker-ai.org/archive/www.pokerai.org/pf3/viewtopica90d.html?f=3&t=2777)
Quote:
EHS = HS + (1-HS) * PPOT - HS * NPOT

Where I believe PPOT is probability HS will increase on River compared to current street (Flop or Turn), NPOT is probability HS will decrease. (could someone please correct me if I am wrong?)

Which formula for EHS is correct, the one shown by vlad2048 or the one above?

If I use the formula above, would this mean: EHS2 = EHS*EHS ?

I have found some definitions that might help in a paper from UAlberta: http://webdocs.cs.ualberta.ca/~johanson/publications/poker/2013-aamas-kmeans-abstraction/2013-aamas-kmeans-abstraction.pdf
Quote:
Hand Strength (HS): In the final round when all public cards have been revealed, a player's hand strength (HS) is the probability that their hand is stronger than a uniform randomly sampled opponent hand.

Expected Hand Strength (EHS): In the earlier rounds, expected hand strength (E[HS]) is the expectation of hand strength over all possible rollouts of the remaining public cards.

Expected Hand Strength Squared (EHS2):A related metric, expected hand strength squared (E[HS2]), computes the expectation of the squared hand strength values, and assigns a relatively higher value to hands with the potential to improve such as flush-draws or straight-draws.


In the definitions above, they say 'stronger than a uniform randomly sampled opponent hand'. But before evaluation and computation of EHS and EHS2, my opponent modeller will put opponents on a hand range, not a uniform randomly sampled hand. How does that change things?


Top
 Profile  
 
PostPosted: Fri Sep 06, 2013 6:35 pm 
Offline
Junior Member

Joined: Wed Sep 04, 2013 6:05 pm
Posts: 47
Seikez,

Following my fonction to calculate HS et HS²... Could inspire you maybe.

Code:
void PreFlop_HandStrength(int ourcard1, int ourcard2)
{
   long ahead=0, tied=0, behind=0;
   long totalWins = 0, totalTies = 0, totalShowdowns = 0, showdowns=0, totalBoards=0;

   HandVal ourrank=0;
   HandVal opprank=0;
   double EHS=0, EHS2=0;

   bool used[52];

   for (int i=0; i<52; i++)
   {
      used[i]=false;
   }

   used[ourcard1]=true;
   used[ourcard2]=true;

   StdDeck_CardMask ourhand;
   StdDeck_CardMask opphand;

   StdDeck_CardMask virginDeck[52];
   
   for (int index = 0; index < 52; index++)
   {
      virginDeck[index] = StdDeck_MASK(index);
   }

   for (int boardcard1 = 0; boardcard1 < 48; boardcard1++) if (!used[boardcard1])
   {
      used[boardcard1]=true;

      for (int boardcard2 = boardcard1+1; boardcard2 < 49; boardcard2++) if (!used[boardcard2])
      {
         used[boardcard2]=true;
         for (int boardcard3 = boardcard2+1; boardcard3 < 50; boardcard3++) if (!used[boardcard3])
         {
            used[boardcard3]=true;
            for (int boardcard4 = boardcard3+1; boardcard4 < 51; boardcard4++) if (!used[boardcard4])
            {
               used[boardcard4]=true;
               for (int boardcard5 = boardcard4 + 1; boardcard5 < 52; boardcard5++) if (!used[boardcard5])
               {
                  used[boardcard5]=true;
                  ahead=0;
                  tied=0;
                  behind=0;
                  showdowns=0;
                  totalBoards++;

                  for (int oppcard1 = 0; oppcard1 < 51; oppcard1++) if (!used[oppcard1])
                  {
                     used[oppcard1]=true;
                     
                     for (int oppcard2 = oppcard1 + 1; oppcard2 < 52; oppcard2++) if (!used[oppcard2])
                     {
                        used[oppcard2]=true;
                        
                        StdDeck_CardMask_RESET(ourhand);
                        StdDeck_CardMask_RESET(opphand);
                           
                        ourhand.cards_n = virginDeck[ourcard1].cards_n | virginDeck[ourcard2].cards_n | virginDeck[boardcard1].cards_n | virginDeck[boardcard2].cards_n | virginDeck[boardcard3].cards_n | virginDeck[boardcard4].cards_n | virginDeck[boardcard5].cards_n;
                        opphand.cards_n = virginDeck[oppcard1].cards_n | virginDeck[oppcard2].cards_n | virginDeck[boardcard1].cards_n | virginDeck[boardcard2].cards_n | virginDeck[boardcard3].cards_n | virginDeck[boardcard4].cards_n | virginDeck[boardcard5].cards_n;
                           
                        ourrank=StdDeck_StdRules_EVAL_N(ourhand, 7);
                        opprank=StdDeck_StdRules_EVAL_N(opphand, 7);

                        if(ourrank>opprank)
                        {
                           ahead++;
                        }
                        else if(ourrank==opprank)
                        {
                           tied++;
                        }

                        showdowns++;
                        used[oppcard2]=false;
                     }
                     used[oppcard1]=false;
                     
                  }

                  //To be fullfilled
                  totalWins += ahead;
                  totalTies += tied;
                  totalShowdowns += showdowns;

                  double _ehs = ((double)ahead + ((double)tied/2)) / showdowns;
                  EHS += _ehs;
                  EHS2 += _ehs*_ehs;

                  used[boardcard5]=false;
               }

               used[boardcard4]=false;
            }
            used[boardcard3]=false;
         }
         used[boardcard2]=false;
        }
      used[boardcard1]=false;
    }
   
   EHS  = EHS/totalBoards;
    EHS2 = EHS2/totalBoards;

   
   std::cout<<"EHS    : "<<EHS<<"\n";
   std::cout<<"EHS2   : "<<EHS2<<"\n";

 
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group