Open Side Menu Go to the Top
Register
Make Odds Calculator faster (iOS-Swift language) Make Odds Calculator faster (iOS-Swift language)

12-04-2019 , 04:02 PM
Any iOS devs out there? I am working on creating an odds calculator in Swift but the simulations are way too slow. It's taking 9 seconds to calculate a preflop all-in on my iPhone XR to simulate only 1000 hands.

I would like to get much closer to Poker Cruncher. They do 1 million sims in like 1 second.

If anyone wants to take a look this is where the code is:
https://github.com/jpaaquino/PokerEvaluator
Make Odds Calculator faster (iOS-Swift language) Quote
12-05-2019 , 01:38 AM
Heads up or multi-way? Sorry, I did not look at your code.

If it's heads up you can preload the win equities in a file, and read it into cache. 52x51x50x49/4/3/2 = 270,725 combos, which should be easily manageable.

If mulri-way, I suggest looking at skpe, which has an array footprint of about 60k elements, and only about 10 lines of runtime code.
Make Odds Calculator faster (iOS-Swift language) Quote
12-05-2019 , 08:14 AM
Quote:
Originally Posted by PokerHero77
Heads up or multi-way? Sorry, I did not look at your code.

If it's heads up you can preload the win equities in a file, and read it into cache. 52x51x50x49/4/3/2 = 270,725 combos, which should be easily manageable.

If mulri-way, I suggest looking at skpe, which has an array footprint of about 60k elements, and only about 10 lines of runtime code.
Thanks. That sounds like the way to go.

Heads up for now...

Problem is with C52,4 we'll get unordered combos right? And we care about the order of the cards partially(in whose hand the cards are).

Using a permutation(order matters) it would be ~6.5M combos. We can sort the order of the cards for each player (so that AK vs QJ = KA vs QJ = AK vs JQ = KA vs JQ) and the order of the players(AK vs QJ = QJ vs AK) to divide that by 8 and bring the number of combos down to 812,175 if my calculations are correct.

Does my calculation sound right to you? Did I miss anything or can you think of a way to bring the number of combos down a little more?
Make Odds Calculator faster (iOS-Swift language) Quote
12-05-2019 , 09:10 PM
Yeah, I was thinking about 4 cards instead of two 2 card hands.

52×51/2 × 50×49/2 = 1,624,350 combos. Should still be manageable.

You can map all hands with unmatching suits together, that will reduce the array. You can also map suit dominated hands.
Make Odds Calculator faster (iOS-Swift language) Quote
12-05-2019 , 10:52 PM
For example:
AK suited against AK suited is one item;
AK off against AQ off with K suit != Q suit is one item;
etc.
Make Odds Calculator faster (iOS-Swift language) Quote
12-06-2019 , 01:26 PM
I am thinking now how I would populate this list with the correct probabilities. If I use my calculator it would take literally months to simulate 1 million hands for ~1 million combos.

I wonder if there is a look-up table for preflop matchups already done somewhere... I couldn't find one
Make Odds Calculator faster (iOS-Swift language) Quote
12-10-2019 , 09:25 AM
Quote:
Originally Posted by BRpokah
I am thinking now how I would populate this list with the correct probabilities. If I use my calculator it would take literally months to simulate 1 million hands for ~1 million combos.

I wonder if there is a look-up table for preflop matchups already done somewhere... I couldn't find one
If you look at the code I posted here: https://forumserver.twoplustwo.com/s...3&postcount=51

then it shows how to use this look-up table: http://jukofyork.com/2WAY_HandEval.dat

You should be able to use LoadEVLookups() and CreateModifiedHoleMultiplicityTables() to create the lookup table you are after.

Juk

PS: Somewhere I have the same for 3-way match-ups... If you have any luck getting this working I'll try and find it for you if you want.
Make Odds Calculator faster (iOS-Swift language) Quote
12-10-2019 , 06:08 PM
Thanks. I'll take a look in detail later.
Make Odds Calculator faster (iOS-Swift language) Quote

      
m