Пример #1
0
int main(){
    struct player *players;
    struct card *deck;
    //struct player computer;
    int numPlayers;
    int i;


    deck = createDeck();
    shuffleDeck(deck);
    printf("__WELCOME_TO_HENRY'S_BLACK_JACK_GAME__\n");     
    printf("How many players? (MAX 5)\n");
    scanf("%d", &numPlayers);
     while(numPlayers < 1 || numPlayers > 5){
       printf("Minimum 1, Maximum 5\n");
       scanf("%d", &numPlayers);
     }
    players = makePlayers(numPlayers);
    printf("number of players %d\n", numPlayers);
    printf("_________LETS_PLAY_BLACK_JACK!________\n");
    for(i=0;i<numPlayers;i++){
      players[i].playersCards = NULL;
      players[i].amountCard = 2; //varför fungerar du inte?=
      printf("player: %s\n", players[i].name);
      dealCards(players[i].playersCards,deck,players[i].amountCard);
    }

    free(deck);
    free(players);
    return 0;
}
Пример #2
0
int evalAllHands (int *results) {
	cardType deck[NUM_CARDS];
	handType hand;
	createDeck (deck);
	
	return evalAllHandsHelper (deck, &hand, results, 0, 0);
}
Пример #3
0
void ChicaneCardGame::readConfig( Config& cfg )
{
    cfg.setGroup("GameState");

    // Create Cards, but don't shuffle or deal them yet
    createDeck();

    // Move the cards to their piles (deal them to their previous places)
    beginDealing();

    highestZ = 1;

    for (int i = 0; i < 8; i++) {
        QString pile;
        pile.sprintf( "ChicaneDiscardPile%i", i );
        readPile( cfg, discardPiles[i], pile, highestZ );
    }

    for (int i = 0; i < 8; i++) {
        QString pile;
        pile.sprintf( "ChicaneWorkingPile%i", i );
        readPile( cfg, workingPiles[i], pile, highestZ );
    }

    readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ );

    highestZ++;

    endDealing();
}
Пример #4
0
int main(int argc, const char * argv[]) {
    // insert code here...
    
    char *trump = "false";
	deck *Standard, *shuffled, *reshuffled;
	card *popper;
    
    printf("Hello, World!\n");
    printf("welcome to BLACK JIGGITY JACK, JACK!\n\n\n");
    
	Standard = createDeck();
    printDeck(Standard);
    
    setTrumpSuit(suitArr[3]);
    
    if (isTrump(Standard->cards[1]->suit)) {trump = "true";}
    
    
    printf("\nHearts are trump:  %s\n", trump);
    
    if (isTrump(Standard->cards[51]->suit)) {trump = "true";}
    else trump = "false";
    printf("Clubs are trump:  %s\n", trump);
    
    desetTrumpSuit(suitArr[3]);
    
    printf("\ndesetting trump suit\n");
    
    if (isTrump(Standard->cards[51]->suit)) {trump = "true";}
    else trump = "false";
    printf("Clubs are trump:  %s\n", trump);
    
    printf("\nFirst Ace is: %s\tvalue: %d\nSecond Ace is: %s\tvalue: %d\n",
           Standard->cards[12]->name, Standard->cards[12]->value->weight,
           Standard->cards[25]->name, Standard->cards[25]->value->weight);
    setLoAce(Standard->cards[12]);
    printf("Changing first ace to lo.\n");
    printf("\nFirst Ace is: %s\tvalue: %d\nSecond Ace is: %s\tvalue: %d\n",
           Standard->cards[12]->name, Standard->cards[12]->value->weight,
           Standard->cards[25]->name, Standard->cards[25]->value->weight);
    setLoAce(Standard->cards[12]);
    printf("Is first ace hi? %d\tIs second ace hi? %d\n", isHiAce(Standard->cards[12]), isHiAce(Standard->cards[25]));
    isHiAce(Standard->cards[25]);
    
    setHiAce(Standard->cards[12]);
    printf("Is first ace hi? %d\tIs second ace hi? %d\n", isHiAce(Standard->cards[12]), isHiAce(Standard->cards[25]));

    shuffled = shuffle(Standard);
    reshuffled = shuffle(shuffled);
    printDeck(reshuffled);
    
    popper = _popCard(reshuffled);
    printf("first card from the top: \n\t%s\n", popper->name);
    popper = _popCard(reshuffled);
    printf("second card from the top: \n\t%s\n", popper->name);
    _deleteDeck(reshuffled);
    
    return 0;
}
Пример #5
0
int main() {
    Card * deck = createDeck();
    //    printCard(deck[0]);
    //    printCard(deck[1]);
    for(int c=0;c<NUM_CARDS;c++) {
        printCard(deck[c]);
    }
    free(deck);
    return 0;
}
Пример #6
0
/* Usage: deck hand_size number_of_hands */
int main(int argc, char *argv[]) {

    /* input */
    int nhands;                   /* stores number of hands from input */
    int handSize;                 /* stores hand size from input */
    int canDisplayHands;          /* flag to indicate if the hands can be displayed */

    int foundErrors = NO_ERRORS;  /* indicate whether errors are found */

    /* validate input */
    if (validInput(argc, argv, &handSize, &nhands)) {

        Card deck[DECK_SIZE];     /* the cards deck */
        Hand hands[nhands];       /* the hands */
        Hand sortedHands[nhands];

        canDisplayHands = (handSize && nhands) > 0 ? TRUE : FALSE;

        /* create a deck of cards. */
        printf("\n   Create and display the deck.\n\n");
        createDeck(deck);
        displayDeck(deck, DECK_SIZE);

        /* shuffle deck of cards */
        printf("\n   Shuffle and display the deck.\n\n");
        shuffleDeck(deck, DECK_SIZE);
        displayDeck(deck, DECK_SIZE);

        if (canDisplayHands) {
            /* create and display hands */
            printf("\n   Create and display hands.\n\n");
            createHands(deck, hands, handSize, nhands);
            sortHands(hands, sortedHands, handSize, nhands);

            displayHands(hands, sortedHands, handSize, nhands);

            /* rank hands */
            printf("\n   Rank and display ranked hands.\n\n");
            displayRankedHands(sortedHands, nhands);

            printf("\n   Display winners.\n\n");
            displayWinners(sortedHands, nhands);
        }
        else {
            printf("\nCould not display hands because either the hand size or the number of hands is zero.\n");
        }
    }
    else {
        /* invalid input */
        printf("Usage: deck hand_size number_of_hands\n");
        foundErrors = ERRORS;
    }
    return foundErrors;
}
Пример #7
0
/**
* Initialises the solver
*/
int main()
{
	createDeck();

	while(1)
	{
		menu();
	}

	return 0;
}
Пример #8
0
void simGame (FILE *f, int numPlayers, int numGames) {
	cardType deck[NUM_CARDS];
	handType players[numPlayers];
	createDeck(deck);
	
	int winners[numPlayers]; 
	int numWinners; 
	char *type[] = {"Bust", "Pair", "Two Pair", "Three of a Kind", "Straight", "Flush", "Full House", "Four of a Kind", "Straight Flush", "Royal Flush"};
	char suitSym [] = {'H', 'D', 'S', 'C'};
	
	for (int i = 0; i < numGames; i++) {
		shuffleDeck (deck);
		numWinners = 0;
		
		fprintf (f, "GAME %i", i + 1);
		
		for (int j = 0; j < numPlayers; j++) {
			
			fprintf (f, "\nPlayer %i's hand: ", j + 1);	
			
			for (int k = 0; k < HAND_SIZE; k++) {
				players[j].cards[k] = deck[j * HAND_SIZE + k];
				
				fprintf (f, "%i%c ", players[j].cards[k].rank + 1, suitSym[players[j].cards[k].suit]);
			}
			checkHand (&players[j]);		
			fprintf (f, "(%s)", type[players[j].type]);
			
			
			if (j == 0) {
				winners[0] = j;
				numWinners = 1;
			}			
			else if (players[j].type > players[winners[numWinners - 1]].type || 
			(players[j].type == players[winners[numWinners - 1]].type &&  players[j].value > players [winners[numWinners - 1]].value)) {
				winners[0] = j;		
				numWinners = 1;				
			}
			else if (players[j].type == players [winners[numWinners - 1]].type && players[j].value == players [winners[numWinners - 1]].value) {
				winners [numWinners++] = j;
			}
						
		}
		
		fprintf (f, "\nThe %s ", (numWinners == 1)? "winner is" : "winners are");
		for (int j = 0; j < numWinners; j++) {
			fprintf (f, "%splayer %i", j == 0? "" : " and ",  winners[j] + 1);
		}
		fprintf (f, "!\n\n");	
		
	}
}
Пример #9
0
DeckOfCards::DeckOfCards(void){
	suit[0]="spades";
	suit[1]="clubs";
	suit[2]="hearts";
	suit[3]="diamonds";

	short handValue = 0;

	int pointerToDeck = 0;

	//inits card 0-51 with values 1-13
	createDeck();
	shuffleDeck();
}
Пример #10
0
int main(void)
{   srand(time(NULL));
    char prog;
    int seed, end=0;

        //Prompts the user to seed the program.
        printf("Enter seed value, either:\n\t>= 0 to randomize rand( ) with u");
        printf("ser-input seed value\n\t<  0 to randomize rand( ) with system");
        printf(" time\n");

        scanf("%i", &seed);

        if(seed>=0)
            srand(seed);

        if(seed<0)
            srand(time(NULL));

        do
        {   ct1=ct2=ct3=ct4=ct5=0;

            printf("Do you want to use the assigned function, play poker or end program(A/P/E)?");
            prog=getchar();
            prog=getchar();

            printf("\n");

            if (prog=='A' || prog=='a')
            {   for(ct1=0; ct1<52; ct1++)
                    createDeck();

                assigned();
            }

            else if(prog=='p' || prog=='P')
            {   poker();
            }
            else if(prog=='e' || prog=='E')
            {
                for(ct2=0; ct2<100000; ct2++)  //Smilies!
                    printf("%2c", 1);
                end++;
            }
            //Prints after invalid inputs.
            else
                printf("Would you like to try that again.....\n\n");

        }while(end==0);
        return 0;
}   // end main
Пример #11
0
/* deal function which accepts the 2 arguments passed by the command-line, 
 already converted to int, create a new deck, shuffle the deck, print the deck, then deal and display the cards that each player has. */
