Bonjour,

je dois développer "le jeu de la vie" en shell, ce jeu consiste à faire évoluer des cellules (vivantes et mortes), en fonction du nombre de cellules vivantes autour d'une cellule, celle-ci naît ou meurt, ou reste vivante.

Mon premier problème vient du fait qu'il ne m'accepte pas mes comparaison suivantes :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
if test $j -eq 131
 
if [ $autour -eq 3 ]
Donc j'aimerais savoir si j'ai fait une erreur d'écriture.

Pour mieux comprendre le projet, je vous mets le code entier, car je n'arrive totalement à mon but, puisque mon nombre de cellule vivante n'augmente pas, pourriez-vous aussi voir si mes condition sont bonnes, enfin bien disposées ?

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
157
158
159
160
161
#!\bin\sh
 
i=0
vivante=0
generation=0
 
j=0
for ligne in `cat gen0.txt` 
do
	for i in 0 1 2 3 4 5 6 7 8 9 10 11
	do
	car=${ligne:i:1}
	tableau[$j]=$car
	j=$(($j+1))
	done
 
done
 
 
for ((j=13;j<132;j++))
	do
	if test ${tableau[$j]} == .
		then vivante=$(($vivante+1))
	fi	
 
	done
 
 
 
while test $vivante -gt 0
	do
 
j=13
vivante=0
 
for ((j=13;j<132;j++)) 
	do
 
 
	if test ${tableau[$j]} != /
 
		then
 
		if test ${tableau[$j-13]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j-12]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j-11]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j-1]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j+1]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j+11]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j+12]} == "."
			then autour=$(($autour+1))
		fi
		if test ${tableau[$j+13]} == "."
			then autour=$(($autour+1))
		fi
	fi
 
 
	case ${tableau[$j]} in
 
	".") if [ $autour -gt 1 ] && [ $autour -lt 4 ]
			then tableau[$j]="."
                else
				tableau[$j]="_"
	     fi
	;;
 
	"_") if [ $autour -eq 3 ]
			then tableau[$j]="."
	     fi
	;;
	esac
 
 
	if test $j -eq 131
		then
 
	for ((j=13;j<23;j++))
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=25;j<35;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=37;j<47;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=49;j<59;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=61;j<71;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=73;j<83;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=85;j<95;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=97;j<107;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=109;j<119;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
	for ((j=121;j<131;j++)) 
	do
	echo  "${tableau[j]}"
	done
 
                  generation=$(($generation+1))
		     for ((j=0;j<132;j++))
			 do
			   if test ${tableau[$j]} == "."
				  then vivante=$(($vivante+1))
			   fi
			done
 
	echo "nombre de vivantes : $vivante"
	echo -n "generation numéro : $generation"
 
    fi
 
if test $generation == 20
	then exit 0
fi
 
 
done
 
autour=0
done

Merci d'avance car je suis débutant, et je bloque toujours sur des petites erreurs ...

Bonne soirée.