Skip to content
Snippets Groups Projects
Commit 36ce29c3 authored by Alexandre 2n's avatar Alexandre 2n
Browse files

fix de la generation des salles

parent 47add08e
Branches
No related tags found
No related merge requests found
No preview for this file type
...@@ -121,36 +121,61 @@ class Labyrinthe extends Program{ ...@@ -121,36 +121,61 @@ class Labyrinthe extends Program{
String droite = substring(check,4,8); String droite = substring(check,4,8);
String bas = substring(check,8,12); String bas = substring(check,8,12);
String gauche = substring(check,12,16); String gauche = substring(check,12,16);
if(i==0){
haut = "0000";
}
if(i==length(lab,1)-1){
bas = "0000";
}
if(j==0){
gauche = "0000";
}
if(j==length(lab,2)-1){
droite="0000";
}
println(haut);
println(droite);
println(bas);
println(gauche);
if(charAt(haut,2)=='1'){ if(charAt(haut,2)=='1'){
resultat=resultat+'1'; resultat=resultat+'1';
}else if(charAt(haut,2)=='0'){
resultat=resultat+'0';
}else{resultat=resultat+'.';} }else{resultat=resultat+'.';}
if(charAt(droite,3)=='1'){ if(charAt(droite,3)=='1'){
resultat=resultat+'1'; resultat=resultat+'1';
}else if(charAt(droite,3)=='0'){
resultat=resultat+'0';
}else{resultat=resultat+'.';} }else{resultat=resultat+'.';}
if(charAt(bas,0)=='1'){ if(charAt(bas,0)=='1'){
resultat=resultat+'1'; resultat=resultat+'1';
}else if(charAt(bas,0)=='0'){
resultat=resultat+'0';
}else{resultat=resultat+'.';} }else{resultat=resultat+'.';}
if(charAt(gauche,1)=='1'){ if(charAt(gauche,1)=='1'){
resultat=resultat+'1'; resultat=resultat+'1';
}else if(charAt(gauche,1)=='0'){
resultat=resultat+'0';
}else{resultat=resultat+'.';} }else{resultat=resultat+'.';}
//println(resultat); println(resultat);
int nbalea=(int)(random()*10); int nbalea=(int)(random()*10);
while(!equals(salles[nbalea].sorties,choixAlea(resultat))){ while(!equals(salles[nbalea].sorties,choixAlea(resultat))){
print("Salle vérifier : ");
println(salles[nbalea].sorties);
nbalea=(int)(random()*10); nbalea=(int)(random()*10);
//println(nbalea); //println(nbalea);
} }
lab[i][j]=salles[nbalea]; lab[i][j]=salles[nbalea];
println("FINI");
} }
String choixAlea(String chaine){ String choixAlea(String chaine){
for(int a = 0; a<4;a++){ for(int a = 0; a<4;a++){
if(charAt(chaine,a)=='E'){
chaine=substring(chaine,0,a)+0+substring(chaine,a+1,length(chaine));
}
if(charAt(chaine,a)=='.'){ if(charAt(chaine,a)=='.'){
chaine=substring(chaine,0,a)+(int)(random()*2)+substring(chaine,a+1,length(chaine)); chaine=substring(chaine,0,a)+(int)(random()*2)+substring(chaine,a+1,length(chaine));
} }
} }
println(chaine);
return(chaine); return(chaine);
} }
...@@ -445,7 +470,7 @@ class Labyrinthe extends Program{ ...@@ -445,7 +470,7 @@ class Labyrinthe extends Program{
afficheLab(salle); afficheLab(salle);
} }
void algorithm(){ void algorithm(){
Salle[][] lab = genererLab(5); //genere le Layrinthe Salle[][] lab = genererLab(3); //genere le Layrinthe
String[][] questionTemp = load("ressources/ListeQuestion.csv"); String[][] questionTemp = load("ressources/ListeQuestion.csv");
print("Voulez vous ajouter des question ? oui (o), non (autre) : "); print("Voulez vous ajouter des question ? oui (o), non (autre) : ");
boolean ques = equals(toLowerCase(readString()), "o"); boolean ques = equals(toLowerCase(readString()), "o");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment