|
@ -59,33 +59,37 @@ 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') { |
|
|
|
|
|
if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) { |
|
|
|
|
|
|
|
|
switch(richtung){ |
|
|
|
|
|
case 'u': |
|
|
|
|
|
if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (richtung == 'd') { |
|
|
|
|
|
if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'd': |
|
|
|
|
|
if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) { |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (richtung == 'l') { |
|
|
|
|
|
if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'l': |
|
|
|
|
|
if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) { |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
if (realU[ii][jj + 1] != (N*N) + 1 && realU[ii][jj + 1] != 0) { |
|
|
|
|
|
|
|
|
case 'r': |
|
|
|
|
|
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) { |
|
|