|
@@ -0,0 +1,94 @@
|
|
|
+#include <iostream> // std::cout
|
|
|
+#include <algorithm> // std::random_shuffle
|
|
|
+#include <vector> // std::vector
|
|
|
+#include <ctime> // std::time
|
|
|
+#include <cstdlib> // std::rand, std::srand
|
|
|
+#include <set>
|
|
|
+
|
|
|
+using namespace std;
|
|
|
+
|
|
|
+enum Color {CARREAU, COEUR, PIQUE, TREFLE};
|
|
|
+enum Rank {AS = 1, VALET = 11, DAME, ROI};
|
|
|
+
|
|
|
+struct Card
|
|
|
+{
|
|
|
+ Color c; // Couleur
|
|
|
+ int r; // Rang
|
|
|
+};
|
|
|
+
|
|
|
+bool operator<(const Card &a, const Card &b)
|
|
|
+{
|
|
|
+ if (a.r < b.r)
|
|
|
+ return true;
|
|
|
+ else if (a.r == b.r)
|
|
|
+ return a.c < b.c;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+void disp(const vector<Card> &tas)
|
|
|
+{
|
|
|
+ for (auto it(tas.begin()); it != tas.end(); it++) {
|
|
|
+ cout << "C:" << it->c <<"; R:"<< it->r << endl;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void disp(const set<Card> &jeu)
|
|
|
+{
|
|
|
+ for (auto it(jeu.begin()); it != jeu.end(); it++) {
|
|
|
+ cout << "C:" << it->c <<"; R:"<< it->r << endl;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void piocher(vector<Card> &tas, set<Card> &jeu)
|
|
|
+{
|
|
|
+ jeu.insert(tas.back());
|
|
|
+ tas.pop_back();
|
|
|
+}
|
|
|
+
|
|
|
+/* Essaye de jouer, et sinon pioche. */
|
|
|
+void jouer(vector<Card> &pioche, vector<Card> &pile, set<Card> &jeu)
|
|
|
+{
|
|
|
+ // Peut jouer la même couleur
|
|
|
+ Card instCard;
|
|
|
+ instCard.c = pile.back();
|
|
|
+
|
|
|
+ // Essaye tous les numéros
|
|
|
+ // ... find avec set
|
|
|
+
|
|
|
+ // Essaye le numéro et d'autres couleurs
|
|
|
+
|
|
|
+ // Pioche
|
|
|
+}
|
|
|
+
|
|
|
+int main(int argc, char const *argv[])
|
|
|
+{
|
|
|
+ // Variables
|
|
|
+ const int nbPlayer(2);
|
|
|
+ int curPlayer(0);
|
|
|
+ Card instCard;
|
|
|
+
|
|
|
+ vector<Card> pioche;
|
|
|
+ vector<Card> pile;
|
|
|
+
|
|
|
+ for (int c(0); c < 4; c++)
|
|
|
+ for (int r(AS); r < 14; r++) {
|
|
|
+ instCard.c = (Color)c;
|
|
|
+ instCard.r = r;
|
|
|
+ pioche.push_back(instCard);
|
|
|
+ }
|
|
|
+
|
|
|
+ set<Card> jeu[nbPlayer];
|
|
|
+
|
|
|
+ // Init
|
|
|
+ random_shuffle(pioche.begin(), pioche.end());
|
|
|
+
|
|
|
+ for (int k(0); k < nbPlayer; k++) {
|
|
|
+ for (int c(0); c < 3; c++) {
|
|
|
+ piocher(pioche, jeu[k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Fin
|
|
|
+ return 0;
|
|
|
+}
|