Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 12-04-2019, 04:02 PM   #1
BRpokah
veteran
 
Join Date: Oct 2007
Posts: 2,414
Make Odds Calculator faster (iOS-Swift language)

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
BRpokah is offline   Reply With Quote
Old 12-05-2019, 01:38 AM   #2
PokerHero77
veteran
 
Join Date: Oct 2008
Posts: 2,518
Re: Make Odds Calculator faster (iOS-Swift language)

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.
PokerHero77 is offline   Reply With Quote
Old 12-05-2019, 08:14 AM   #3
BRpokah
veteran
 
Join Date: Oct 2007
Posts: 2,414
Re: Make Odds Calculator faster (iOS-Swift language)

Quote:
Originally Posted by PokerHero77 View Post
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?
BRpokah is offline   Reply With Quote
Old 12-05-2019, 09:10 PM   #4
PokerHero77
veteran
 
Join Date: Oct 2008
Posts: 2,518
Re: Make Odds Calculator faster (iOS-Swift language)

Yeah, I was thinking about 4 cards instead of two 2 card hands.

5251/2 5049/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.
PokerHero77 is offline   Reply With Quote
Old 12-05-2019, 10:52 PM   #5
PokerHero77
veteran
 
Join Date: Oct 2008
Posts: 2,518
Re: Make Odds Calculator faster (iOS-Swift language)

For example:
AK suited against AK suited is one item;
AK off against AQ off with K suit != Q suit is one item;
etc.
PokerHero77 is offline   Reply With Quote
Old 12-06-2019, 01:26 PM   #6
BRpokah
veteran
 
Join Date: Oct 2007
Posts: 2,414
Re: Make Odds Calculator faster (iOS-Swift language)

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
BRpokah is offline   Reply With Quote
Old 12-10-2019, 09:25 AM   #7
jukofyork
Carpal \'Tunnel
 
jukofyork's Avatar
 
Join Date: Sep 2004
Posts: 11,532
Re: Make Odds Calculator faster (iOS-Swift language)

Quote:
Originally Posted by BRpokah View Post
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.
jukofyork is offline   Reply With Quote
Old 12-10-2019, 06:08 PM   #8
BRpokah
veteran
 
Join Date: Oct 2007
Posts: 2,414
Re: Make Odds Calculator faster (iOS-Swift language)

Thanks. I'll take a look in detail later.
BRpokah is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 12:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online