Share this

Wizard Recommends

  • 300% + 40 Free Spins Play
  • $11000 Welcome Bonus Play
  • $3000 Welcome Bonus Play
Last Updated: June 22, 2021

Three Card Poker Analysis

Here is the code created in the video.

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

struct card {
	int r;
	int s;
};

void set_array(void);
int score(int p1, int p2, int p3);
void dealer(int p1, int p2, int p3, int psc, int event_array[]);

int score_array[22100];
card deck[52];

void main()
{
	int i, p1, p2, p3, sc, cat, pairplus_array[6], event_array[4],tot_ante_bonus[6];
	int ante_bonus_pay[] = { 0,0,0,1,4,5 };
	__int64 tot_event_array[6];
	string hand_name[] = { "Three singletons","Pair","Flush","Straight","Three of a kind","Straight flush" };
	string event_name[] = { "Player win","Dealer doesn't qualify","Tie","Dealer win","Player folds" };
	int index = 0;
	double ev = 0;
	for (i = 0; i < 6; i++)
	{
		tot_ante_bonus[i] = 0;
		pairplus_array[i] = 0;
		tot_event_array[i] = 0;
	}
	for (i = 0; i < 51; i++)
	{
		deck[i].r = (int)(i / 4);
		deck[i].s = i % 4;
	}
	set_array();
	for (p1 = 0; p1 <= 49; p1++)
	{
		for (p2 = p1 + 1; p2 <= 50; p2++)
		{
			for (p3 = p2 + 1; p3 <= 51; p3++)
			{
				sc = score_array[index];
				cat = (int)sc / 2197;
				pairplus_array[cat]++;
				dealer(p1, p2, p3, sc, event_array);
				ev = (2.0 * (double)event_array[0] + (double)event_array[1] - 2.0 * (double)event_array[3]) / 18424.0;
				ev += ante_bonus_pay[cat];
				if (ev < -1) // fold
				{
					tot_event_array[4] += 18424;
				}
				else
				{
					for (i = 0; i <= 3; i++)
						tot_event_array[i] += event_array[i];
					tot_ante_bonus[cat]++;
				}
				index++;
			}
		}
	}
	printf("Pairplus Analysis\n");
	for (i = 0; i < 6; i++)
		printf("%s\t%i\n", hand_name[i].c_str(), pairplus_array[i]);
	printf("\nAnte Analysis\n");
	for (i = 0; i <=4; i++)
		printf("%s\t%I64i\t%f\n", event_name[i].c_str(), tot_event_array[i],(double)tot_event_array[i]/22100.0/18424.0);
	double game_ev = (2.0 * (double)tot_event_array[0] + (double)tot_event_array[1] - 2.0 * (double)tot_event_array[3] - (double)tot_event_array[4]) / 22100.0 / 18424.0;
	printf("Game expected value w/o Ante Bonus=\t%f\n",game_ev );
	for (i = 0; i <= 5; i++)
		game_ev += ante_bonus_pay[i] * tot_ante_bonus[i] / 22100.0;
	printf("Game expected value w/ Ante Bonus=\t%f\n", game_ev);

}

void dealer(int p1, int p2, int p3, int psc, int event_array[])
{
	int d1, d2, d3, i,dsc;
	int index = 0;
	for (i = 0; i <= 3; i++)
		event_array[i] = 0;
	for (d1 = 0; d1 <= 49; d1++)
	{
		for (d2 = d1 + 1; d2 <= 50; d2++)
		{
			for (d3 = d2 + 1; d3 <= 51; d3++)
			{
				if ((d1 != p1) && (d1 != p2) && (d1 != p3) && (d2 != p1) && (d2 != p2) && (d2 != p3) && (d3 != p1) && (d3 != p2) && (d3 != p3))
				{
					dsc = score_array[index];
					if (dsc < 1703) // dealer does not qualify
						event_array[1]++;
					else if (psc>dsc)
						event_array[0]++;
					else if (psc < dsc)
						event_array[3]++;
					else
						event_array[2]++;
				}
				index++;
			}
		}
	}

}

void set_array(void)
{
	int p1, p2, p3,sc;
	int index = 0;
	for (p1 = 0; p1 <= 49; p1++)
	{
		for (p2 = p1 + 1; p2 <= 50; p2++)
		{
			for (p3 = p2 + 1; p3 <= 51; p3++)
			{
				sc = score(p1, p2, p3);
				score_array[index] = sc;
				index++;
			}
		}
	}
}

int score(int p1, int p2, int p3)
{
	int flush, straight;
	card hand[3];
	hand[0].r = (int)(p1 / 4);
	hand[1].r = (int)(p2 / 4);
	hand[2].r = (int)(p3 / 4);
	hand[0].s = p1 % 4;
	hand[1].s = p2 % 4;
	hand[2].s = p3 % 4;
	if ((hand[0].s == hand[1].s) && (hand[1].s == hand[2].s))
		flush = 169 * hand[2].r + 13 * hand[1].r + hand[0].r;
	else
		flush = 0;
	if ((hand[2].r - hand[1].r == 1) && (hand[1].r - hand[0].r == 1))
		straight = hand[2].r;
	else if ((hand[2].r == 12) && (hand[1].r == 1) && (hand[0].r == 0))
		straight = 1;
	else
		straight = 0;
	if ((straight > 0) && (flush > 0))
		return 2197 * 5 + straight;
	else if (hand[2].r == hand[0].r)
		return 2197 * 4 + hand[0].r;
	else if (straight > 0)
		return 2197 * 3 + straight;
	else if (flush > 0)
		return 2197 * 2 + flush;
	else if (hand[2].r == hand[1].r)
		return 2197 + 13 * hand[1].r + hand[0].r;
	else if (hand[0].r == hand[1].r)
		return 2197 + 13 * hand[1].r + hand[2].r;
	else
		return 169 * hand[2].r + 13 * hand[1].r + hand[0].r;	
}