Advertisement

poker game

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

Would you be receptive to using other peoples’’ code?

If it is simple

Advertisement

That’s the goal. Ok I will come up with a code for you to classify the hand types. You can use it, or not. Give me a day.

As long as it is simple

It's about as simple as it gets. The code repository, so far, is at https://github.com/sjhalayka/poker/blob/main/main.cpp

I will post tomorrow when it's complete.

that is alot of code you do not have to post

Advertisement

I won't post the whole code, but do you understand what this code does:

bool is_flush(const vector<card>& sorted_hand)
{
	map<short unsigned int, size_t> suit_counts;

	for (size_t i = 0; i < NUM_CARDS_PER_HAND; i++)
		suit_counts[sorted_hand[i].suit]++;

	if (suit_counts.size() == 1 && suit_counts[0] == NUM_CARDS_PER_HAND)
		return true;

	return false;
}

I am unfamiliar with maps

Ok. The alpha code is uploaded. I haven’t tested the classification function fully, but most should work.

Let me test it some more, and then after that you can work at copying the code into your codebase.

As for map.. do you have any C++ books?

I ordered a new one it should get here tomorrow

Advertisement