1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| bool Solitaire::solution() {
unsigned a,b,c;
cout<<" 0.0 ";
vector<position>::iterator it1;
cout<<" 0.1 ";
vector<position> temp = mouvementRestant.top();
cout<<" 0.2 ";
mouvementRestant.pop();
cout<<" 0.3 ";
if(nombrePion == 1) {
return true;
}else {
cout<<" 2 ";
for(it1=temp.begin();it1!=temp.end();it1++) {
a = (*it1).depart;
b = (*it1).milieu;
c = (*it1).arrive;
if( mouvement(a,b,c) ) {
cout<<" 3 ";
enleverPion(a,b,c);
mouvementSucces.push(*it1);
temp.erase(it1);
mouvementRestant.push(temp);
mouvementRestant.push(mouvementPossible);
//cout<<"nombre de pion "<<nombrePion<<" taille pileRestant: "<<mouvementRestant.size()<<" taille pileSucces : "<<mouvementSucces.size()<<endl;
solution();
}
}
cout<<" 4 ";
a = mouvementSucces.top().depart;
cout<<" 5 ";
b = mouvementSucces.top().milieu;
cout<<" 6 ";
c = mouvementSucces.top().arrive;
cout<<" 7 ";
annuler(a,b,c);
cout<<" 8 ";
//cout<<a<<" "<<b<<" "<<c<<endl;
mouvementSucces.pop();
cout<<" 9 ";
solution();
}
cout<<" 5 ";
return false;
}
//partie pour comprendre le code
struct position {
unsigned depart;
unsigned milieu;
unsigned arrive;
};
unsigned nombrePion;
vector<pair<unsigned, list<pair<unsigned, char> > > >matriceLien;
vector<bool> pion;
vector<position> mouvementPossible;
stack<position> mouvementSucces;
stack<vector<position> > mouvementRestant;
stack<vector<bool> > pileEchiquier; |
Partager