zeph
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Maïwen ## fonction.cpp ```` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <cstdlib> #include <sstream> using namespace std; typedef vector<vector<string>> tableau; tableau initialise_grille(){ tableau grille; grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; } } return grille; } string aleatoire(){ vector<string> t = {".","R","V","J","B","M"}; return t[rand() % 6]; } tableau test_grille(){ tableau grilletest; grilletest =tableau (12); for ( int i = 0 ; i < grilletest.size(); i++ ){ grilletest[i]=vector<string> (6); for ( int j = 0; j < grilletest[i].size(); j++ ) { grilletest[i][j] = aleatoire(); } } return grilletest; } tableau gravite(tableau grille){ for(int i=grille.size()-1;i>0;i--){ // on passe le tableau en revue du bas vers le haut et de gauche vers la droite for(int j=0 ;j<grille[i].size();j++){ if(grille[i][j]=="."){ string a= grille[i][j]; //on swap grille1[i][j] avec la case du dessus grille[i][j]=grille[i-1][j]; grille[i-1][j]=a; } } } return grille; } tableau gravitefinal(tableau grille){ tableau grillefinal=grille; for(int i=grille.size()-1;i>0;i--){ for(int j=0 ;j<grille[i].size();j++){ for ( int k=0;k<12;k++){ grillefinal= gravite(grillefinal); } } } return grillefinal; } tableau debut(tableau grille, tableau puyo,int colonne){ if(puyo[0][1]=="."){ grille[0][colonne-1]=puyo[0][0]; grille[1][colonne-1]=puyo[1][0]; }else{ grille[0][colonne-1]= puyo[0][0]; grille[0][colonne]=puyo[0][1]; grille[1][colonne-1]=puyo[1][0]; grille[1][colonne]=puyo[1][1]; } return grille; } void affichegrille(tableau grille,int score) { for ( int i = 0; i <grille.size(); i++ ) { for ( int j = 0; j < grille[i].size(); j++ ){ cout << setw(2) << grille[i][j] << " "; } cout << endl; } cout <<endl<<score<<" points."<<endl<<endl; } string remplacecouleur1(int tour,vector<string>tab){ string couleur1; couleur1=tab[tour][0]; return couleur1; } string remplacecouleur2(int tour,vector<string>tab){ string couleur2; couleur2=tab[tour][1]; return couleur2; } int remplacerotation(int tour,vector<string>tab){ int rotation; istringstream flux =istringstream(tab[tour*2]); int i; flux>>i; rotation=i; return rotation; } int remplacecolonne(int tour,vector<string>tab){ int colonne; istringstream flux =istringstream(tab[tour*2]); int i; flux>>i; flux>>i; colonne=i; return colonne; } tableau faitrotation (tableau choix0, int rotation){ tableau choix1={{choix0[0][1],"."},{choix0[0][0],"."}}; tableau choix2={{choix0[0][1],choix0[0][0]},{".","."}}; tableau choix3={{choix0[0][0],"."},{choix0[0][1],"."}}; if (rotation ==0){ return choix0; }else if (rotation == 1){ return choix1; }else if (rotation == 2){ return choix2; }else if (rotation == 3){ return choix3; } } bool isgameover(tableau grille,tableau puyo,int colonne){ if(puyo[1][0]=="."){ if (grille[0][colonne-1]!="." or grille[0][colonne]!="."){ return false; } return true; } if(grille[0][colonne]!="."){ return false; } return true; } void affiche(tableau choix0){ tableau choix1={{choix0[0][1],"."},{choix0[0][0],"."}}; tableau choix2={{choix0[0][1],choix0[0][0]},{".","."}}; tableau choix3={{choix0[0][0],"."},{choix0[0][1],"."}}; for (int i=0; i<4;i++){ cout<<"Rotation "<<i<<"\t"; } cout<<endl; cout<<choix0[0][0]<<" "<<choix0[0][1]<<"\t\t"<<choix1[0][0]<<" "<<choix1[0][1]<<"\t\t"<<choix2[0][0]<<" "<<choix2[0][1]<<"\t\t"<<choix3[0][0]<<" "<<choix3[0][1]<<endl; cout<<choix0[1][0]<<" "<<choix0[1][1]<<"\t\t"<<choix1[1][0]<<" "<<choix1[1][1]<<"\t\t"<<choix2[1][0]<<" "<<choix2[1][1]<<"\t\t"<<choix3[1][0]<<" "<<choix3[1][1]<<endl; } vector<int> choixrotationcolonne(tableau choix0, tableau grille, int score){ affiche(choix0); cout<<endl; affichegrille(grille,score); string continuer="n"; vector<int> tab; while(continuer=="n"){ //test si le jouer souhaite continuer avec la rotation et la colonne choisie int rotation; cout<< "Rotation: "; cin>>rotation; while(rotation<0 or rotation>3){ cout<<"Rotation invalide, veuillez r�essayer: "; cin>>rotation; cout<<endl; } int colonne; cout<<"Colonne: "; cin>>colonne; while(colonne<1 or colonne>6 or (colonne==6 and rotation%2==0)){ cout<<"Colonne invalide, veuillez r�essayer: "; cin>>colonne; cout<<endl; } affichegrille (debut(grille,faitrotation(choix0,rotation),colonne),score); cout<<"Continuer ? (y/n) "; cin>>continuer; cout<<endl; tab={rotation,colonne}; } return tab; } int aleatoire_rotation(){ return rand ()%4; } int aleatoire_colonne(int rotation){ if(rotation%2==0){ return (rand()%5)+1; } return (rand() % 6)+1; } ```` ### fonction.h ``` // Les fonction not?es M ont ?t?s faites par Ma?wen et celle not?es T par Tiphaine /** M Initialise grille vide * Testée connu * @return une grille vide repr?sent?e par des points ? l'int?rieur **/ tableau initialise_grille(); /** M Aléatoire qui donne une couleur ou un point * Impossible à tester du fait de l'al?atiore mais fonctionne empiriquement * @return un string point ou couleur **/ string aleatoire(); /** M Initialise grille test al?atoire * Impossible ? tester du fait de l'al?atiore mais fonctionne empiriquement * @return une grille test aleatoire **/ tableau test_grille(); /** M gravit? fais descendre d'une case tous les puyos d'une case si possible * Testée aucun bug connu * @param grille la grille de jeu * @return grille le tableau 2D après un coup **/ tableau gravite(tableau grille); /** M gravitefinal fais descendre tous en bas * Testée aucun bug connu * @param grille la grille de jeu * @return tableau la nv grille **/ tableau gravitefinal(tableau grille); /** M affiche grille et le score * Test?e empiriquement aucun bug connu * @param grille le tableau 2D de string * @param score un entier **/ void affichegrille(tableau grille,int score); /** M Place les puyos du d�part dans la bonne colonne * Testée aucun bug connu * @param grille un tableau 2d de string * @param puyo un tableau 2D de string avec la position des puyos * @param colonne un entier * @return grille la grille de jeu actualis?e **/ tableau debut(tableau grille, tableau puyo,int colonne); /** M Assigne � une variable la couleur du premier puyo * Test�e aucun bug connu * @param int le num�ro du tour * @param tab le tableau qui continent les lignes du fichier * @param le num?ro de la colonnes * @return le string qui correspond ? la couleur **/ string remplacecouleur1(int tour,vector<string>tab); /** M Assigne a une variable la couleur du deuxieme puyo * Test�e aucun bug connu * @param int le num�ro du tour * @param tab le tableau qui continent les lignes du fichier * @return le string qui correspond a la couleur **/ string remplacecouleur2(int tour,vector<string>tab); /** M Assigne a nue variable le numero de la rotation * Test�e aucun bug connu * @param int le num?ro du tour * @param tab le tableau qui contient les lignes du fichier * @return l'entier correspondant **/ int remplacerotation(int tour,vector<string>tab); /** M Assigne a une variable le num�ro de la colonne * Test�e aucun bug connu * @param int le num�ro du tour * @param tab le tableau qui contient les lignes du fichier * @return l'entier correspondant **/ int remplacecolonne (int tour,vector<string>tab); /** T retourne le tableau avec la rotation choisie * Test�e aucun bug connu * @param le tableau avec les 2 Puyos * @param la rotation choisi * @return le tableau correspondant ? la rotation **/ tableau faitrotation (tableau choix0, int rotation); /** M vérifie si défaite * Testée aucun bug connu * @param tableau la grille de puyos * @param tableau la grille qui repr?sente les puyos ? ins?rer * @param int le numéro de la colonne * @return false si défaite true sinon **/ bool isgameover(tableau grille,tableau puyo,int colonne); /** T demande au joueur de choisir une colonne et une rotation en lui montrant les propositions * Impossible a testé avec un cin mais fonctionne empiriquement * Bug erreur si on rentre un char au lieu d'un int * @param choix0 tableau 2d pour la rotation * @param grille tableau 2D pour la grille de jeu * @param score un entier * @return tab un tableau de 2 entiers avec la colonne et rotation choisi par le joueur **/ vector<int> choixrotationcolonne(tableau choix0, tableau grille, int score); /** affiche les différents patern de rotation * Testée empiriquement aucun bug connu * @param la combinaison en rotation 0 des puyos **/ void affiche(tableau choix0); /** genere une rotation aleatoire entre 0 et 3 * Impossible � tester du fait de l'al�atiore mais fonctionne empiriquement * @return rotation un chiffre al�atoire entre 0 et 3 **/ int aleatoire_rotation(); /** genere une colonne aleatoire entre 0 et 11 * Impossible ? tester du fait de l'al?atiore mais fonctionne empiriquement * @param rotation le num?ro de la rotation * @return colonne le num?ro de la colonne aleatoire **/ int aleatoire_colonne(int rotation); ``` ## fonction-fichier.cpp ``` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include<iomanip> #include <cstdlib> using namespace std; typedef vector<vector<string>> tableau; int compteleslignes(string nomfichier){ int nbligne=0; ifstream fichier; fichier.open(nomfichier); string ligne; while(getline(fichier, ligne)){ nbligne++; } fichier.close(); return nbligne; } vector<string> extraitfichier (string nomfichier){ int nblignes = compteleslignes(nomfichier); vector<string> textrait (nblignes); ifstream fichier; fichier.open(nomfichier); string ligne; int i=0; while(i<nblignes){ getline(fichier, ligne); textrait[i]=ligne; i++; } fichier.close(); return textrait ; } ``` ### fonction-fichier.h ``` // Les fonction notés M ont étés faites par Maïwen et celle notées T par Tiphaine /** M fonction qui compte le nb de ligne d'un fichier * Testée aucun bug connu * @param string le nom du fichier * @return le nb de ligne **/ int compteleslignes(string nomfichier); /** M fonction extrait les lignes d'un fichier et les met dans un tableau * Testée aucun bug connu * @param string le nom du fichier * @return letableau avec les lignes du fichier **/ vector<string> extraitfichier (string nomfichier); /** M génère des fichiers de jeu pour les trois modes différents * Impossible à tester du fait de l'aléatoire mais fonctionne à l'éxécution aucun bug connu * @return void mais génère un fichier dans le repertoire correspondant **/ void nouveaufichier(); ``` ## fonction-test.cpp ``` #include <vector> #include <iostream> #include <stdexcept> #include <fstream> #include <math.h> #include <string> #include <iomanip> #include <cstdlib> #include <sstream> using namespace std; typedef vector<vector<string>> tableau; #include "fonction.h" #include "fonction-fichier.h" #include "regle1.h" /** Infrastructure minimale de test **/ #define ASSERT(test) if (!(test)) cout<<"Test failed in file " \ <<__FILE__<<" line "<<__LINE__<<": "#test<<endl /** Les tests des fonctions**/ void fonctionbasiqueTest(){ tableau t1; t1=tableau (12); for ( int i = 0 ; i < t1.size(); i++ ){ t1[i]=vector<string> (6); for ( int j = 0; j < t1[i].size(); j++ ) { t1[i][j] = "."; } } vector<string> t2={"MODE SIMULATION","BJ","0 1","BJ","1 3","BJ","2 4","BJ","3 6"}; vector<string>t3 ={"MODE SIMULATION","BM","0 1","BJ","1 2","MM","0 4","MJ","2 2"}; tableau t4={{{"B"},{"M"}},{{"."},{"."}},{{"."},{"."}}}; tableau t5={{{"."},{"."}},{{"."},{"."}},{{"B"},{"M"}}}; tableau t6={{{"."},{"."}},{{"B"},{"M"}},{{"."},{"."}}}; string nomfichier= "exemples\\simulation\\0_rotations.txt"; string nomfichier2 ="exemples\\ia\\2_grand.txt"; tableau test = test_grille(); ASSERT (initialise_grille()==t1); ASSERT (gravitefinal(t4)==t5); ASSERT (gravite(t4)==t6); ASSERT (remplacecolonne(1,t3)==1); ASSERT (remplacecolonne(2,t3)==2); ASSERT (remplacerotation(1,t3)==0); ASSERT (remplacerotation(2,t3)==1); ASSERT (remplacecouleur1(1,t3)=="B"); ASSERT (remplacecouleur1(5,t3)=="M"); ASSERT (remplacecouleur2(1,t3)=="M"); ASSERT (remplacecouleur2(3,t3)=="J"); ASSERT (compteleslignes(nomfichier)==9); ASSERT (compteleslignes(nomfichier2)==101); ASSERT (extraitfichier(nomfichier)==t2); } void defaitetest(){ tableau puyo ={{"B","V"},{".","."}}; tableau t1; t1=tableau (12); for ( int i = 0 ; i < t1.size(); i++ ){ t1[i]=vector<string> (6); for ( int j = 0; j < t1[i].size(); j++ ) { t1[i][j] = "V"; } } ASSERT(not isgameover(t1,puyo,4)); } void fonctiondebuttest(){ tableau t = initialise_grille(); tableau puyo1 ={{"B","V"},{".","."}}; tableau puyo2 ={{"R","."},{"J","."}}; tableau t1=t; tableau t3=t; t1[0][2]=puyo1[0][0]; t1[0][3]=puyo1[0][1]; t1[1][2]=puyo1[1][0]; t1[1][3]=puyo1[1][1]; t3[0][5]=puyo2[0][0]; t3[1][5]=puyo2[1][0]; ASSERT(debut(t,puyo1,3)==t1); ASSERT (debut(t,puyo2,6)==t3); } void faitrotationtest (){ tableau choix0={{"R","J"},{".","."}}; tableau resultat1 ={{"J","."},{"R","."}}; tableau resultat2 ={{"J","R"},{".","."}}; tableau resultat3 ={{"R","."},{"J","."}}; tableau resultat0 ={{"R","J"},{".","."}}; ASSERT(faitrotation(choix0,1)==resultat1); ASSERT(faitrotation(choix0,2)==resultat2); ASSERT(faitrotation(choix0,3)==resultat3); ASSERT(faitrotation(choix0,0)==resultat0); } void scorefinaltest (){ vector<vector<int>> score ={{0,0,0,0,0,0,0},{1,2,1,2,1,2,0},{1,0,1,0,1,0,195}}; vector<vector<int>> score1={{0,0},{0,0,0},{0,0}}; vector<vector<int>> score2={{0,4,5,6,5,7},{0,2,2,1,1,1},{0,1,1,2,3,4}}; vector<vector<int>> score3={{4},{},{1}}; ASSERT (scorefinal(score)==0); ASSERT (scorefinal(score1)==0); ASSERT (scorefinal(score2)==23790); ASSERT (scorefinal(score3)==0); } void chercheligne() { tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; vector<int>t={0,3}; ASSERT(chercheligne(11,grille)==t); } void cherchecolonnetest(){ tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][3]="B"; grille [10][3]="M"; grille [9][3]="M"; grille [8][3]="M"; grille [7][3]="M"; grille [6][3]="M"; vector<int>t={6,10}; ASSERT (cherchecolonne(3,grille)==t ); } void comparaisontest (){ tableau t={{"a","b","n"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; tableau t2={{"a","b","n"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; tableau t3={{"a","b","c"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; ASSERT (comparaison(t,t2)==false); ASSERT (comparaison(t,t3)==true); } void destructiontest (){ tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; fin[11][4]="M"; fin[11][5]="M"; ASSERT(destruction(grille)==fin); } void tableauscoreETrechercheETfintourtest (){ tableau grille; tableau fin ; grille =tableau (12); fin=tableau(12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; grille [10][2]="V"; grille [10][3]="J"; grille [10][4]="M"; grille [10][5]="M"; grille [9][2]="M"; grille [9][3]="M"; grille [9][4]="J"; grille [9][5]="J"; grille [8][2]="J"; grille [8][3]="J"; fin [11][2]="V"; fin [11][3]="J"; fin [11][4]="M"; fin [11][5]="M"; vector<vector<int>> h={{0,4,4,4},{0,1,2,2},{0,1,2,2}}; vector<vector<int>> t={{0},{0},{0}}; vector<vector<int>> tab ={{0,4},{0,1},{0,1}}; ASSERT(tableauscore(grille)==h ); ASSERT (fintour(h,grille)==fin); ASSERT (recherche(1,t,grille)==tab); } /**Cette fonction main ne sert qu'� lancer les test **/ int main(){ defaitetest(); faitrotationtest(); fonctiondebuttest(); scorefinaltest(); tableauscoreETrechercheETfintourtest(); destructiontest(); comparaisontest(); chercheligne(); cherchecolonnetest(); fonctionbasiqueTest(); return 0; } ``` ## regle1.cpp ``` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <cstdlib> #include <sstream> using namespace std; typedef vector<vector<string>> tableau; #include "fonction.h" vector<int> chercheligne (int l, tableau tab){ vector<int> indice(2); string puyo; if (tab [l][2]=="."){ indice[0]=15; return indice; }else{ puyo=tab[l][2]; } int debut; int fin=0; if (puyo==tab[l][0] and tab[l][1]==puyo){ debut=0; }else if (puyo==tab[l][1]){ debut=1; }else{ debut=2; } for (int i=3;i<tab[l].size();i++){ if (puyo==tab[l][i]){ fin=i; }else{ break; } } if ((fin-debut) <3){ //verifie si le groupes est sup � 4 indice[0]=15; }else{ indice [0]=debut; indice [1]=fin; } return indice; } vector<int> cherchecolonne (int c, tableau tab){ vector<int> indice (2); int a=0; string puyo; do{ puyo=tab [a][c]; a++; }while(puyo=="." and a<12); a--; int debut =a; int fin=0; for (int j=a;j<tab.size();j++){ if (tab [j][c]!=puyo and fin-debut<3){ debut =j; puyo=tab[j][c]; }else if (tab [j][c]==puyo){ fin=j; } } if ((fin-debut) <3){ indice[0]=15; }else{ indice [0]=debut; indice [1]=fin; } return indice; } vector<vector<int>> recherche(int combos,vector<vector<int>> score, tableau tab){ int groupe=0; for (int i=0;i<tab.size();i++){ int a=chercheligne(i,tab)[0]; int b=chercheligne(i,tab)[1]; // mettre dans le tableau tt les groupes en ligne if (a!=15){ // si !=15 trouve un groupe score[0].push_back(b-a+1); //nombre de puyo de ce groupe groupe++; } } for (int i=0;i<tab[0].size();i++){ int a=cherchecolonne(i,tab)[0]; int b =cherchecolonne(i,tab)[1]; // mettre dans le tableau tt les groupes en colonne if (a!=15){ score[0].push_back(b-a+1); // nombre de puyo de ce groupe groupe++; } } int j=0; while(j<groupe) { score[1].push_back(groupe); // donne le nombre de groupes d�truit score[2].push_back(combos); j++; // rentre le num�ros du combos si il y en a un } return score; } tableau destruction (tableau tab){ for (int i=0;i<tab.size();i++){ int a=chercheligne(i,tab)[0]; int b =chercheligne(i,tab)[1]; // détruire tous les groupes en ligne if (a!=15){ for (int j=0; j<=b-a;j++){ tab [i][a+j]="."; } } } for (int j=0;j<tab[0].size();j++){ int a =cherchecolonne(j,tab)[0]; int b =cherchecolonne(j,tab)[1]; // d�truire tous les groupes en colonne if (b!=15){ for (int d=0; d<=b-a;d++){ tab [a+d][j]="."; } } } return tab; } bool comparaison (tableau tab, tableau ancien){ for (int i=0;i<tab.size();i++){ for (int j=0;j<tab[i].size();j++){ if (tab[i][j]!=ancien[i][j]){ return true; } } } return false; } vector<vector<int>> tableauscore (tableau tab){ int combos =1; tableau ancien (12); tableau nouveau (12); for (int i=0;i<ancien.size();i++){ ancien[i]= vector<string>(6); nouveau [i]=vector<string>(6); ancien=tab; } vector<vector<int>> score(3); //nb puyo- nb groupe -nb combos score[0]=vector<int> (1); score[1]=vector<int> (1); score[2]=vector<int> (1); do{ score=recherche(combos,score,ancien); ancien=gravitefinal (destruction(ancien)); nouveau=gravitefinal (destruction(ancien)); combos++; }while (comparaison(ancien,nouveau)); return score; } tableau fintour (vector<vector<int>> score,tableau tab){ int a=score[0].size(); if(a==0){ return tab; } int q=score[2][a-1]; for (int z=0;z<=q;z++){ tab=gravitefinal(destruction(tab)); } return tab; } int scorefinal (vector<vector<int>> score){ int sc=0; for (int v=1;v<score[0].size();v++){ sc+=10*score[0][v]*(pow(4,score[2][v])+pow(3,score[1][v])); } return sc; } ``` ### regle1.h ``` // Les fonction notés M ont étés faites par Maïwen et celle notées T par Tiphaine /** T la fct cherche la présence d'un groupe dans une ligne * Fiable, mais elle fonctionne uniquement avec des tableau de 12 sur 6. Il y a un test pour cette fonction. * @param l la ligne dans laquelle on veut chercher * @param tab le tableau de jeu * @return l'indice de début et de fin du groupe sous forme d'un tableau à deux cases, si il n'y a pas de groupe, retourne 15 dans la première case du tableau **/ vector<int> chercheligne (int l, tableau tab); /** T la fonction recherche la présence d'un groupe dans la colonne * fiable, mais elle fonctionne uniquement avec des tableau de 12 sur 6. Il y a un test pour cette fonction * @param c l'indice de la collonne où chercher * @param tab le tableau de jeu * @return l'indice de début et de fin du groupe (orga dans un tableau?) ou 0 si il n'y a pas de groupe **/ vector<int> cherchecolonne (int c, tableau tab); /** T la fonction recherche qui dénombre le nombre de groupes présent dans le tableau * fiable mais compatible qu’avec des tableau string de 12 sur 6 Il y a un test pour cette fonction. * @param combos le numéros du combos * @param score l'actuel tableau de score (soit vides, soit avec la description des groupes du combos précédent) * @param tab le plateau de jeu * @return un tableau 2d d'entier, où une colonne représente un group de puyo, la 1 er ligne est le nombre de puyo dans le groupe, la 2ème ligne et le nombre de groupe sur un même tableau de jeu en même tempss, et la 3 ème ligne est le numéros du combos qui est donné dans les paramèrtres. **/ vector<vector<int>> recherche(int combos,vector<vector<int>> score, tableau tab); /** T la fonction destruction enlève du tableau tous les groupes du tableau * fiable, mais compatible qu’avec des tableau 12 sur 6 et des tableaux string. Il y a un test. * @param tab le tableau * @return le tableau avec les groupes supprimés **/ tableau destruction (tableau tab); /** T La fonction compare deux tablaux * fiable, compatible avec toute taille de tableau de type string. Mais elle ne vérifie pas si les 2 tableaux sont de la même taille. Il y a un test. * @param tab le premier tableau * @param ancien le deuxième tableau deux tableaux * @return true si les deux tableaux sont identiques, false sinon **/ bool comparaison (tableau tab, tableau ancien); /** T La fonction construit le tableau de score complet du tours de jeu * fiable, compatible qu'avec des tableau de 12 sur 6 de type string.. Il y a un test pour cette fonction. * @param tab le plateau de jeu * @return le tableau des scores du groupe entier **/ vector<vector<int>> tableauscore (tableau tab); /** T la fonction construit le tableau de fin de tours, avec tout les groupes suprimé * fiable, elle est compatible avec des tableau string de toutes tailles. il y a un test. * @param score le tableau des scores * @param tab le plateau de jeu * @return le tableau de jeu à la fin du tours **/ tableau fintour (vector<vector<int>> score,tableau tab); /** T fonction compte les points du tours * fiable, mais le tableau doit être correctement créer. Il y a plusieurs teste pour cette fonction. * @param score le tableau des scores * @return le score de ce tours **/ int scorefinal (vector<vector<int>> score); ``` ## generefichier.cpp ``` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include<iomanip> #include <cstdlib> using namespace std; typedef vector<vector<string>> tableau; #include "fonction.h" int main(){ cout<<"Entrez: 1 pour jouer au mode simulation"<<endl; cout<<"2 pour jouer au mode solo"<<endl; cout<<"3 pour jouer au mode IA"<<endl; int mode; cin>>mode; cout<<"Indiquez le nombre de tour de jeu souhait�: "<<endl; int nbtour; cin>>nbtour; while(nbtour<=0){ cout<<"Nombre invalide"<<endl; cin>>nbtour; } string nomfichier; cout<<"Donner un nom de fichier"<<endl; cin>>nomfichier; ifstream fichieri(nomfichier); while (fichieri){ //v�rifie si le fichier n'existe pas d�j� cout<<"Fichier existe d�j�"<<endl; fichieri.close(); cin>>nomfichier; ifstream fichieri(nomfichier); } fichieri.close(); ofstream fichier; fichier.open(nomfichier); if(mode==1){ //lance mode simultation fichier<<"MODE SIMULATION"<<endl; for (int i=0;i<nbtour;i++){ vector<string> t = {"R","V","J","B","M"}; string piece1=t[rand() % 5]; string piece2=t[rand() % 5]; fichier<<piece1<<piece2<<endl; int rotation=aleatoire_rotation(); int colonne=aleatoire_colonne(rotation); fichier<<rotation<<" "<<colonne<<endl; } fichier.close(); } if (mode==2){ //lance mode solo fichier<<"MODE SOLO"<<endl; for (int i=0;i<nbtour;i++){ vector<string> t = {"R","V","J","B","M"}; string piece1=t[rand() % 5]; string piece2=t[rand() % 5]; fichier<<piece1<<piece2<<endl; } fichier.close(); } if(mode==3){ //lance mode ia fichier<<"MODE IA"<<endl; for (int i=0;i<nbtour;i++){ vector<string> t = {"R","V","J","B","M"}; string piece1=t[rand() % 5]; string piece2=t[rand() % 5]; fichier<< piece1<<piece2<<endl; } fichier.close(); } return 0; } ``` ## puyo.cpp ``` #include <vector> #include <iostream> #include <stdexcept> #include <fstream> #include <math.h> #include <string> #include <sstream> #include <locale> using namespace std; typedef vector<vector<string>> tableau; #include "fonction-fichier.h" #include "fonction.h" #include "regle1.h" int main(int argc, char *argv[] ){ if (argc < 2){ throw invalid_argument("wrong argument"); } string anim="a"; if(argc==3){ anim= argv[2]; } string nomfichier=argv[1]; vector<string> tabfichier = extraitfichier(nomfichier); string mode = tabfichier[0]; if (mode =="MODE SIMULATION"){ if (anim=="anim"){ cout << mode<<endl; //MODE SIMULATION } tableau grille = initialise_grille(); int score = 0; int tour = 1; bool gagne = true; if (anim=="anim"){ affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } int nblignes = compteleslignes(nomfichier); while(tour <= (nblignes-1)/2 and gagne){ string couleur1 = remplacecouleur1(tour*2-1,tabfichier); string couleur2 = remplacecouleur2(tour*2-1,tabfichier); int rotation = remplacerotation(tour,tabfichier); int colonne = remplacecolonne(tour,tabfichier); tableau puyo = faitrotation({{couleur1,couleur2},{".","."}},rotation); gagne=isgameover(grille,puyo,colonne); if (gagne){ grille = debut(grille,puyo,colonne); grille = gravitefinal(grille); if (anim=="anim"){ cout << "Press Enter to Continue"; cin.ignore(); affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } vector<vector<int>> resultat= tableauscore(grille); grille=fintour(resultat,grille); score +=scorefinal(resultat); if (anim=="anim"){ cout << "Press Enter to Continue"; cin.ignore(); affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } tour++; } } ofstream fichierfin; fichierfin.open("sortie_simulation.txt"); if(not gagne ){ fichierfin<<"GAME OVER"<<endl; } for (int i = 0 ;i < grille.size();i++){ for (int j = 0 ;j < grille[i].size();j++){ fichierfin<<grille[i][j]<<" "; } fichierfin<<endl; } fichierfin<<endl; fichierfin<<score<<" points"; fichierfin.close(); } if(mode=="MODE SOLO"){ cout<<mode<<endl; //MODE SOLO tableau grille=initialise_grille(); int score = 0; int tour = 1; bool gagne= true; int nblignes = compteleslignes(nomfichier); vector<vector<string>> data(4); while(tour <= (nblignes-1) and gagne){ string couleur1 = remplacecouleur1(tour,tabfichier); string couleur2 = remplacecouleur2(tour,tabfichier); tableau puyo = faitrotation({{couleur1,couleur2},{".","."}},0); vector <int> valeur =choixrotationcolonne(puyo,grille,score); int colonne= valeur[1]; int rotation =valeur[0]; ostringstream flux1; flux1<<colonne; string colonnedata=flux1.str(); ostringstream flux2; flux2<<rotation; string rotationdata=flux2.str(); data[0].push_back(rotationdata); //pour les fichiers de sauvegardes data[1].push_back(colonnedata); data[2].push_back(couleur1); data[3].push_back(couleur2); gagne=isgameover(grille,puyo,colonne-1); if (gagne){ puyo=faitrotation(puyo,rotation); grille=gravitefinal(debut(grille,puyo,colonne)); affichegrille(grille,score); vector<vector<int>> resultat= tableauscore(grille); grille=fintour(resultat,grille); score +=scorefinal(resultat); tour++; cout << "Press Enter to Continue"; cin.ignore(); affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } } affichegrille(grille,score); ofstream fichierfin; fichierfin.open("sortie_solo.txt"); fichierfin<<"MODE SIMULATION"<<endl; for (int j = 0;j < data[0].size();j++){ fichierfin<<data[2][j]<<data[3][j]<<endl; fichierfin<<data[0][j]<<" "<<data[1][j]<<endl; } fichierfin.close(); } if(mode=="MODE IA"){ //MODE IA if (anim=="anim"){ cout<<mode<<endl; } tableau grille=initialise_grille(); int score = 0; int tour = 1; bool gagne= true; if (anim=="anim"){ affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } int nblignes = compteleslignes(nomfichier); vector<vector<int>> data(2); while(tour <= (nblignes-1) and gagne){ string couleur1 = remplacecouleur1(tour,tabfichier); string couleur2 = remplacecouleur2(tour,tabfichier); int rotation = aleatoire_rotation(); int colonne = aleatoire_colonne(rotation); tableau puyo = faitrotation({{couleur1,couleur2},{".","."}},rotation); gagne=isgameover(grille,puyo,colonne-1); data[0].push_back(rotation); data[1].push_back(colonne); if (gagne){ grille = debut(grille,puyo,colonne); grille = gravitefinal(grille); if (anim=="anim"){ cout << "Press Enter to Continue"; cin.ignore(); affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } vector<vector<int>> resultat= tableauscore(grille); grille=fintour(resultat,grille); score +=scorefinal(resultat); if (anim=="anim"){ cout << "Press Enter to Continue"; cin.ignore(); affichegrille(grille,score); cout<<"Tour:"<<tour<<endl; } tour++; } } ofstream fichierfin; fichierfin.open("sortie_ia.txt"); if(not gagne ){ fichierfin<<"GAME OVER"<<endl; } for (int j=0;j<data[0].size();j++){ fichierfin<<data[0][j]<<" "<<data[1][j]<<endl; } for (int i = 0 ;i < grille.size();i++){ for (int j = 0 ;j < grille[i].size();j++){ fichierfin<<grille[i][j]<<" "; } fichierfin<<endl; } fichierfin<<endl; fichierfin<<score<<" points"; fichierfin.close(); } return 0; } ``` ## regle2.cpp (ébauche du coup mais nevermind) ``` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include <math.h> #include <iomanip> #include <cstdlib> #include <sstream> using namespace std; typedef vector<vector<string>> tableau; #include "fonction.h" #include "regle2.h" tableau destruction2(tableau grille){ int groupe=0; grille.push_back({"0","0","0"}); cout<<grille[12][0]<<endl; for (int i=0;i<12;i++){ cout<<"ok3"<<endl; for (int j=0;j<6;j++){ cout<<"ok4"<<endl; string couleur=grille[i][j]; cout<<couleur<<endl; if(couleur!="."){ grille=detection(i,j,couleur,"t",grille); string snbpuyo=grille[12][0]; istringstream flux =istringstream(snbpuyo); int k; flux>>k; int nbpuyo=k; cout<<nbpuyo<<endl; if(nbpuyo<4){ grille=detection(i,j,"t",couleur,grille); }else{ grille=detection(i,j,"t",".",grille); groupe++; } } } //cout<<grille[12][0]<<"nbpuyo"<<endl; grille.pop_back(); } //vector<int> score={groupe}; return grille; } tableau detection(int l, int c, string clri, string clrf, tableau grille){ //clri couleur cible clrf couleur finale string snbpuyo=grille[12][0]; istringstream flux1 =istringstream(snbpuyo); int k; flux1>>k; int nbpuyo=k; grille.pop_back(); cout<<clri<<endl; if(grille[l][c]==clri){ nbpuyo++; grille[l][c]=clrf; if(c!=0){ grille=detection(l,c-1,clri,clrf,grille); //cherche à gauche } if(c!=5){ grille= detection(l,c+1,clri,clrf,grille); //cherche à droite } if(l!=0){ grille= detection(l-1,c,clri,clrf,grille); //cherche en haut } if(l!=11){ grille= detection(l+1,c,clri,clrf,grille); //cherche en bas } } ostringstream flux2; flux2<<nbpuyo; string s= flux2.str(); grille.push_back({s,"0","0"}); return grille; } ``` # Tiphaine ``` #include <stdexcept> #include <iostream> #include <fstream> #include <vector> #include <string> #include <assert.h> #include <math.h> #include<iomanip> /** Infrastructure minimale de test **/ #define ASSERT(test) if (!(test)) cout<<"Test failed in file " \ <<__FILE__<<" line "<<__LINE__<<": "#test<<endl using namespace std; typedef vector<vector<string>> tableau; /** affiche des tableaux @param un tableau de string @void affiche le tableau **/ void affichetableau (tableau tab){ for (int i=0;i<tab.size();i++){ for(int j=0;j<tab[i].size();j++){ cout<<setw(2)<<tab[i][j]<<" "; } cout<<endl; } } /** permet de choisir la rotation @ param untableau avec les 2 Puyos proposé @return la rotation choisie **/ int choixrotation(tableau choix0){ tableau choix1={{choix0[0][1]},{choix0[0][0]}}; tableau choix2={{choix0[0][1],choix0[0][0]},{}}; tableau choix3={{choix0[0][0]},{choix0[0][1]}}; int rotation=5; while (rotation <0 or rotation>4){ cout<< "quel rotation ?"<<endl; cout<< "0:" <<endl; affichetableau(choix0); cout<<"1:" <<endl; affichetableau(choix1); cout<<"2:" <<endl; affichetableau(choix2); cout<<"3:" <<endl; affichetableau(choix3); cin >>rotation; } return rotation; } /** retourne le tableau avec la rotation choisie @param le tableau avec les 2 Puyos @param la rotation choisi @return le tableau correspondant à la rotation **/ tableau rotation (tableau choix0, int rotation){ tableau choix1={{choix0[0][1]},{choix0[0][0]}}; tableau choix2={{choix0[0][1],choix0[0][0]},{}}; tableau choix3={{choix0[0][0]},{choix0[0][1]}}; if (rotation ==0){ return choix0; }else if (rotation ==1){ return choix1; }else if (rotation ==2){ return choix2; }else if (rotation == 3){ return choix3; } } int main(){ string a ="A"; string b ="B"; tableau choix0={{a,b},{}}; /**a créer avec une autre fonction pour l'utilisation de celle ci **/ int larotation=choixrotation (choix0); rotation (choix0, larotation); ASSERT(rotation({{"A","B"},{}}, 3)== {{"A"},{"B"}}); return 0; } ``` Et voila tt ce qui constitut la règle 1 ``` /** la fct cherche la présence d'un groupe dans une ligne @param la ligne dans laquelle on veut chercher @param le tableau de jeu @return l'indice de début et de fin du groupe sous forme d'un tableau à deux cases, si il n'y a pas de groupe, retourne 15 dans la première case du tableau OK **/ vector<int> chercheligne (int l, tableau tab){ vector<int> indice (2); string puyo=tab [l][0]; int debut =0; int fin; for (int j=1;j<tab[l].size();j++){ if (tab[l][j]== puyo){ fin=j; puyo=tab[l][j]; }else{ debut =j; } } if ((fin-debut) <3){ indice[0]=15; }else{ indice [0]=debut; indice [1]=fin; } return indice; } /** la fonction recherche la présence d'un groupe dans la colonne @param l'indice de la collonne où chercher @param le tableau de jeu @return l'indice de début et de fin du groupe (orga dans un tableau?) ou 0 si il n'y a pas de groupe OK **/ vector<int> cherchecolonne (int c, tableau tab){ vector<int> indice (2); string puyo=tab [0][c]; int debut =0; int fin; for (int i=1;i<tab.size();i++){ if (tab[i][c]== puyo){ fin=i; puyo=tab[i][c]; }else{ debut =i; } } if ((fin-debut) <3){ indice[0]=15; }else{ indice [0]=debut; indice [1]=fin; } return indice; } /** la fonction recherche qui dénombre le nombre de groupes présent dans le tableau @param le numéros du combos @param l'actuel tableau de score (soit vides, soit avec la description des groupes du combos précédent) @param le plateau de jeu @return un tableau 2d d'entier, où une colonne représente un group de puyo, la 1 er ligne est le nombre de puyo dans le groupe, la 2ème ligne et le nombre de groupe sur un même tableau de jeu en même tempss, et la 3 ème ligne est le numéros du combos qui est donné dans les paramèrtres. **/ vector<vector<int>> recherche(int combos,vector<vector<int>> resultat, tableau tab){ int groupe=0; for (int i=0;i<tab.size();i++){ /** mettre dans le tableau tt les groupes en ligne**/ if (chercheligne(i,tab)[0]!=15){ resultat[0].push_back(chercheligne(i,tab)[1]-chercheligne(i,tab)[0]);/** nombre de puyo de ce groupe**/ groupe+=1; } } for (int j=0;j<tab[0].size();j++){ /** metre dans le tableau tt les groupes en colonne**/ if (cherchecolonne (j,tab)[0]!=15){ resultat[0].push_back(cherchecolonne (j,tab)[1]-cherchecolonne (j,tab)[0]);/** nombre de puyo de ce groupe**/ groupe+=1; } } for (int k=0;k<groupe; k++){ resultat[1].push_back(groupe); /** donne le nombre de groupes détruit **/ resultat[1].push_back(combos);/** rentre le numéros du combos si il y en a un**/ } return resultat; } /** la fonction déstruction enlève du tableau tous les groupes du tableau @param le tableau @return le tableau avec des groupes en moins **/ tableau destruction (tableau tab){ for (int i=0;i<tab.size();i++){ /** détruiretous les groupes en ligne**/ vector<int> ligne (2); ligne= chercheligne (i,tab); if (ligne[0]!=15){ for (int k=0; k<(ligne[1]-ligne[0]);k++){ int a=ligne[0]; tab [i][a+k]="."; } } } for (int j=0;j<tab[0].size();j++){ /** détruire tous les groupes en ligne**/ vector<int> colonne (2); colonne= cherchecolonne (j,tab); if (colonne[0]!=15){ for (int d=0; d<(colonne[1]-colonne[0]);d++){ int b=colonne[0]; tab [b+d][j]="."; } } } return tab; } /** La fonction compare deux tablaux @param deux tableaux @return true su les deux tableaux sont ideentiques, false sinon **/ bool comparaison (tableau tab, tableau ancien){ for (int i=0;i<12;i++){ for (int j=0;j<tab[i].size();j++){ if (tab[i][j]!=ancien[i][j]){ return false; } } } return true; } /** La fonction construit le tableau de score complet du tours de jeu @param le plateau de jeu @return le tableau des scores du groupe entier **/ vector<vector<int>> tableauscore (tableau tab){ int combos =1; tableau ancien (12); tableau nouveau (12); for (int i=0;i<ancien.size();i++){ ancien[i]= vector<string>(6); nouveau [i]=vector<string>(6); for (int j=0;j<tab[i].size();j++){ ancien[i][j]=tab[i][j]; } } vector<vector<int>> score(3); do{ for (int h=0;h<recherche(combos,score,ancien).size();h++){ for (int f=0;f<recherche(combos,score,ancien)[h].size();f++){ score[h][f]=recherche(combos,score,ancien)[h][f]; } } for (int x=0;x<ancien.size();x++){ for (int y=0;y<ancien[x].size();y++){ ancien=gravitefinal (destruction(ancien)); nouveau=gravitefinal (destruction(ancien)); } } combos+=1; }while ( comparaison(ancien,nouveau) ); return score; } /** la fonction construit le tableau de fin de tours, avec tout les groupes suprimé @param le tableau des scores @param le plateau de jeu @return le tableau de jeu à la fin du tours **/ tableau fintour (vector<vector<int>> score,tableau tab){ int a=score[0].size(); int q=score[3][a]; for (int z=0;z<q;z++){ for (int t=0;t<tab.size();t++){ for (int m=0;m<tab[t].size();m++){ tab[t][m]=gravitefinal(destruction(tab))[t][m]; } } } return tab; } /** fonction compte les points du tours @param le tableau des scores @return le score de ce tours **/ int scorefinal (vector<vector<int>> score){ int sc=0; for (int v=0;v<score[0].size();v++){ sc+=10*score[0][v]*(pow(4,score[3][v])+pow(3,score[2][v])); } return sc; } ``` nouvelle essaie de cherche ligne ```` string puyo; if (tab [l][2]=="."){ indice[0]=15; return indice; }else{ puyo=tab[l][2]; } int debut; int fin=0; if (puyo==tab[l][0] and tab[l][1]==puyo){ debut=0; }else if (puyo==tab[l][1]){ debut=1; }else { debut=2; } for (int i=3;i<tab[l].size();i++){ if (puyo=tab[l][i]){ fin=i; }else{ break(); } } if ((fin-debut) <3){ indice[0]=15; }else{ indice [0]=debut; indice [1]=fin; } } ```` Pour les fct de la règne 1 ``` void scorefinaltest (){ vector<vector<int>> score ={{0,0,0,0,0,0,0},{1,2,1,2,1,2,0},{1,0,1,0,1,0,195}}; vector<vector<int>> score1={{0,0},{0,0,0},{0,0}}; vector<vector<int>> score2={{0,4,5,6,5,7},{0,2,2,1,1,1},{0,1,1,2,3,4}}; vector<vector<int>> score3={{4},{},{1}}; ASSERT (scorefinal(score)==0); ASSERT (scorefinal(score1)==0); ASSERT (scorefinal(score2)==23790); ASSERT (scorefinal(score3)==0); } void chercheligne() { tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; vector<int>t={0,3}; ASSERT(chercheligne(11,grille)==t); } void cherchecolonnetest(){ tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][3]="B"; grille [10][3]="M"; grille [9][3]="M"; grille [8][3]="M"; grille [7][3]="M"; grille [6][3]="M"; vector<int>t={6,10}; ASSERT (cherchecolonne(3,grille)==t ); } void comparaisontest (){ tableau t={{"a","b","n"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; tableau t2={{"a","b","n"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; tableau t3={{"a","b","c"},{"c","i","o"},{"p","m","k"},{"a","b","n"}}; ASSERT (comparaison(t,t2)==false); ASSERT (comparaison(t,t3)==true); } void destructiontest (){ tableau grille; tableau fin (12); grille =tableau (12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; fin[11][4]="M"; fin[11][5]="M"; ASSERT(destruction(grille)==fin); } void tableauscoreETrechercheETfintourtest (){ tableau grille; tableau fin ; grille =tableau (12); fin=tableau(12); for ( int i = 0 ; i < grille.size(); i++ ){ grille[i]=vector<string> (6); fin[i]=vector<string> (6); for ( int j = 0; j < grille[i].size(); j++ ) { grille[i][j] = "."; fin[i][j] = "."; } } grille [11][0]="B"; grille [11][1]="B"; grille [11][2]="B"; grille [11][3]="B"; grille [11][4]="M"; grille [11][5]="M"; grille [10][2]="V"; grille [10][3]="J"; grille [10][4]="M"; grille [10][5]="M"; grille [9][2]="M"; grille [9][3]="M"; grille [9][4]="J"; grille [9][5]="J"; grille [8][2]="J"; grille [8][3]="J"; fin [11][2]="V"; fin [11][3]="J"; fin [11][4]="M"; fin [11][5]="M"; vector<vector<int>> h={{0,4,4,4},{0,1,2,2},{0,1,2,2}}; vector<vector<int>> t={{0},{0},{0}}; vector<vector<int>> tab ={{0,4},{0,1},{0,1}}; ASSERT(tableauscore(grille)==h ); ASSERT (fintour(h,grille)==fin); ASSERT (recherche(1,t,grille)==tab); } int main (){ scorefinaltest(); tableauscoreETrechercheETfintourtest(); destructiontest(); comparaisontest(); chercheligne(); cherchecolonnetest(); return 0; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully