Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // Blackjack Bot
  4. //
  5. // Created by Michael P on 12/5/18.
  6. // Copyright © 2018 Michael P. All rights reserved.
  7. //
  8.  
  9.  
  10. #include <iostream>
  11. #include <fstream>
  12. #include <cstdlib>
  13. #include <algorithm> // std::shuffle
  14. #include <array> // std::array
  15. #include <random> // std::default_random_engine
  16. #include <chrono> // std::chrono::system_clock
  17. #include <vector> // std::vector
  18. #include <ctime> // std::time
  19. #include <cstdlib> // std::rand, std::srand
  20. #include <stdio.h> /* printf, NULL */
  21. #include <stdlib.h> /* srand, rand */
  22. #include <time.h> /* time */
  23.  
  24. using namespace std;
  25.  
  26. #define NUMBEROFDECKS 2
  27. #define NUMSUITS 4
  28. #define CARDSPERSUIT 13
  29. #define CARDSPERDECK NUMSUITS * CARDSPERSUIT
  30. #define TOTALCARDS CARDSPERDECK * NUMBEROFDECKS
  31. #define MAXCARDSPERPLAYER 22
  32. #define MAXPLAYERS 5
  33.  
  34. class Card {
  35. public:
  36. int suit;
  37. string SuitName;
  38. string CardName;
  39. int pointValue;
  40. };
  41.  
  42. class CardDeck {
  43. Card cd[NUMBEROFDECKS * CARDSPERDECK];
  44.  
  45. public: void CreateCard(){
  46. string CardNames [CARDSPERSUIT] {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
  47. string SuitNames [NUMSUITS] {"Spades", "Hearts", "Diamonds", "Clubs"};
  48. int ci = 0;
  49. for (int deck = 0; deck < NUMBEROFDECKS; deck++){
  50.  
  51. for (int i=0; i < NUMSUITS; i++) {
  52.  
  53. for (int j=0; j < CARDSPERSUIT; j++) {
  54. cd[ci].suit = i;
  55. cd[ci].CardName = CardNames [j];
  56. cd[ci].SuitName=SuitNames[i];
  57. if (j <= 8) {
  58. cd[ci].pointValue = j+2;
  59. }
  60. else if (j < 12) {
  61. cd[ci].pointValue = 10;
  62. }
  63. else
  64. cd[ci].pointValue = 11;
  65.  
  66. ci ++;
  67.  
  68. }
  69. }
  70. }
  71. }
  72.  
  73. int myrandom (int ci) { return std::rand()%ci;}
  74. void CardShuffle(){
  75.  
  76. std::srand ( unsigned ( std::time(0) ) );
  77. std::random_shuffle(&cd[0], &cd[TOTALCARDS - 1]);
  78. for (int ci=0; ci < TOTALCARDS; ci++) {
  79. cout << cd[ci].CardName << " " << cd[ci].pointValue << " " << cd[ci].SuitName << " " << ci << endl;
  80.  
  81. }
  82. }
  83. };
  84.  
  85. class Player {
  86. int bet;
  87. int score;
  88. int bank;
  89. public: Card cards [MAXCARDSPERPLAYER];
  90. };
  91. Player player [MAXPLAYERS+1];
  92. void DealCards() {
  93. int numplayers = 1;
  94. int gameover = 0;
  95. int ci = 0;
  96.  
  97.  
  98. //Card hands [MAXPLAYERS+1] [MAXCARDSPERPLAYER];
  99. while (gameover == 0) {
  100. for (int round = 0; round < 2; round++) {
  101.  
  102.  
  103. for (int i=0; i < numplayers+1; i++) {
  104. player[i].cards[round] = cd[ci];
  105. }
  106. }
  107. }
  108.  
  109.  
  110. };
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. int main() {
  118.  
  119.  
  120. CardDeck d;
  121. d.CreateCard();
  122. d.CardShuffle();
  123. DealCards();
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement