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
| int maxi = 0, counter = 0, tempmaxi, j, n, length, oldmaxi;
int tabLength[Q];
for(int i = 0; i < Q; i++) {
p_Piece p_piece = &(p_grid->pieces[player][i]);
p_Case p_case = getCase(p_grid, p_piece->x, p_piece->y);
n = getPossibilities(p_grid, p_case, true);
if(n == 0) {
tabLength[i] = 0;
continue;
}
tempmaxi = 0;
for(j = 0; j < n; j++) {
length = getLengthOfTree(p_case->move->nextmoves[j]) + 1;
tempmaxi = max(tempmaxi, length);
}
tabLength[i] = tempmaxi;
oldmaxi = maxi;
maxi = max(maxi, tempmaxi);
// Si le maximum a changer on réinitialise le compteur
if(oldmaxi < maxi)
counter = 1;
// Sinon si l'élément était égal au maximum, on incrémente le compteur
else if(tempmaxi == oldmaxi)
counter++;
} |
Partager