int main() { /* initialize suit array */ const char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" }; /* initialize face array */ const char *face[ 13 ] = { "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace" }; const char *names[ 9 ] = { "High card", "Pair", "Two Pair", "Three of a kind", "Straight", "Flush", "Full house", "Four of a kind", "Straight Flush" }; int hand1, hand2; /* initialize deck array */ int deck[ 4 ][ 13 ] = { 0 }; int Hands[10] = { 0 }; int Decks[2][5][2]; srand( time( 0 ) ); /* seed random-number generator */ int Decks2[2][5][2] ={ { {2, 2},{3, 2},{8, 2},{12, 2},{9, 2} }, { {12, 1},{8, 3},{9, 3},{10, 1},{11, 2} } }; shuffle( deck ); deal( deck, face, suit, Decks); printDeal(Decks, face, suit); evaluate_hand(Decks, Hands, names); //getchar(); return 0; /* indicates successful termination */ } /* end main */
// Ex. 8 int main(void) { puts("Enter hand number 1"); card* hand1 = get_hand(); int eval1 = evaluate_hand(hand1); print_hand(hand1); printf("%s\n\n", hand_value[eval1]); puts("Enter hand number 2"); card* hand2 = get_hand(); int eval2 = evaluate_hand(hand2); print_hand(hand2); printf("%s\n\n", hand_value[eval2]); if(eval1 > eval2) puts("Hand number 1 wins"); else if(eval2 > eval1) puts("Hand number 2 wins"); else puts("It's a tie"); free(hand1); free(hand2); return(EXIT_SUCCESS); }
void evaluate_game_immediate(GAME *game, int *vector) { int i; unsigned int hash; #ifdef USE_TRANSPOSITION_TABLE hash = hash_game(game) % TRANSPOSITION_TABLE_SIZE; if (transposition_table[hash][0] != TABLE_UNUSED) { memcpy(vector, transposition_table[hash], sizeof(int)*MAX_PLAYERS); hit_count++; return; } #endif for (i = 0; i < game->num_players; i++) { if (game->players[i].rank != UNRANKED) { vector[i] = (game->num_players-1)*parameters.rank_bonus/2 - game->players[i].rank*parameters.rank_bonus; } else { vector[i] = evaluate_hand(game->players[i].hand); if (i == game->current_player) { vector[i] += parameters.current_player_bonus; } } } /* Normalise the vector somehow. */ //TODO #ifdef USE_TRANSPOSITION_TABLE memcpy(transposition_table[hash], vector, sizeof(int)*MAX_PLAYERS); #endif }