I'm facing a problem with negamax. Think it comes from my eval function but i'm not sure at all.

First, can you tell me if my negamax and his call are ok ?

Because i don't find any solution, even if i read a lot about it these days.

Before showing you the code, i have to tell you that my verification function is based on (x,y) position (correspond to the last coin inserted with X = column and Y = line). Is this a portable method with negamax/alpha-beta or do i have to check the entire grid ?

Here is my negamax function:

int IA_NegaMaxAlphaBeta(int profondeur, int alpha, int beta, int grille[LIGNES][COLONNES], int emplacements[COLONNES], int colonne, int emplacement, int joueur) { int x = COLONNES/2, y, i, k = 1; if (profondeur == 0) { return IA_Evaluation(grille, emplacements, colonne, emplacement, joueur); } if (check(grille, emplacements, colonne, emplacement, joueur) == 4) { if (joueur == 0) { return -1000; } return 1000; } if (GrillePleine(emplacements)) { return 0; } for(i = 0; i < COLONNES && alpha < beta; i++) { // EFFICACITE: Balayer les colonnes du milieu vers l'extérieur (alternativement gauche/droite) x += i*k; k = -k; if (emplacements[x] > -1) { y = InsererJeton(grille, emplacements, x, joueur); alpha = max(alpha, -IA_NegaMaxAlphaBeta(profondeur-1, -beta, -alpha, grille, emplacements, x, y, joueur^1)); AnnulerJeton(grille, emplacements, y, x); } } return alpha; }

Is there something wrong in it ?

And here comes my negamax call:

int x = COLONNES/2, y, i, k = 1, scoreCoup, scoreMeilleur = -1000000, col = -1; for(i = 0; i < COLONNES; i++) { // EFFICACITE: Balayer les colonnes du milieu vers l'extérieur (alternativement gauche/droite) x += i*k; k = -k; if (emplacements[x] > -1) { y = InsererJeton(grille, emplacements, x, joueur); scoreCoup = IA_NegaMaxAlphaBeta(4, -100000, 100000, grille, emplacements, colonne, emplacement, joueur); if (scoreCoup > scoreMeilleur) { scoreMeilleur = scoreCoup; col = x; } AnnulerJeton(grille, emplacements, y, x); } }

If you want to see my eval function, just ask. I don't show it right now because there are maybe errors in my negamax.

Oh and by the way... Sorry for my english if i made mistakes ! I'm from Belgium

Thanks in advance for your help !