bonjour,

Ca fait une semaine que j'essaye sans succes à coder la fonction minmax pour le jeu othello. J'aimerais vraiment que quelqu'un me dise ce qui ne va pas dans ma fonction minimax.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
 
const int dim = 8;
const int Noir = 1;
const int Blanc = 0;
const int Vide = -1;
const int Egal =5;
define INFINI 100000
 
 
 
typedef struct
{
    int x;
    int y;
}Coordonnees;
 
int inverser_couleur(int couleur)
{
    if (couleur == Noir) return Blanc; else return Noir;
}
 
void jouer_coup(int couleur,Coordonnees pos,int othellier[dim][dim])
{
    int score ;
    othellier[pos.x][pos.y]=couleur;
    score=jouer_et_retourner(couleur,pos,othellier) ;
 
}
 
void dejouer_coup(int couleur,Coordonnees pos,int othellier[dim][dim])
{
    othellier[pos.x][pos.y]=Vide ;
 
}
 
 
int minimax(int couleur,int profondeur,int *bestI,int *bestJ,int othellier[dim][dim])
{
 
    int adversaire = inverser_couleur(couleur);
     Coordonnees pos ;
 
	/*if(check == Noir) { //Si le ordinateur gagne, c'est la fête
		return 100;
	} else if(check == adversaire)	{	//Si l'ordinateur perd, c'est triste :(
		return -100;
	}  else if(check == Egal || profondeur == 0) {	//Si il y a égalité ou que l'on est assez profond, alors ça ne fait rien
		return 0;
	}*/
 
	int i,j;
 
	int max =-INFINI;
	int min=INFINI ;
	int truc = 0;	//variable temporaire qui permet de voir les résultats
 
if(couleur == 1)
{
	for(i=0;i<1;i++)
	{
		for(j=0;j<1;j++)
		{
		    pos.x=i ;
            pos.y=j ;
            if(othellier[i][j]!=1 && othellier[i][j]!=0)
            {
				 //Max
 
				    jouer_coup(couleur,pos,othellier) ;
				    afficher_othellier(othellier) ;
 
					truc = minimax(couleur,profondeur-1,&pos.x,&pos.y,othellier);
 
 
					if(truc >= max)
					{
					    max = truc;
					    *bestI=i ;
					    *bestJ=j ;
 
 
					}
 
                    dejouer_coup(couleur,pos,othellier) ;
                    afficher_othellier(othellier);
 
				}
 
		}
 
 
	}
        couleur=adversaire  ;
 
   return max ;
 
}
else
{
 
    for(i=0;i<1;i++)
    {
 
		for(j=0;j<1;j++)
		{
		    pos.x=i ;
                     pos.y=j ;
	 //Min
 
		 jouer_coup(couleur,pos,othellier) ;
		afficher_othellier(othellier) ;
 
		truc =minimax(couleur,profondeur-1,&pos.x,&pos.y,othellier);
 
					if(truc < min)
					{
					    min = truc;
                                            *bestI=i ;
					    *bestJ=j ;
					}
 
					dejouer_coup(couleur,pos,othellier) ;
					afficher_othellier(othellier) ;
					//inverser la couleur;
                                       couleur=adversaire 
 
			}
		}
    return min ;
}
 
 
    othellier[bestI][bestJ] = 1; (1==Noir)
 
 
 
 
return 0 ;
}
 
int main()
{
 if(couleur==1)
            {
 
                int bestI,bestJ  ;
                int valeur=minimax(couleur,2,&bestI,&bestJ,othellier) ;
            }
 
 
else{//c'est au joueur humain de jouer(ce qui marche tres bien)}
 
 
 
    return 0;
}
alors dans mon fonction minimax je n'arrive pas à rentrer dans la boucle else ni à avoir une valeur de max ou min differente de l'infini ou -infini


svp aidez moi j'ai beau chercher je ne vois pas pourquoi ca ne marche pas.

Merci d'avance à ceux qui prendront le temps de m'aider