Correction génération

master
yasevret 4 years ago
parent fbd76d4ad6
commit 0722d8970c

@ -586,17 +586,17 @@ function creaMatrice(row, column) {
var Cox1, Coy1, Cox2, Coy2; var Cox1, Coy1, Cox2, Coy2;
Cox1 = getRandom(0, 2); Cox1 = getRandom(0, column - 1);
Coy1 = getRandom(0, 3); Coy1 = getRandom(0, row - 1);
myMatrice[Cox1][Coy1] = 1; myMatrice[Cox1][Coy1] = 1;
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, column - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, row - 1);
while (Cox2 == Cox1 && Coy1 == Coy2) { while (Cox2 == Cox1 && Coy1 == Coy2) {
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, column - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, row - 1);
} }
myMatrice[Cox2][Coy2] = 2; myMatrice[Cox2][Coy2] = 2;
@ -663,7 +663,7 @@ function chercherCombinaison() {
} }
function test() { function test() {
printCombinations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 3); printCombinations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 12);
} }
function printCombinations(array, p) { function printCombinations(array, p) {
@ -684,9 +684,9 @@ function printCombinations(array, p) {
for (var j = 0; j < combinations.length; j++) { for (var j = 0; j < combinations.length; j++) {
combTest.push(deckPartie[combinations[j]]); combTest.push(deckPartie[combinations[j]]);
//window.alert("Matrice ajouté num" + j + " :" + deckPartie[combinations[j]].getMatrice); //window.alert("Matrice ajouté num" + j + " :" + deckPartie[combinations[j]].getMatrice);
//console.log("i"+j +" :"+ combinations[j]); console.log("i"+j +" :"+ combinations[j]);
} }
//console.log("matrice début ex: "+combTest[0].getMatrice); console.log("matrice début ex: "+combTest[0].getMatrice);
console.log("Cartes selectionnées :(en partant de indice 0) :") console.log("Cartes selectionnées :(en partant de indice 0) :")
console.log(combinations.join(" ")); console.log(combinations.join(" "));
console.log("----- taille :" + combTest.length + " -------"); console.log("----- taille :" + combTest.length + " -------");
@ -697,6 +697,7 @@ function printCombinations(array, p) {
} }
} }
run(0, 0); run(0, 0);
window.alert("fin test " + k + " cartes" )
} }
window.alert("nb combi :" + Cptsolution); window.alert("nb combi :" + Cptsolution);
} }

Loading…
Cancel
Save