mardi 23 février 2021

C++ 2D int array randomly shuffle

I am trying to make a program that simulates a game of dominoes. For this I have to randomly shuffle the pile of dominoes but I cannot figure out how. I have searched this but everything I have tried has failed. Is there a way to do this? Here is what I was attempting, the problem with this though is that it says that Seed and Time are not declared in this scope:

#include <iostream>
#include <vector>
#include <ctime>
#include <algorithm>
#include <cstdlib>


using namespace std;

class CRandom {
   public:
      vector<int>* shufflePile(){
      
         vector<int>* pile = new vector<int>;
         
         for(int i=0; i<=27; i++){
            pile->push_back(i);
         }
         srand( _Seed; unsigned (time( _Time 0)));
         random_shuffle(pile->begin(), pile->end());
         
   }

};

class CDominoes {
   int pieces [28][3] =
      {
         {0,0,1}, //1
         {1,1,1}, {1,0,1}, //2,3
         {2,2,1}, {2,1,1}, {2,0,1}, //4, 5, 6
         {3,3,1}, {3,2,1}, {3,1,1}, {3,0,1}, //7, 8, 9, 10
         {4,4,1}, {4,3,1}, {4,2,1}, {4,1,1}, {4,0,1}, //11, 12, 13, 14, 15
         {5,5,1}, {5,4,1}, {5,3,1}, {5,2,1}, {5,1,1}, {5,0,1}, //16, 17,18, 19, 20, 21
         {6,6,1}, {6,5,1}, {6,4,1}, {6,3,1}, {6,2,1}, {6,1,1}, {6,0,1} //22, 23, 24, 25, 26, 27, 28 
      };
};

class CPlayer {
};

class CTable {
};

int main() {
}



Aucun commentaire:

Enregistrer un commentaire