Guest User

Untitled

a guest
Apr 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <iterator>
  5. #include <vector>
  6. #include <algorithm>
  7. //#include <cstdlib>
  8. #include <ctime>
  9. using namespace std;
  10.  
  11. class Domino {
  12. public:
  13. vector<string> shuffle(vector<string> a, vector<string> b, vector<string> c);
  14. void goesFirst();
  15. void winner();
  16. };
  17.  
  18. class Player : public Domino {
  19. public:
  20. vector <string> playerDom;
  21. void menu(int);
  22. void printDom(vector<string> playerDom);
  23. void addBoneyard();
  24. void head();
  25. void tail();
  26. void pass();
  27. };
  28.  
  29. vector<string> Domino::shuffle(vector<string> a, vector<string> b,
  30. vector<string> c) {
  31. typedef map<int, string> boneyard;
  32. boneyard m;
  33. m[1] = "[0|1]";
  34. m[2] = "[0|2]";
  35. m[3] = "[0|3]";
  36. m[4] = "[0|4]";
  37. m[5] = "[0|5]";
  38. m[6] = "[0|6]";
  39. m[7] = "[1|2]";
  40. m[8] = "[1|3]";
  41. m[9] = "[1|4]";
  42. m[10] = "[1|5]";
  43. m[11] = "[1|6]";
  44. m[12] = "[2|3]";
  45. m[13] = "[2|4]";
  46. m[14] = "[2|5]";
  47. m[15] = "[2|6]";
  48. m[16] = "[3|4]";
  49. m[17] = "[3|5]";
  50. m[18] = "[3|6]";
  51. m[19] = "[4|5]";
  52. m[20] = "[4|6]";
  53. m[21] = "[5|6]";
  54. m[22] = "[0|0]";
  55. m[23] = "[1|1]";
  56. m[24] = "[2|2]";
  57. m[25] = "[3|3]";
  58. m[26] = "[4|4]";
  59. m[27] = "[5|5]";
  60. m[28] = "[6|6]";
  61.  
  62. vector <string> bone;
  63. for (boneyard::iterator it = m.begin(); it != m.end(); it++) {
  64. bone.push_back(it->second);
  65. }
  66.  
  67. random_shuffle(bone.begin(), bone.end());
  68.  
  69. int n = 6, i = 0;
  70. vector<string>playerDom(bone.begin(), bone.begin() + n);
  71. for (i = 0; i < playerDom.size(); i++) {
  72. cout << playerDom[i];
  73. }
  74. cout << endl;
  75. a = playerDom;
  76.  
  77. vector<string>compDom(bone.end() - n, bone.end());
  78. for (i = 0; i < compDom.size(); i++) {
  79. cout << compDom[i];
  80.  
  81. }
  82. cout << endl;
  83. b = compDom;
  84.  
  85. bone.erase(bone.begin(), bone.begin() + n);
  86. bone.erase(bone.end() - n, bone.end());
  87.  
  88. for (i = 0; i < bone.size(); i++) {
  89. cout << bone[i];
  90. cout << endl;
  91. }
  92. c = bone;
  93.  
  94. return a, b, c;
  95. }
  96.  
  97. void Domino::goesFirst() {
  98. string AI;
  99. bool status = true;
  100. /*for (int i = 0; status && i < 6; i++) {
  101. if (AI[i] = '0,0') {
  102. //idk how to figure out WHICH player will go first, comparing their numbers to figure out
  103. //who has the HIGHER number. Ex. AI has '4,4' but player has '6,6', therefore player goes first
  104. }
  105. else if (AI[i] = '1,1') {
  106. //USE A BINARY SEARCH?
  107. }
  108. else if (AI[i] = '2,2') {
  109. //SUBSTRING USED TO FLIP DOMINOES TO MATCH NUMBERS
  110. }
  111. else if (AI[i] = '3,3') {// [ 2 | 3 ]
  112. //
  113. }
  114. else if (AI[i] = '4,4') {
  115. //
  116. }
  117. else if (AI[i] = '5,5') {
  118. //
  119. }
  120. else if (AI[i] = '6,6') {
  121. //
  122. }
  123. }
  124. // compare computer and player1 dominoes to find who goes first
  125. // whoever has the heaviest of (6,6), (5,5), (4,4), (3,3), (2,2), (1,1)
  126. // goes first*/
  127. return;
  128. }
  129.  
  130. void Player::printDom(vector<string> a) {
  131. //a = shuffle(a);
  132. for (int i = 0; i < a.size(); i++) {
  133. cout << a[i];
  134. }
  135. return;
  136. }
  137.  
  138. void Player::addBoneyard() {//BONEYARD MUST BE SHUFFLED FIRST
  139. // get the first domino in the boneyard and add it
  140. // if there are no more dominoes in the boneyard then
  141. the turn passes
  142. return;
  143. }
  144.  
  145. void Domino::winner() {
  146. int counter = 0;
  147. // counts elements in array to determine winner
  148. for (int index = 0; index <= 6; index++) {//idk what to add in to count each players pieces
  149. counter++; //it should look similar to the pass function
  150. }
  151. return;
  152. }
  153.  
  154. void Player::head() {
  155. // place domino on the left, first in the array
  156. //ADD ELEMENT TO FRONT OF VECTOR USE INSERT
  157. return;
  158. }
  159.  
  160. void Player::tail() {
  161. // place domino on the right, last in the array
  162. //ADD ELEMENT TO END OF VECTOR USE PUSH_BACK
  163. return;
  164. }
  165.  
  166. void Player::pass() {
  167. //somehow figure out how to continue the game
  168. // passes turn, also passes if the boneyard is empty
  169. return;
  170. }
  171.  
  172. int printMenu(int choice) {
  173. cout << "Domino Menu" << endl << endl;
  174. cout << "1. Print your dominoes" << endl;
  175. cout << "2. Add a domino to the head of the train" << endl;
  176. cout << "3. Add a domino to the tail of the train" << endl;
  177. cout << "4. Pick a domino from the boneyard" << endl;
  178. cout << "5. Pass your turn (only if bone yard is empty)" << endl;
  179. cout << "6. Print this menu" << endl;
  180. cout << "7. Quit" << endl << endl;
  181. cout << "Please enter a choice: ";
  182. cin >> choice;
  183. return choice;
  184. }
  185.  
  186. void Player::menu(int choice) {
  187. choice = printMenu(choice);
  188.  
  189. if (choice == 1) {
  190. //printDom(i);
  191. }
  192. else if (choice == 2) {
  193. head();
  194. }
  195. else if (choice == 3) {
  196. tail();
  197. }
  198. else if (choice == 4) {
  199. addBoneyard();
  200. }
  201. else if (choice == 5) {
  202. pass();
  203. }
  204. else if (choice == 6) {
  205. printMenu(choice);
  206. }
  207. else if (choice == 7) {
  208. exit(0);
  209. }
  210.  
  211. return;
  212. }
  213.  
  214. int main()
  215. {
  216. Domino play;
  217. Player play1;
  218. play1.menu(0);
  219.  
  220. return 0;
  221. }
Add Comment
Please, Sign In to add comment