Skip to forum
Stackoffski vs Stac...
 
Notifications
Clear all

Stackoffski vs Stackoffski

232 Posts
12 Users
84 Reactions
16.2 K Views
Stackoffski
Joined: 08.09.2021

133,784,560 === 36,000,000
I managed to store the ranking of all 133,784,560 7-card combinations in a JSON file of 3.6MB. Combinations that are not truly unique are only stored once, both the non-flush hands, but now also the flush hands. But all the 133,784,560 combos are represented in 3.6MB. That is only 0.27 byte per combo. This is a real achievement for me, all made possible by prime numbers.

The equity-calculator still takes ~1.35 seconds for comparing 2 hands. It runs all possible boards, it's not an estimation. Also works for more hands. I don't know how I could speed it up anymore. But maybe I'll think of something.


Reply
Quote
Stackoffski
Joined: 08.09.2021

Whoops ... I said it was 3.6mb, but that was because some numbers I used where too big for javascript, and some things that shouldn't got overwritten (they all used the largest integer possible). Luckily the new size is still only 4032kb.

Something is slightly off though, and I really do no know what it is. I checked and rechecked everything and some more checking after that, but my results are a bit different than Pokerst_ve (very old), F___zilla, Equilab, and some websites, which by the way sometimes give slightly different results compared to each other. But my results differ slighly more ...

My results for AsKs vs 9h8h for example:

-------------
As,Ks: equity:64.28%, win:63.93%, tie:0.35%, boards:1712304
9h,8h: equity:36.07%, win:35.72%, tie:0.35%, boards:1712304
-------------

Results of different calculators:

Spoiler

Pokerst_ve:

         equity   win     tie     pots won pots tied	
Hand 0:  62.116%  61.89%  00.23%  1059724  3905.00   { AsKs }
Hand 1:  37.884%  37.66%  00.23%  644790   3905.00   { 9h8h }

But, if you sum up the pots here, there are only 1,708,419 instead of all 1,712,304 boards possible!

F___zilla:

     Equity    Win       Tie
Asks: 62.116%  61.889%   0.455%
9h8h: 37.884%  37.656%   0.455%

Equilab:

	Equity	Win	Tie
MP2	62.12%	61.89%	0.23%	{ AsKs }
MP3	37.88%	37.66%	0.23%	{ 9h8h }

Some online calculators:

AsKs: 61.89%
9h8h: 37.66%
Tie: 0.45%


Reply
Quote
Rhodriguez
Joined: 01.10.2006

Very good. Heads-up are 1712304 different boards. For both players that makes 3.4 M hands in 1.35 seconds. 2.5 M hand evaluations per second.
Now it would be good to know how fast zilla actually is on your system. To have an idea how far away you are with your nodejs solution compared to a compiled product.


Reply
Quote
Stackoffski
Joined: 08.09.2021

Originally posted by Rhodriguez
Very good. Heads-up are 1712304 different boards. For both players that makes 3.4 M hands in 1.35 seconds. 2.5 M hand evaluations per second.
Now it would be good to know how fast zilla actually is on your system. To have an idea how far away you are with your nodejs solution compared to a compiled product.

I dabbed a bit in C++ and C# last year, but I forgot almost everything. I might learn enough C++ to rebuild this in C++, and see what's the speed difference.

I also wonder what it would do in Chrome vs Nodejs. They both use V8 javascript engine I think. Will take a look at that first.

Last year I made a generic linked list in all 3 languages and the javascript one was way faster than the other ones. But that probably isn't always the case. Also I know nothing about compiling. Using Visual Studio, i did set it on release mode instead of development mode.

Did you finish your equity calculator or not?


Reply
Quote
Stackoffski
Joined: 08.09.2021

I coded the equity calculation concurrently/asynchrounously in nodejs (= doing things at the same time instead of one after the other), but it only got slower :f_zZz:.

I guess there is some initial overhead for doing things concurrently, and the benefit only comes when you have multiple large calculations to do, instead of millions of small ones. It would probably be usefull for range vs range comparisons. But the javascript engine is just probably too slow anyway ...

So I am going to use this project to learn some c++. I used it just a little bit in the past, but forgot completely everything. Probably will take me a while to code it proper because it's not easy. Javascript is really nice and flexible, you get things done much quicker. (It has other drawbacks though, including the speed probably).
You need a lot more code with c++.


Reply
Quote
Stackoffski
Joined: 08.09.2021

Yess ... I found a flaw in my javascript code after all. Now it generates pretty much the same results as any old equity calculator!! :f_thumbsup::f_thumbsup:

-------------
As,Ks: equity:62.34%, win:61.89%, tie:0.45%, boards:1712304
9h,8h: equity:38.11%, win:37.66%, tie:0.45%, boards:1712304
-------------

I also already almost have a badly coded (I assume) c++ version of the same code to see if it is any faster than the ~1.5sec.


Reply
Quote
Rhodriguez
Joined: 01.10.2006

