Bonjour à tous,
Alors me voilà suite à un petit problème ! J'aimerais réaliser une intelligence artificielle pour mon projet (bataille navale) pour cela si je touche un bateau j'aimerais créer un tableau a deux dimensions contenant les coordonnées des points entourant le point touché !
Pour cela j'ai déjà écrit un morceau de code mais je ne suis vraiment pas sur... (Pour tester ici j'ai choisi de prendre le point G5)

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
 
#include <stdio.h>
#include <stdlib.h>
 
 
int calcul_IA(int ord, int abs)
{
    int i,j;
    int tab[2][4]=
        {
            0
        }
        ;// tableau des coordonnee abscisse / ordonnee initialisé a 0
 
    printf("Le point de coordonnee : %c %c \n",ord,abs);
 
 
    for(i=0;i<4;i++)
    {
        j=0;
        if(i==0 && ord !=0)
        {
            tab[i][j]=abs;
            j++;
            tab[i][j]=ord+1;
        }
        if(i==0 && ord == 0)
        {
            tab[i][j]=abs;
            j++;
            tab[i][j]=11 ;
        }
        if(i==1)
        {
            tab[i][j]=abs+1;
            j++;
            tab[i][j]=ord;
        }
        if(i==2)
        {
            tab[i][j]=abs;
            j++;
            tab[i][j]=ord-1;
        }
        if(i==3)
        {
            tab[i][j]=abs-1;
            j++;
            tab[i][j]=ord;
        }
    }
 
    j=0;
    for(i=0;i<4;i++)
    {
        if(j==0)
        {
            printf("i=%d j=%d => tab : %c \n",i,j,tab[i][j]);
        }
    }
    printf("\n");
    j++;
    for(i=0;i<4;i++)
    {
        if(j==1)
        {
            printf("i=%d j=%d => tab : %c \n",i,j,tab[i][j]);
        }
    }
 
    return tab[2][4];
}
 
int main()
{
int i,j;
int tab[2][4];
int ord,abs;
ord='5';
abs='G';
 
tab[2][4] = calcul_IA(abs,ord);
printf("\n\n");
 
for(i=0;i<4;i++)
    {
        for(j=0;j<2;j++)
        {
            printf("i=%d j=%d => tab : %d \n",i,j,tab[i][j]);
        }
    }
	return 0;
}
Merci d'avance pour votre aide ^^