Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Blackjack Bot
- //
- // Created by Michael P on 12/5/18.
- // Copyright © 2018 Michael P. All rights reserved.
- //
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <algorithm> // std::shuffle
- #include <array> // std::array
- #include <random> // std::default_random_engine
- #include <chrono> // std::chrono::system_clock
- #include <vector> // std::vector
- #include <ctime> // std::time
- #include <cstdlib> // std::rand, std::srand
- #include <stdio.h> /* printf, NULL */
- #include <stdlib.h> /* srand, rand */
- #include <time.h> /* time */
- using namespace std;
- #define NUMBEROFDECKS 2
- #define NUMSUITS 4
- #define CARDSPERSUIT 13
- #define CARDSPERDECK NUMSUITS * CARDSPERSUIT
- #define TOTALCARDS CARDSPERDECK * NUMBEROFDECKS
- #define MAXCARDSPERPLAYER 22
- #define MAXPLAYERS 5
- class Card {
- public:
- int suit;
- string SuitName;
- string CardName;
- int pointValue;
- };
- class CardDeck {
- Card cd[NUMBEROFDECKS * CARDSPERDECK];
- public: void CreateCard(){
- string CardNames [CARDSPERSUIT] {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
- string SuitNames [NUMSUITS] {"Spades", "Hearts", "Diamonds", "Clubs"};
- int ci = 0;
- for (int deck = 0; deck < NUMBEROFDECKS; deck++){
- for (int i=0; i < NUMSUITS; i++) {
- for (int j=0; j < CARDSPERSUIT; j++) {
- cd[ci].suit = i;
- cd[ci].CardName = CardNames [j];
- cd[ci].SuitName=SuitNames[i];
- if (j <= 8) {
- cd[ci].pointValue = j+2;
- }
- else if (j < 12) {
- cd[ci].pointValue = 10;
- }
- else
- cd[ci].pointValue = 11;
- ci ++;
- }
- }
- }
- }
- int myrandom (int ci) { return std::rand()%ci;}
- void CardShuffle(){
- std::srand ( unsigned ( std::time(0) ) );
- std::random_shuffle(&cd[0], &cd[TOTALCARDS - 1]);
- for (int ci=0; ci < TOTALCARDS; ci++) {
- cout << cd[ci].CardName << " " << cd[ci].pointValue << " " << cd[ci].SuitName << " " << ci << endl;
- }
- }
- };
- class Player {
- int bet;
- int score;
- int bank;
- public: Card cards [MAXCARDSPERPLAYER];
- };
- Player player [MAXPLAYERS+1];
- void DealCards() {
- int numplayers = 1;
- int gameover = 0;
- int ci = 0;
- //Card hands [MAXPLAYERS+1] [MAXCARDSPERPLAYER];
- while (gameover == 0) {
- for (int round = 0; round < 2; round++) {
- for (int i=0; i < numplayers+1; i++) {
- player[i].cards[round] = cd[ci];
- }
- }
- }
- };
- int main() {
- CardDeck d;
- d.CreateCard();
- d.CardShuffle();
- DealCards();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement