|
@ -59,34 +59,38 @@ int win(int realU[N][N]){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Die Funktion gibt bei verlorenem Spiel 1 zurück |
|
|
|
|
|
// Das Spiel ist verloren wenn die Schlange den Spielbereich verlässt |
|
|
|
|
|
//oder sich selbst trifft |
|
|
int lose(int realU[N][N], char richtung){ |
|
|
int lose(int realU[N][N], char richtung){ |
|
|
|
|
|
|
|
|
int ii = sucheXWert(realU); |
|
|
int ii = sucheXWert(realU); |
|
|
int jj = sucheYWert(realU); |
|
|
int jj = sucheYWert(realU); |
|
|
|
|
|
|
|
|
if (richtung == 'u') { |
|
|
|
|
|
|
|
|
switch(richtung){ |
|
|
|
|
|
case 'u': |
|
|
if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) { |
|
|
if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else if (richtung == 'd') { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'd': |
|
|
if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) { |
|
|
if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else if (richtung == 'l') { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'l': |
|
|
if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) { |
|
|
if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) { |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'r': |
|
|
if (realU[ii][jj + 1] != (N*N) + 1 && realU[ii][jj + 1] != 0) { |
|
|
if (realU[ii][jj + 1] != (N*N) + 1 && realU[ii][jj + 1] != 0) { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*int update(int realU[N][N],char richtung) { |
|
|
/*int update(int realU[N][N],char richtung) { |
|
|
|
|
|
|
|
|