Exemplo n.º 1
0
int main()
{
    //set up a timer and seed the random and create the decks and hands
    Timer clock;
    srand(time(NULL));
    vector<int> deck(52*deckCount);
    vector<int> copy(52*deckCount);
    Dhand dealer;
    Phand player;
    
    //initialize the decks by loading in 
    initDeck(deck);
    initDeck(copy);   
    
    char temp;
    
    while(true)
    {
        cout << "What would you like to do? ((s)how, (p)lay), (l)earn: ";
        cin >> temp;
        switch(temp)
        {
            //this section is for if a human player wishes to play a single game, but havent gotten a chance to implement the play function yet, so play currently does not do much.
            /*case 'p':
                initDeck(deck);
                shuffle(deck);
                    
                deal(dealer, player, deck);
                
                board(dealer, player);
                play(dealer, player, deck, false);
                
                cout <<  endl << "========================" << endl << "      NEW GAME" << endl << "========================" << endl;
                break; */
            case 'l':
                /*runs a timer to see how quickly Runs amount takes for debugging issues.
                  this section first copies the original deck to a temp copy and shuffles it
                  as reinitializing the deck every time was too slow. It then loops through run times
                  in order to simulate that many games played. */
                wins = 0;
                clock.start();
                for(long long int x=0; x<RUNS; x++)
                {
                    copy = deck;
                    shuffle(copy);
                    
                    deal(dealer, player, copy);
                    if(learn(dealer, player, copy, false))
                    {
                        wins++;
                    }
                }
                clock.stop();
                cout << clock.getElapsedTime() << endl;
                cout << "won: " << (wins/RUNS)*100 << "%" << endl;
                break;
            case 's':
                info.show();
                break;
        }
    }
    
    return 0;
}