Análise do Three Card Poker
Aqui está o código criado no vídeo.
#incluir#incluir #incluir #incluir #incluir h>#incluir usando o 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]; baralho de cartas[52]; vazio principal() { 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[] = { "Três singletons","Par","Flush","Sequência","Trinca","Sequência de flush" }; string event_name[] = { "Jogador vence","O dealer não se qualifica","Empate","O dealer vence","Jogador desiste" }; int índice = 0; duplo ev = 0; para (i = 0; i < 6; i++) { tot_ante_bonus[i] = 0; pairplus_array[i] = 0; tot_event_array[i] = 0; } para (i = 0; i < 51; i++) { deck[i].r = (int)(i / 4); deck[i].s = i % 4; } definir_array(); para (p1 = 0; p1 <= 49; p1++) { para (p2 = p1 + 1; p2 <= 50; p2++) { para (p3 = p2 + 1; p3 <= 51; p3++) { sc = matriz_de_pontuação[índice]; gato = (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]; se (ev < -1) // dobrar { tot_event_array[4] += 18424; } outro { para (i = 0; i <= 3; i++) tot_event_array[i] += event_array[i]; tot_ante_bonus[cat]++; } índice++; } } } printf("Análise Pairplus\n"); para (i = 0; i < 6; i++) printf("%s\t%i\n", hand_name[i].c_str(), pairplus_array[i]); printf("\nAnálise Ante\n"); para (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("Valor esperado do jogo sem bônus de aposta = %f\n",game_ev ); para (i = 0; i <= 5; i++) game_ev += ante_bonus_pay[i] * tot_ante_bonus[i] / 22100.0; printf("Valor esperado do jogo com bônus Ante=\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 índice = 0; para (i = 0; i <= 3; i++) event_array[i] = 0; para (d1 = 0; d1 <= 49; d1++) { para (d2 = d1 + 1; d2 <= 50; d2++) { para (d3 = d2 + 1; d3 <= 51; d3++) { se ((d1! = p1) && (d1! = p2) && (d1! = p3) && (d2! = p1) && (d2! = p2) && (d2! = p3) && (d3! = p1) && (d3! = p2) && (d3! = p3)) { dsc = matriz_de_pontuação[índice]; se (dsc < 1703) // o revendedor não se qualifica evento_array[1]++; senão se (psc>dsc) evento_array[0]++; senão se (psc < dsc) event_array[3]++; outro event_array[2]++; } índice++; } } } } void set_array(void) { int p1, p2, p3,sc; int índice = 0; para (p1 = 0; p1 <= 49; p1++) { para (p2 = p1 + 1; p2 <= 50; p2++) { para (p3 = p2 + 1; p3 <= 51; p3++) { sc = pontuação(p1, p2, p3); matriz_pontuação[índice] = sc; índice++; } } } } int score(int p1, int p2, int p3) { int nivelado, reto; mão de cartas[3]; mão[0].r = (int)(p1 / 4); mão[1].r = (int)(p2 / 4); mão[2].r = (int)(p3 / 4); mão[0].s = p1 % 4; mão[1].s = p2 % 4; mão[2].s = p3 % 4; se ((mão[0].s == mão[1].s) && (mão[1].s == mão[2].s)) flush = 169 * hand[2].r + 13 * hand[1].r + hand[0].r; outro flush = 0; se ((mão[2].r - mão[1].r == 1) && (mão[1].r - mão[0].r == 1)) reto = mão[2].r; senão se ((mão[2].r == 12) && (mão[1].r == 1) && (mão[0].r == 0)) reto = 1; outro reto = 0; se ((straight > 0) && (flush > 0)) retornar 2197 * 5 + direto; senão se (mão[2].r == mão[0].r) retornar 2197 * 4 + mão[0].r; senão se (reto > 0) retornar 2197 * 3 + direto; senão se (flush > 0) retornar 2197 * 2 + flush; senão se (mão[2].r == mão[1].r) retornar 2197 + 13 * mão[1].r + mão[0].r; senão se (mão[0].r == mão[1].r) retornar 2197 + 13 * mão[1].r + mão[2].r; outro retornar 169 * mão[2].r + 13 * mão[1].r + mão[0].r; }