Advertisement

poker game

Started by November 01, 2024 12:29 AM
158 comments, last by pbivens67 6 hours, 50 minutes ago

I am also studying up on equity buckets which might be helpful in coding my game.

pbivens67 said:
what is a label of the outermost box?

Ah sorry. The label was supposed to be used for the name of the variable, but I never mentioned that.

Advertisement

what variable are you referring to?

Every variable in your program.

I started with “A variable is like a box with a type and a label.”

For example the “Hand hand” variable in the main program. I said that you can see it as a box. You write “hand” on the label of the box so you know which box you have.

Inside a box you store a value or more boxes for internal variables. In the “hand” box (of type “Hand”), there are 3 boxes inside the “hand” box, since the "Hand" type/class has 3 local variables.

It looks like this:

As you can see there is neither a box with “h_one” label at the outside nor a box with “h_two” label at the outside.

Such boxes do exist inside the “hand” box, but the compiler doesn't look there.

Therefore the compiler cannot find the boxes you refer to in the CompareHands call.

Okay. There's that. Everything has to start from somewhere.

pbivens67 said:

I am also studying up on equity buckets which might be helpful in coding my game.

Equity buckets appear to be a really neat concept for decision making. Thanks for that, as it applies to chess as well.
We'll still need an evaluator to determine what we have in our hands.
These are the links I've bookmarked for down time review and reference.
https://blog.gtowizard.com/the-magic-of-equity-buckets/
https://github.com/zekyll/OMPEval
https://github.com/christophschmalhofer/poker/blob/master/XPokerEval/XPokerEval.CactusKev.PerfectHash/fast_eval.cpp

The first link is a nice overview of someone using Equity Buckets in the context of human memory.
The second link is an advanced implementation of both equity and evaluation.
The third link is included as a claimed optimized implementation of the Grand-Daddy Cactus Kev's Poker Hand Evaluator.

Some foundational terms to be aware of:
Hash function - Wikipedia
Monte Carlo method - Wikipedia

If you find something better. Please do share.

Dev careful. Pixel on board.

I am studying the first link and wish there was there was more non github links

Advertisement

I have stubbed out some very simple code, all I am trying to do is convert a number from 1-52 to 4 sets of 2-14.

here is the code I am using.

#include <iostream>

using namespace std;

int main()
{
	int num = 0, rem_total = 0;

	cout << "Enter number (1-52): ";
	cin >> num;
	cout << endl;

	rem_total = num % 14 + 1;

	cout << "Rem total: " << rem_total << endl;

	return 0;
}

#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
    int num = 0, remainder = 0;

    cout << "Enter number (1-52): ";
    cin >> num;

    remainder = num % 13;                                 // there are only 13 cards per suit
    cout << "Rem total: " << remainder << endl;           // internal machine understand-able representation ( remainder: 0==Ace, 1==Two )
    cout << "Card value: " << remainder + 1 << endl;      // human understand-able card value ( remainder+1: 1==Ace, 2==Two, ...)
    cout << "Card suit: ";                                // human understand-able suit from deck range __.
    if (num < 14) cout << "clubs" << endl;                //                                              |
    if (num > 13 && num < 27) cout << "diamonds" << endl; //                                              |
    if (num > 26 && num < 40) cout << "spades" << endl;   //                                              |
    if (num > 39) cout << "hearts" << endl;               //                                              V
    
    return 0;
}

Dev careful. Pixel on board.

thanks for all the help my code was similar to yours

similar, yes. one was broken the other was less broken.

Dev careful. Pixel on board.

Advertisement