void deal(int numberOfCards, int numberOfPlayers)
{
    
    
    int forPlayer, forCard, currentCard = 0;
    
    printf("\n\nReady to deal %d card(s) to %d player(s)...\n\n", numberOfCards, numberOfPlayers);

    struct deck cardDeck, *point = &cardDeck;
    cardDeck = createDeck(); /* Create the cardDeck with all cards */
    
    shuffle(point);
    printDeck(point);
    
    struct card players[numberOfPlayers];
    struct card *playersPoint;
    
    playersPoint = players;
    
    printf("\n");
    
    for(forPlayer = 0; forPlayer < numberOfPlayers; ++forPlayer)
    {
        if (numberOfCards > 1) /* If numberOfCards is greater than 1 then we must
                                display all of the cards the players have */
        {
            for (forCard = 0; forCard < numberOfCards; ++forCard)
            {
                playersPoint[forCard] = cardDeck.deckOfCards[currentCard];
                
                currentCard++;
            }
        } else { /* Otherwise, the number of cards is 1. */
            
            playersPoint[forPlayer] = cardDeck.deckOfCards[currentCard];
            
            currentCard++;
        }
    }
    
    printf("\n");
    
    printHands(numberOfCards, numberOfPlayers, point);
    
}
Пример #12
0
void Spider::setSuits(int suits)
{
    if ( suits != m_suits )
    {
        m_suits = suits;

        stopDemo();
        clearHighlightedItems();
        setKeyboardModeActive( false );

        int cardWidth = deck()->cardWidth();
        createDeck();
        deck()->setCardWidth( cardWidth );

        Settings::setSpiderSuitCount( m_suits );

        if ( m_suits == 1 )
            options->setCurrentItem( 0 );
        else if ( m_suits == 2 )
            options->setCurrentItem( 1 );
        else
            options->setCurrentItem( 2 );
    }
}
Пример #13
0
void poker(void)
{   char again;
    int numShuf;

    do
    {   ct1=ct2=ct3=ct4=ct5=0;

        for(ct1=0; ct1<52; ct1++)
            createDeck();

        printf("A randomized deck has been created:\n");
        displayOrder();

        printf("\n\nHow many times would you like to shuffle: ");
        scanf("%i", &numShuf);

        //Shuffles bridges and displays the order for the number of times specified.
        for(ct5=0; ct5<numShuf; ct5++)
        {   if(ct5==numShuf-1)  //Prints above the final order to declare the final card order.
            printf("\n\nThe final order is:\n");
            shuffle();
            bridge();
            displayOrder();
        }

        deal();

        //This program cannot determine a winner.
        printf("You figure out who won\n\nDo you want to play again (Y/N)? ");
        getchar();  //This getchar receives the new line character left by
        again=getchar();           //previous scanf.

    }while(again=='y');

    printf("\n");
}
Пример #14
0
int main(int argc, const char * argv[]) {
    
    /* local variables used here */
    
    int max, numCardsPerHand, numOfPlayers, i, j, cardsPtr = 0, *ptr = &cardsPtr;
    struct deck thedeck, *pointer = &thedeck;
    thedeck = createDeck();
    struct player thePlayers[MAX_NUM_PLAYERS];
    time_t t;
    
    srand((unsigned)time(&t));               // generate seed for random value
    
    /* validation of user input. No more than 3 args. */
    if( argc == ARGNUM ){
        
        /* parse the arguments to integer values
         and compute maximum legal values allowed
         for game */
        
        numCardsPerHand = atoi(argv[CARD_INPUT]);
        numOfPlayers = atoi(argv[PLAYER_INPUT]);
        
       if(validateInput(numCardsPerHand, numOfPlayers)) /* If the validateInput function returns
                                                        a 1 then the inputs were correct and the 
                                                        game of cards can begin */
        {
            /* create and display deck, shuffle the deck,
             deal and display hands */
            
            thedeck = createDeck();
            printf("\nThe standard deck:\n\n");
            printDeck(pointer);
            printf("\nThe shuffled deck:\n\n");
            shuffle(pointer);
            printDeck(pointer);
            //deal(pointer, numCardsPerHand, numOfPlayers);
            //sortHands(pointer, numCardsPerHand, numOfPlayers);
	    //rankHands(gamer, numCardsPerHand, numOfPlayers);
	    
	    for (i = 0; i < numOfPlayers; i++) {
                thePlayers[i] = deal2(numCardsPerHand, pointer);
            }
            
            displayHands2(thePlayers, numCardsPerHand, numOfPlayers, numCardsPerHand);
            
            //deal(pointer, numCardsPerHand, numOfPlayers);
            //sortHands(pointer, numCardsPerHand, numOfPlayers);
            sortHands2(thePlayers, numCardsPerHand, numOfPlayers);
            displayHands2(thePlayers, numCardsPerHand, numOfPlayers, numCardsPerHand);
            printDeck(pointer);
	    //hasHighCard(pointer, numCardsPerHand, numOfPlayers);
            findHighCard(thePlayers, numOfPlayers, numCardsPerHand);
            
        }
    }else{
        /* here as specified, display error and terminate due to incorrect number of args entered by user */
        
        printf("Sorry that is incorrect. You must enter the number of cards per hand\n");
        printf("followed by the number of players separated by a space.\n\n");
    }
    
    return 0;
}
Пример #15
0
int main(void){
  printf("WELCOME TO HENRYS BLACKJACK\n");
  //player1
  struct player player1;
  printf("Type name for player1: ");
  scanf("%s",player1.name);
  getchar();
  player1.playerHand = NULL;
  player1.cardValue = 0;
  player1.startCards = 2;
  printf("utan ptr: %d\n", player1.startCards);
  //player2
  struct player player2;
  printf("Type name for player2: ");
  scanf("%s",player2.name);
  getchar();
  player2.playerHand = NULL;
  player2.cardValue = 0;
  player2.startCards = 2;
  //computer
  struct player comp;
  strcpy(comp.name, "the dealer");
  comp.playerHand = NULL;
  comp.cardValue = 0;
  comp.startCards = 1;

  int cardCounter = 0;
  struct card *deck = NULL;
  deck = createDeck(deck);    // deck created
  int i;
  for(i=0; i<20; i++)
    shuffleDeck(deck);   // deck shuffled

  /* Name giving and first cards dealing  */
  printf("\n\nHand of %s:\n", player1.name);
  dealCards(&player1, deck, &cardCounter);
  printCards(player1.playerHand, player1.startCards);
  printf("\n\nHand of %s: \n", player2.name);
  dealCards(&player2, deck, &cardCounter);
  printCards(player2.playerHand, player2.startCards);

  printf("\n\nHand of %s: \n", comp.name);
  dealCards(&comp, deck, &cardCounter);
  printCards(comp.playerHand, comp.startCards);


  /* Hit or stay face  */
 printf("------------------------------------------------------\n");
 player1.cardValue = actDealer(player1,deck, &cardCounter,22);
 printf("------------------------------------------------------\n");
 player2.cardValue = actDealer(player2,deck, &cardCounter,22);
 printf("------------------------------------------------------\n");
    if(player1.cardValue  == -1 && player2.cardValue == -1){  // if both loses dealer does not have to continue
        printf("Both players lost!\n");
        printf("--------------------Game-finished---------------------\n");
        goto masteJagKompletteraNufragetecken;
    }
 comp.cardValue = actDealer(comp,deck,&cardCounter,17);
 printf("------------------------------------------------------\n");
 whoWon(player1, player2, comp);
 printf("--------------------Game-finished---------------------\n");

masteJagKompletteraNufragetecken:
/* Freeing memory */
free(deck);
free(player1.playerHand);
free(player2.playerHand);
free(comp.playerHand);
return 0;
}
Пример #16
0
/**
 * 
 * @param argc
 * @param argv
 * @return 
 */
