Bonjour,
J'ai un problème avec OpenList et ClosedList. Je ne comprend pas trop.
J'ai besoins d'aide pour terminer le programme.
Je voudrais intégrer OpenList et ClosedList dans le programme. je ne sais pas comment faire.

Merci beaucoup


j’utilise cette méthode :
Pièce jointe 482080

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
// ----------------------------------------------------------------------------------------------------------------------------
void CIa::Init(int Player, int x0, int y0, int x1, int y1)
{
	// Init G H et F
	for(int i=0; i<100; i++)
		for(int j=0; j<100; j++) 
		{
			G[i][j]=0;
			H[i][j]=0; 
			F[i][j]=0; 
		}
 
		for(int j=0; j<100; j++) Sav_xy[Player][j]=0; // Init. la mémorisation des déplacements trouvés
		endi=0;
 
	Ia1(Player,x0,y0,x1,y1);
}
// ----------------------------------------------------------------------------------------------------------------------------
void CIa::Ia1(int Player, int x0, int y0, int x1, int y1)
{
	Sav_xy[Player][1]=x0;
	Sav_xy[Player][2]=y0;
	Sav_xy[Player][3]=0;
	endi=0;
	for (int i=1; i<100; i++)
	{ 
		if(x0!=x1 || y0!=y1)
		{
			Ia0(x0,y0,x1,y1);
 
			x0=MemX0;
			y0=MemY0;
			// Mémorise les déplacements avec l'angle
			Sav_xy[Player][i*3+1]=x0;
			Sav_xy[Player][i*3+2]=y0;
			Sav_xy[Player][i*3+3]=MemAng;
			endi=i;
		}
	}
	Sav_xy[Player][0]=endi;
}
// ----------------------------------------------------------------------------------------------------------------------------
void CIa::Ia0(int x0, int y0, int x1, int y1)
{
if(Map_liste[x0-1][y0+1]==0) {G[x0-1][y0+1]+=14; F[x0-1][y0+1]=G[x0-1][y0+1]+10*(abs(x1-(x0-1.0)) + abs(y1-(y0+1.0))); distance[1]=F[x0-1][y0+1];}
if(Map_liste[x0][y0+1]==0)   {G[x0][y0+1]+=10;   F[x0][y0+1]  =G[x0][y0+1]  +10*(abs(x1-x0)       + abs(y1-(y0+1.0))); distance[2]=F[x0][y0+1];}
if(Map_liste[x0+1][y0+1]==0) {G[x0+1][y0+1]+=14; F[x0+1][y0+1]=G[x0+1][y0+1]+10*(abs(x1-(x0+1.0)) + abs(y1-(y0+1.0))); distance[3]=F[x0+1][y0+1];}
if(Map_liste[x0-1][y0]==0)   {G[x0-1][y0]+=10;   F[x0-1][y0]  =G[x0-1][y0]  +10*(abs(x1-(x0-1.0)) + abs(y1-y0));   distance[4]=F[x0-1][y0];}
if(Map_liste[x0+1][y0]==0)   {G[x0+1][y0]+=10;   F[x0+1][y0]  =G[x0+1][y0]  +10*(abs(x1-(x0+1.0)) + abs(y1-y0));    distance[6]=F[x0+1][y0];}
if(Map_liste[x0-1][y0-1]==0) {G[x0-1][y0-1]+=14; F[x0-1][y0-1]=G[x0-1][y0-1]+10*(abs(x1-(x0-1.0)) + abs(y1-(y0-1.0))); distance[7]=F[x0-1][y0-1];}
if(Map_liste[x0][y0-1]==0)   {G[x0][y0-1]+=10;   F[x0][y0-1]  =G[x0][y0-1]  +10*(abs(x1-x0)       + abs(y1-(y0-1.0))); distance[8]=F[x0][y0-1];}
if(Map_liste[x0+1][y0-1]==0) {G[x0+1][y0-1]+=14; F[x0+1][y0-1]=G[x0+1][y0-1]+10*(abs(x1-(x0+1.0)) + abs(y1-(y0-1.0))); distance[9]=F[x0+1][y0-1];}
 
//////////////////////////////////
 
float distanceMin=1000000.0;
float ang=0;
 
if(Map_liste[x0-1][y0+1]==0 && distance[1]<=distanceMin) {distanceMin=distance[1]; ang=1;}
if(Map_liste[x0][y0+1]==0   && distance[2]<=distanceMin) {distanceMin=distance[2]; ang=2;}   
if(Map_liste[x0+1][y0+1]==0 && distance[3]<=distanceMin) {distanceMin=distance[3]; ang=3;}
if(Map_liste[x0-1][y0]==0   && distance[4]<=distanceMin) {distanceMin=distance[4]; ang=4;} 
if(Map_liste[x0+1][y0]==0   && distance[6]<=distanceMin) {distanceMin=distance[6]; ang=6;}  
if(Map_liste[x0-1][y0-1]==0 && distance[7]<=distanceMin) {distanceMin=distance[7]; ang=7;}
if(Map_liste[x0][y0-1]==0   && distance[8]<=distanceMin) {distanceMin=distance[8]; ang=8;}  
if(Map_liste[x0+1][y0-1]==0 && distance[9]<=distanceMin) {distanceMin=distance[9]; ang=9;}
 
 
 if(ang==1) {x0--; y0++;    MemAng=45;}
else if(ang==2) {      y0++;    MemAng=0;}
else if(ang==3) {x0++; y0++; MemAng=315;}
else if(ang==4) {x0--;		 MemAng=90;}
else if(ang==6) {x0++;		 MemAng=270;}
else if(ang==7) {x0--; y0--;	MemAng=135;}
else if(ang==8) {      y0--;	MemAng=180;}
else if(ang==9) {x0++; y0--;  MemAng=225;}
 
Map_liste[x0][y0]=1;
 
MemX0=x0;
MemY0=y0;
}
// ----------------------------------------------------------------------------------------------------------------------------