pretty much the same results as any old equity calculator!! :f_thumbsup::f_thumbsup:

-------------
As,Ks: equity:62.34%, win:61.89%, tie:0.45%, boards:1712304
9h,8h: equity:38.11%, win:37.66%, tie:0.45%, boards:1712304
-------------

Don't scare me!
62.34+38.11= 100.45.
Ties are only half added to the equity. 61.89+0.225 = 62.115 (with your rounded result)


Reply
Quote
Stackoffski
Joined: 08.09.2021

Originally posted by Rhodriguez

pretty much the same results as any old equity calculator!! :f_thumbsup::f_thumbsup:

-------------
As,Ks: equity:62.34%, win:61.89%, tie:0.45%, boards:1712304
9h,8h: equity:38.11%, win:37.66%, tie:0.45%, boards:1712304
-------------

Don't scare me!
62.34+38.11= 100.45.
Ties are only half added to the equity. 61.89+0.225 = 62.115 (with your rounded result)

Ah oke thank you!! I thought it was supposed to be this way. luckily 61.89 + 37.66 + 0.45 = 100.

----

I tried to build pretty much the same thing in c++, and it takes 2.2sec (same results) :f_zZz:
However, I don't really know c++ well, so probably a lot of things can be more efficient.


Reply
Quote
Stackoffski
Joined: 08.09.2021

Graph for January:

A nice win :f_thumbsup:, but going down fast now :f_o:


Reply
Quote
Rhodriguez
Joined: 01.10.2006

I tried to build pretty much the same thing in c++, and it takes 2.2sec (same results) :f_zZz:

Maybe I should ask as well. How do you measure time? With startup or after loading everything and then how long it takes.


Reply
Quote
Stackoffski
Joined: 08.09.2021

Some more programming, less playing poker ...
Used the equity calculator-project to take another good look at c++. It is supposed to be really fast, but a few times now, every time I check it vs Javascript (which is supposed to be slow) there is not much of a difference. That Google V8 JS engine is so incredibly optimized and fast.

I tried to build the same equity calculator project in a comparable way in both languages to check for the speed difference. There is a little bug somewhere in the c++ version, don't know what. Results are slightly off! But I don't think the speed will matter if I find it.

The good news about how I build it with a prime-number system is that it only uses 1 data-file of just ~800kb. The bad news is that I can't get either version to run within a second.

For the same comparison:
c++: 1.125 seconds.
JS: 1.368 seconds

If I want to beat this time I should probably take a look at other (existing) solutions than using the prime numbers.

I like Javascript so much, I don't know if I will continue the C++ journey ...

This was the ouput (wrong in c++ output because of something something):

Spoiler

C++ (uses datafile of 798kb): (Wrong!)

//-------------------------------------------------------|
// Timer stopped. Duration: 1.125 seconds.
//-------------------------------------------------------|
AsKs: Equity:60.573% Win:59.714% Tie:1.719% Runs:1712304 wins:1022488 ties:29427
98h8: Equity:39.427% Win:38.567% Tie:1.719% Runs:1712304 wins:660389 ties:29427
//-------------------------------------------------------|

Javascript (uses json datafile of 853kb):

//-----------------------------------------|
timer: 1.368s
//-----------------------------------------|
AsKs: equity:62.116% win:61.889% tie:0.455% wins: 1059724 ties:7790 runs:1712304
9h8h: equity:37.884% win:37.656% tie:0.455% wins: 644790 ties:7790 runs:1712304
//-----------------------------------------|


Reply
Quote
Super Moderator
VorpalF2F
Joined: 02.09.2010

Originally posted by Stackoffski
Some more programming, less playing poker ...

I like Javascript so much, I don't know if I will continue the C++ journey ...

"To the one who has a hammer, everything is a nail".
Stick with what you're good at, or if you're OK with different things, use the one best suited to the job.
It seems to me, that unless you're going to get some genuine benefit from the amount of effort required, it's best to stick to what you know.