int main(int argc, char** argv) {
    
    //Command line input
    int players;
    int cards;
    
    cards = atoi(argv[1]);
    players = atoi(argv[2]);
    
    cards = 5; //Force cards to 5
//    players = 5;

    //Validate
    if (players < MINPLAYERS || players > MAXPLAYERS) {
        printf("Players too high or too low!!!\n");
        return 0;
    }
    if (cards < MINCARDS || cards > MAXCARDS) {
        printf("Cards too high or too low!!!\n");
        return 0;
    }
        
    //Create
    struct card deck[NUMCARDS]; //Create the deck
    createDeck(deck); //Fill the deck
    
    //Display
    printf("Unshuffled deck(suit, val):\n");
    //printDeck(deck);
    printDeckColumned(deck);
    printf("\n");
    
    //Shuffle
    shuffleDeck(deck);
    
    //Display
    printf("Shuffled deck(suit, val):\n");
    //printDeck(deck);
    printDeckColumned(deck);
    printf("\n");
    
    //Deal
    printf("Dealing.\n\n");
    struct hand * hands = dealDeck(players, cards, deck);
    
    //Show Hands
    printf("Player's hands(unsorted):\n");
    printHandsNamed(players, cards, hands);
    printf("\n");
    
    //Sort Hands
    sortHands(players, cards, hands);
    
    //Show Hands
    printf("Player's hands(sorted):\n");
    printHandsNamed(players, cards, hands);
    printf("\n");
    
//    //Fixed cards for testing (suit, value)
//    struct card card1 = makeCard(4,3);
//    struct card card2 = makeCard(4,4);
//    struct card card3 = makeCard(4,5);
//    struct card card4 = makeCard(4,6);
//    struct card card5 = makeCard(4,7);
//    
//    //Fixed hand for testing
//    struct hand fixedHand;
//    fixedHand.cards[0] = card1;
//    fixedHand.cards[1] = card2;
//    fixedHand.cards[2] = card3;
//    fixedHand.cards[3] = card4;
//    fixedHand.cards[4] = card5;
//    
//    printHandsNamed(1,5,&fixedHand);
//    rankHand(&fixedHand);
//    printHandsNamed(1,5,&fixedHand);
//    printf("%i",fixedHand.rank);
    
    //Rank hands
    rankHands(players, hands);
    
    //Show hands with ranks
    printf("Players hands' ranks:\n");
    printHandsRanked(players, hands);
    
    //Determine winner
    determineWinner(players, hands);
    
    return (0);
}
Пример #17
0
void Spider::initialize()
{
    m_leg = 0;
    m_redeal = 0;

    const qreal dist_x = 1.12;
    const qreal smallNeg = -1e-6;

    m_suits = Settings::spiderSuitCount();

    m_stackFaceup = Settings::spiderStackFaceup();

    createDeck();

    // Dealing the cards out into 5 piles so the user can see how many
    // sets of 10 cards are left to be dealt out
    for( int column = 0; column < 5; ++column )
    {
        redeals[column] = new InvisiblePile( this, column + 1, QStringLiteral( "redeals%1" ).arg( column ) );
        redeals[column]->setPileRole(PatPile::Stock);
        redeals[column]->setLayoutPos( dist_x * (9 - (4.0 - column) / 3), smallNeg );
        redeals[column]->setZValue(12 * ( 5-column ));
        redeals[column]->setSpread(0, 0);
        redeals[column]->setKeyboardSelectHint( KCardPile::NeverFocus );
        redeals[column]->setKeyboardDropHint( KCardPile::NeverFocus );
        connect( redeals[column], &KCardPile::clicked, this, &DealerScene::drawDealRowOrRedeal );
    }

    // The 10 playing piles
    for( int column = 0; column < 10; ++column )
    {
        stack[column] = new PatPile( this, column + 6, QStringLiteral( "stack%1" ).arg( column ) );
        stack[column]->setPileRole(PatPile::Tableau);
        stack[column]->setLayoutPos(dist_x * column, 0);
        stack[column]->setZValue(20);
        stack[column]->setAutoTurnTop(true);
        stack[column]->setBottomPadding( 1.5 );
        stack[column]->setHeightPolicy( KCardPile::GrowDown );
        stack[column]->setKeyboardSelectHint( KCardPile::AutoFocusDeepestRemovable );
        stack[column]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    // The 8 'legs' so named by me because spiders have 8 legs - why
    // else the name Spider?
    for( int column = 0; column < 8; ++column )
    {
        legs[column] = new InvisiblePile( this, column + 16, QStringLiteral( "legs%1" ).arg( column ) );
        legs[column]->setPileRole(PatPile::Foundation);
        legs[column]->setLayoutPos(dist_x / 3 * column, smallNeg);
        legs[column]->setZValue(column+1);
        legs[column]->setSpread(0, 0);
        legs[column]->setZValue(14 * column);
        legs[column]->setVisible( false );
        legs[column]->setKeyboardSelectHint( KCardPile::NeverFocus );
        legs[column]->setKeyboardDropHint( KCardPile::NeverFocus );
    }

    // Moving an A-K run to a leg is not really an autoDrop - the
    // user should have no choice.
    setAutoDropEnabled(false);
    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
    setSolver( new SpiderSolver( this ) );

    options = new KSelectAction(i18n("Spider &Options"), this );
    options->addAction( i18n("1 Suit (Easy)") );
    options->addAction( i18n("2 Suits (Medium)") );
    options->addAction( i18n("4 Suits (Hard)") );
    if ( m_suits == 1 )
        options->setCurrentItem( 0 );
    else if ( m_suits == 2 )
        options->setCurrentItem( 1 );
    else
        options->setCurrentItem( 2 );
    connect(options, static_cast<void (KSelectAction::*)(int)>(&KSelectAction::triggered), this, &Spider::gameTypeChanged);

    m_stackFaceupOption = new KSelectAction(i18n("S&tack Options"), this );
    m_stackFaceupOption->addAction( i18n("Face &Down (harder)") );
    m_stackFaceupOption->addAction( i18n("Face &Up (easier)") );
    m_stackFaceupOption->setCurrentItem( m_stackFaceup );

    connect(m_stackFaceupOption, static_cast<void (KSelectAction::*)(int)>(&KSelectAction::triggered), this, &Spider::gameTypeChanged);
}
Пример #18
0
Deck::Deck( QObject* parent ) :
    QObject( parent )
{
    createDeck();
    shuffleDeck();
}
int main()//int argc, char **argv)
{
	cardType *topDeck = NULL, *bottomDeck = NULL, *topTable = NULL;
	cardType *nextBottom = NULL; // the topDeck
	unsigned int rounds = 0;
	BOOL done = FALSE;
	unsigned short deckSize = 0;
	unsigned short *key;
	unsigned short *copy;

	/*if (argc != 2)
		return 0;

	sscanf_s(argv[1], "%d", &deckSize);*/

	scanf("%d", &deckSize);

	key = (unsigned short*) malloc(sizeof(unsigned short) * deckSize);
	copy = (unsigned short*) malloc(sizeof(unsigned short) * deckSize);
	
	createDeck(&topDeck, &bottomDeck, deckSize);
	nextBottom = topDeck; // we know our current top will be the bottom of our next deck
	
	// keep removing and shifting until deck is empty
	do
	{
		removeTop(&topDeck, &topTable);
		
		if (topDeck)
		{
			if (topDeck != bottomDeck) // cannot shift if already bottom
				shiftDeck(&topDeck, &bottomDeck);
		}
		else
		{
			rounds++; // all cards on table
			topDeck = topTable; // table deck becomes our new deck
			topTable = NULL;

			bottomDeck = nextBottom;
			nextBottom = topDeck;

			done = TRUE;
		}
	} while (!done);

    // We only needed to analyze how cards moved around once to create a key
 	// of indexes which lets us get the next position of a card in O(1).
	makeKey(topDeck, key, copy, deckSize);

	// Next we keep adjusting the deck following the key until cards are back in place.
	while (!checkDeck(topDeck, rounds))
	{
		adjustDeck(topDeck, key, copy, deckSize);
		rounds++;
	}

	// find the lcm of all the r's
	rounds = lcmLoop(topDeck);

	destroyDeck(&topDeck);

	free(copy);
	free(key);
	
	printf("rounds for %d numbers = %d\n", deckSize, rounds);

	return 0;
}