Poker-AI.org

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

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Mar 01, 2016 6:35 am 
Offline
New Member

Joined: Tue Mar 01, 2016 6:19 am
Posts: 4
I am trying to build an equity range calculator similar to that of Pokerstove, pro poker tools, flopzilla etc.

I have the single hand vs hand hand working pefectly but when I do hand vs range I have small discrepencies when i have more than one opponent with the same cards or same ranges.

I was looking at the following source: https://github.com/mihhailnovik/jSim

In the area where there is monte carlo simulation I cannot figure what is different in my logic than from the code he provides so I;d like to explain what I'm doing and maybe someone can correct my approach.

1) I specify a players specific hand
2) specify the board.
3) I remove those cards from the remaining available cards.
4) Specify a few ranges for each opponent
5 ) For each iteration in the simulation i randomize who is dealt the first hand. For example Opponent 2 below might be dealt first and receive AdKc then the next iteration opponent 3 could be dealt first.
6) For each players range, i use rand on the number of ranges and then pull a specific hand based on that random value.
For example if a player can have 18 different hands between AA, KK, QQ i run a rand % 18 and the use the result as the hand from the array to assign.

I do that for each opponent and check to make sure the cards in the hand are available and not already taken such as:

if( (selectedHand & usedCards) ==0) {
opponentMask[n] = selectedHand;
}

When i run the code the results come back close but still like .25 or .45 different but other times they might be off be off by more depending on the order that I specified the ranges and how many opponents share similar ranges or hands with same cards.

It seems there is something not random enough in they way I am drawing hands. Can anyone suggest something I am fundamentally missing ? Thanks,

An example of something that would evaluate differently is
Player 9h9d
Opponent 1) AA,KK,QQ,TT,44
Opponent 2) 88,44,33,JTs
Opponent 3) KK,77,JJ,65s

will return about .3 to .4 different from

Player 9h9d
Opponent 1) 88,44,33,JTs
Opponent 2) KK,77,JJ,65s
Opponent 3) AA,KK,QQ,TT,44

board in both cases AsQc3d

Any insight or help is appreciated.


Top
 Profile  
 
PostPosted: Tue Mar 01, 2016 12:37 pm 
Offline
Site Admin
User avatar

Joined: Sun Feb 24, 2013 9:39 pm
Posts: 642
Why randomise? Could you assign a probability to opponents hands instead?


Top
 Profile  
 
PostPosted: Tue Mar 01, 2016 12:49 pm 
Offline
New Member

Joined: Tue Mar 01, 2016 6:19 am
Posts: 4
I simply wanted to replicate the randomize functionality for this exercise and then later worry about adding things like probabilities or weights.


Top
 Profile  
 
PostPosted: Tue Mar 01, 2016 7:19 pm 
Offline
Site Admin
User avatar

Joined: Sun Feb 24, 2013 9:39 pm
Posts: 642
Well I think that assigning a probability avoids the problem you are getting through randomisation


Top
 Profile  
 
PostPosted: Wed Mar 02, 2016 12:34 am 
Offline
New Member

Joined: Tue Mar 01, 2016 6:19 am
Posts: 4
spears wrote:
Well I think that assigning a probability avoids the problem you are getting through randomisation


Thanks, I figured out my basic problem was not properly handling collisions but what you are suggesting too sounds like a good idea.

Thank you for the input a good suggestion to consider as well


Top
 Profile  
 
PostPosted: Wed Mar 02, 2016 9:16 pm 
Offline
Senior Member
User avatar

Joined: Sun Mar 10, 2013 10:31 am
Posts: 139
no, no, no no.
You have several fundamental mistakes.
Here is how I solved not far ago problem like TS`s.

1. No any AA, AK, AKs. You need use AhKh, AhAd ... ets.
2. It is wery simple and useless model you want to calculate. Let's look wider.
Any player may have different cards with different probabilities.
Its about 1300 (not near my work now) different player cards combinations (of 2 cards)
And each combination have some chance to be.
This situation is easy represented by array
Code:
int ProbabilityVector[1300];
//each combination probability easy to calculate
int summ = 0;
for (p=0; p<1300; p++) summ += ProbabilityVector[p];

double P_129 = ProbabilityVector[129] / summ;
//but you need not any double in your calculations


Top
 Profile  
 
PostPosted: Wed Mar 02, 2016 9:22 pm 
Offline
Senior Member
User avatar

Joined: Sun Mar 10, 2013 10:31 am
Posts: 139
All you need is to Get some combination from the set with its probability;

it looks like:
Code:

bool Pockets_probability_vector::GetRandomPockets(card_t* c1, card_t* c2){
   
   int summ = 0;
   for (int pok = 0; pok < TotalPockets; pok++){
      if (Core[pok] > 0) summ += Core[pok];
   }

   if (summ == 0) return false;

   int rand_summ = rand() % summ;
   int rand_number = -1;
   summ = 0;
   for (int pok = 0; pok < TotalPockets; pok++){
      if (Core[pok] > 0) summ += Core[pok];
      if (summ > rand_summ){
         rand_number = pok;
         break;
      }
   }

   if (rand_number == -1) return false;

   NumberToPockets(rand_number, c1, c2);

   return true;
}



Top
 Profile  
 
PostPosted: Wed Mar 02, 2016 9:26 pm 
Offline
Senior Member
User avatar

Joined: Sun Mar 10, 2013 10:31 am
Posts: 139
Second. There are not wining hand and wining %. Its pure and unuseless tactic. You need to calculate who and how mutch win.
For example 2 players of 3 split the bank, and 3rd loose. Or all players have different stakes.


Top
 Profile  
 
PostPosted: Wed Mar 02, 2016 9:39 pm 
Offline
Senior Member
User avatar

Joined: Sun Mar 10, 2013 10:31 am
Posts: 139
And of cause. Algoritm for your problem.


1. Deal cards to hero.
1.1. deal known cards on the table
2. Generate Probability vectors for all opponents.
3. Delete forever all combinations with hero cards and known table cards from player vectors.
Code:
#define deletedForever -100500

4. Loop
5. Get random combination from player1 set.
6. Delete temporaly all combinations from other players sets
7. There you have all players with cards
8. Get random cards to the table and calculate profits.
9. Restore player vectors
and again and again


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 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:
Powered by phpBB® Forum Software © phpBB Group