int strategy( const int hd[], const int fd[], int cg, int tk, const int ud[], int us) { int myhd[HNUM]; int select = -1; int hdcopy[CNUM]; int udcopy[us]; int currentpoint = 0; int deck[CNUM] = { 0 }; int decknum = CNUM; int k; int lastchangehd = 0; // 最初から高い点なら手札を変えずに終了 arr_copy( hdcopy, hd, HNUM); currentpoint = poker_point(hdcopy); if ( currentpoint >= P6 ) { return -1; } arr_copy( udcopy, ud, us ); decknum = make_deck( hdcopy, udcopy, us, deck ); if ( tk == 4 && decknum <= 7 - cg ) { //LAST_RECURSION_LIMIT = decknum; select = select_card_last( hdcopy, cg, tk, udcopy, us, deck, decknum ); } else { select = select_card( hdcopy, cg, tk, udcopy, us, deck, decknum ); } return select; }
int main() { make_deck(); read_card_s_names_deck(); return 0; }
int main(int argc, char *argv[]) { // exit the program if the user didn't give an input arg for num cards if (argc != 2) { printf("Enter 1 argument to initialize the number of cards in deck\n"); exit(1); } char *num = argv[1]; int num_cards = atoi(num); // make new deck and print it deck_t* handdeck = make_deck(num_cards); // initialize empty table deck deck_t *tabledeck = (deck_t *)malloc(sizeof(deck_t)); tabledeck->num_cards = num_cards; tabledeck->top = NULL; tabledeck->bottom = NULL; // play the game int num_rounds = 0; while (1) { play_round(handdeck, tabledeck); // hand deck will get table deck as hand deck should be null after // a round has been played handdeck->top = tabledeck->top; handdeck->bottom = tabledeck->bottom; // table deck is an empty deck again tabledeck->top = NULL; tabledeck->bottom = NULL; ++num_rounds; if (is_equal(handdeck)) { break; } } printf("Final card stack = "); print(handdeck); printf("Number of rounds played = %d\n", num_rounds); // free all the space in the heap used by the program free(handdeck); free(tabledeck); return 1; }
int main(int argc, char *argv[]) { double dealt; char* endptr1; if(argc == 2) { dealt = strtod(argv[1], &endptr1); } else if(argc == 1) { dealt = 5; } printf("Welcome to the Poker Table\n"); struct deck *deck = make_deck(); shuffle_deck(deck); if(!deck) { fprintf(stderr, "Could not create deck"); return 1; } if(dealt > 52 || dealt < 0) { printf("%.2f was not a correct number of cards.\n", dealt); dealt = 5; printf("You were dealt %.2f cards.\n", dealt); print_card_new(deck, dealt); //print_card_abbrev(deck); } else if(dealt <= 52) { print_card_new(deck, dealt); //passes the variable 'deck' because it expects a pointer to a deck structure //print_card_abbrev(deck); } free_deck(deck); }