I use c++ when I need a stand-alone executable (which isn't very often).
Twenty years ago, this was fairly often, and back then we used vbScript on the server side to create .asp pages.
We had a full MSDN subscription, so we just pulled what we needed out of package — web server software, compilers etc.

These days I used python for most things, and AutoHotkey for desktop automation.

I'm no expert in any of the above though.
If I get stuck (or lazy) I just ask Perplexity ( https://www.perplexity.ai/) for help.
I'll also recommend DebugView++[1] for keeping an eye on what your program is doing while you're beating it into shape.

Is your project on GitHub?

[1] https://github.com/CobaltFusion/DebugViewPP


Reply
Quote
Stackoffski
Joined: 08.09.2021

No, it's not on Github. To tell you the truth I don't even know how to use github. :f_o:

I am not a real programmer (whatever that is). I never really use other people's code either. I always try to reinvent the wheel myself and use common sense to analyze the problem and find a solution. It's not an efficient way of going about things if having the end-product is the goal, but I use programming for keeping my brains active more than anything else really.


Reply
Quote
Super Moderator
VorpalF2F
Joined: 02.09.2010

Originally posted by Stackoffski
No, it's not on Github. To tell you the truth I don't even know how to use github. :f_o:

There are a lot of tutorials on git, and you don't need GitHub to use git.
At its simplest, GitHub is just cloud storage for your projects.
That they're shareable is a bonus,

Originally posted by Stackoffski
I am not a real programmer (whatever that is).

Once I might have been considered a "real" programmer, but my job focus was training and customer support. Later, I started writing tools and scripts to automate my daily tasks


Reply
Quote
Stackoffski
Joined: 08.09.2021

Originally posted by VorpalF2F

Originally posted by Stackoffski
No, it's not on Github. To tell you the truth I don't even know how to use github. :f_o:

There are a lot of tutorials on git, and you don't need GitHub to use git.
At its simplest, GitHub is just cloud storage for your projects.
That they're shareable is a bonus,

Thanks! didn't even know they had tutorials.
When I see github, I always think you need to really study it before you can work with it though. I don't know a lot of the terminology that's used.

Originally posted by VorpalF2F

Originally posted by Stackoffski
I am not a real programmer (whatever that is).

Once I might have been considered a "real" programmer, but my job focus was training and customer support. Later, I started writing tools and scripts to automate my daily tasks

I was supposed to be a graphic designer, but I ventured into programming user-interfaces as well. Not just 'scripting' though.


Reply
Quote
Stackoffski
Joined: 08.09.2021

For those interested, the slowness of my programmed equity-calculator is all in getting the data from a datastructure (I use a map). Actually I really think it's superfast already and I would be satisfied with it if I didn't know it can be done faster. Not sure about how fast it can be with Javascript though.

It doesn't do much more after all the precalculations are done and stored in a data-file. The precalculations actually uses a lot more code then the final calculator itself, which is just a little bit of code that remains.

Anyway, everything but retrieving the data is actually superfast. The data-map is just a long list of numbers (that represent the cards in the hand) mapped to another number, which is the ranking of the hand (if you would have a list of all possible hand-rankings with 0 for the weakest hand up to x for a royal flush).

So the only way to speed it up is to speed up the data-retrieval process. I already learned a lot with this project, now I am looking at other ways to store the data. Maybe I can still speed it up if I can manage to get to the data faster. It is the only way to do it!


Reply
Quote
Super Moderator
VorpalF2F
Joined: 02.09.2010

Originally posted by Stackoffski
For those interested, the slowness of my programmed equity-calculator is all in getting the data from a datastructure (I use a map). Actually I really think it's superfast already and I would be satisfied with it if I didn't know it can be done faster. Not sure about how fast it can be with Javascript though.

I apologise if you've already posted the code, but if you did, could you let us know where?
I'd love to play with something like this.

Thanks
VS


Reply
Quote
Stackoffski
Joined: 08.09.2021

Originally posted by VorpalF2F

Originally posted by Stackoffski
For those interested, the slowness of my programmed equity-calculator is all in getting the data from a datastructure (I use a map). Actually I really think it's superfast already and I would be satisfied with it if I didn't know it can be done faster. Not sure about how fast it can be with Javascript though.

I apologise if you've already posted the code, but if you did, could you let us know where?
I'd love to play with something like this.

Thanks
VS

Oh no, I wasn't planning to, I will take a look at it. Maybe I can put the final code and the data on Github. No promises though ...
For the code that created the data file I don't have anything neat (yet) ... It is done in multiple steps in different files and a bit of a mess as it is.

cheers!


Reply
Quote
Stackoffski
Joined: 08.09.2021

Originally posted by Stackoffski
Oh no, I wasn't planning to, I will take a look at it. Maybe I can put the final code and the data on Github. No promises though ...
For the code that created the data file I don't have anything neat (yet) ... It is done in multiple steps in different files and a bit of a mess as it is.

cheers!

Yeah, I don't think I will post it anytime soon ... maybe I will when it is really done ...

Here is some pseudo-code to play with :f_p:. It generates all unique combinations of x size of something (unique as in different order does not make unique):

	generateCombos = function (cards[], size) {		
		combos = [];
		incomplete = [];
		for (card of cards) {
			for (combo of incomplete.copy()) {
				newCombo = combo.copy();
				newCombo.add(card);
				if (newCombo.size == size) {
					combos.add(newCombo);
				} else if (newCombo.size < size) {
					incomplete.add(newCombo);
				}
			}
			incomplete.add(new combo(card));
		}
		return combos;		
	}

Reply
Quote
Stackoffski
Joined: 08.09.2021

@ Vorpal:

Code

This is javascript and comes from a Nodejs project, you can create a new nodejs project in your Visual Studio and put in these files. app.js is the main file to run.

It is about 1.0secs to compare 2 hands without board cards dealt yet.

-

There's not much comments/explanation. Just ask me. It doesn't make checks for correct usage etc. for speed purposes.

The data-creation functions are not included, just the data. but everything those functions used is in there.


Reply
Quote