Open Side Menu Go to the Top
Register
Build an equity calculator Build an equity calculator

09-14-2017 , 01:53 PM
I want to build an equity calculator in java (for android)

Specially for PLO. I have some basic knowledge of java and android studio, but I have no idea where should I begin with this task.

Could any one give me some advice or guide of where should I start?

I have been trying to look at any course or tutorial online on building poker equity calculator but have not found anything
Build an equity calculator Quote
09-14-2017 , 03:01 PM
In it's most basic form an equity "calculator" is really an enumerator. Basically, the user gives input, say, the hand each player has, and the cards on the flop.

The program generates each possible board. If player 1 won, he gets 1 point, if he lost, he gets 0 points, if he tied he gets 1/2 point. At the end you add these up and divide by how many boards you tried.

If there aren't very many combinations to test, you can do all of them. If there are a lot, you can just run for a while, and stop whenever you have "enough" results, for an approximation.

So basically you need 2 big moving parts:
1. something to "deal" random boards
2. something to evaluate a hand+board to see who won.

Doing it this straight-forward way is probably the right way to start, but there are lots of shortcuts to make it go faster.
Build an equity calculator Quote
09-15-2017 , 12:24 AM
Awesome and simple response, thanks! I will start right now to see how I make this work and see what happen
Build an equity calculator Quote
10-15-2017 , 11:00 AM
I am doing the pseudocode for this first.

I am planning to move it to Java later.

I am not being exact with the syntax plan, but I hope to solve it later.

I am planing to create an array for any card consisting of rank and suit in int format. First element will be the rank going from 0 to 12. Second element will be the suit going from 0 to 3.

Then any for example holdem hand, I am going to use an array of two arrays, each element will be an card array.

Then I am going with the strenght value method, I am going to evaluate all of the 21 different hand + board holdem combinations and select the winner, then battle the winner against the oponent winner hand.

Starting this evaluation with the higher strenghts hands and going down, so when the program validate a rank strenght doesn't have to evaluate the others down the way.

If we had a tie between first and second player in hand strenght, I would go to create diferent methods to solve ties in all the diferent hand strenghts.

This is where I am now. Could this logic take me to a functional program?

Last edited by Maroel; 10-15-2017 at 11:12 AM.
Build an equity calculator Quote
10-15-2017 , 01:44 PM
Quote:
Originally Posted by Maroel
I am planing to create an array for any card consisting of rank and suit in int format. First element will be the rank going from 0 to 12. Second element will be the suit going from 0 to 3.
There's nothing particularly wrong with this, but it's probably simpler to just have your cards be integers from 0 to 51. First 13 are clubs in order, then diamonds, hearts and spades. The rank of any card is i % 13 and the suit is i/4

Quote:
Then I am going with the strenght value method, I am going to evaluate all of the 21 different hand + board holdem combinations and select the winner, then battle the winner against the oponent winner hand.
You're making a PLO evaluator, right? So there are 6 ways to choose hole cards from your hand, and each has 10 ways to hit the board. I'm not sure what you get 21 from

Quote:
Starting this evaluation with the higher strenghts hands and going down, so when the program validate a rank strenght doesn't have to evaluate the others down the way.

If we had a tie between first and second player in hand strenght, I would go to create diferent methods to solve ties in all the diferent hand strenghts.
This is probably OK for a start. There is sort of a standard way to rank hands, that you might want to consider, which is to order them from 0 to N in order of increasing strength. Then to find the winner just pick the hand with the highest N. The main reason to do this is that later when you start making shortcuts, one of the shortcuts you'll want to make is to pre-calculate an array of, say, 5-card hands to their score, so that finding the winner becomes much faster. You can then "look it up" instead of "calculating it"

Most fast hand evaluators have several table of data they look stuff up in. There's always a tradeoff between time saved by precalculating, and memory taken by these lookup tables.

Quote:
This is where I am now. Could this logic take me to a functional program?
Yeah, I think so.
Build an equity calculator Quote
10-15-2017 , 02:48 PM
Quote:
There's nothing particularly wrong with this, but it's probably simpler to just have your cards be integers from 0 to 51. First 13 are clubs in order, then diamonds, hearts and spades. The rank of any card is i % 13 and the suit is i/4
When creating the hand strenght methods, I see it more simpler to just calculate for example the strenght of a pair from the rank itself no matter the suit. So I could do it accesing to the exact number in the array.

Same for the suits. Just acess to the exact array when evaluating flushes.

Altough this could takes me to duplicate problems and using the way you named could help a lot in this I guess.

I will see where it takes me and probably if I find dificulties I will look back at this advice


Quote:
You're making a PLO evaluator, right? So there are 6 ways to choose hole cards from your hand, and each has 10 ways to hit the board. I'm not sure what you get 21 from
Yes, but I was talking about a holdem hand in the example. I would do the same process for the 60 combinations in plo.


Appreciate the advices thanks!


P.D: Just tought right now of creating a total 52 deck cards array, having inside arrays of cards, each with his rank and suit.

That way I could keep the count and avoid duplicates easily, also eavluate strenght of hands easily. And generate the randoms easily too accesing to the deck array.

Last edited by Maroel; 10-15-2017 at 03:14 PM.
Build an equity calculator Quote
10-15-2017 , 03:53 PM
So there was another reason I didn't mention for using 0-51 for cards. You can represent any combination of cards with a single 64-bit integer, by setting each bit to 1 if the card is present and 0 if it isn't. Obviously you can't hold a "deck" this way because there's no ordering of the cards, but it's a pretty good way to make maps of hands, board, etc, i.e. good for lookup tables.

Using a little class or array to hold a card, i.e. with a number and suit is OK, it's just probably not the most efficient way to do it. Another fairly simple way is to use a little string like "Ac" or "5s" where the first character is the rank and the 2nd is the suit. This has the advantage of being easy to print/read for debugging (but, it's also easy enough to make a function that prints whatever value you have stored anyway)
Build an equity calculator Quote
10-22-2017 , 12:08 AM
Once you've made a working first version, required reading the the "Coding the Wheel - Hand Evaluator Roundup" article, which will need archive.org to find. And the referenced 2p2 thread "7-Card Hand Evaluators". But make your own idea first! GL!
Build an equity calculator Quote

      
m