You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
1.7 KiB
88 lines
1.7 KiB
#define _CRT_SECURE_NO_WARNINGS // to write faster
|
|
#define re return
|
|
#define N 20 // size of Play Field
|
|
#include<stdio.h>
|
|
#include<string.h>
|
|
#include<stdlib.h>
|
|
#include<time.h>
|
|
#include<stdbool.h>
|
|
|
|
int speed = 0;
|
|
|
|
int win(int realU[N][N]){
|
|
int groesste = 0;
|
|
for(int i = 0; i < N; i++){
|
|
for(int j = 0; j < N; j++){
|
|
if(realU[i][j] > groesste && realU[i][j] != (N * N ) + 1){
|
|
groesste = realU[i][j];
|
|
}
|
|
}
|
|
}
|
|
if(groesste == (N * N) - 1){
|
|
return 1;
|
|
}
|
|
else{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
//Die Funktion überprüft, ob das Feld bereits vom Schlangenkoerper besetzt ist.
|
|
int feldFrei(int realU[N][N], int ii, int jj){
|
|
if (realU[ii][jj] == 0)
|
|
{
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int lose(int realU[N][N], char richtung){
|
|
int groesste = 0; //Suche den Kopf der Schlange
|
|
int ii, jj;
|
|
for(int i = 0; i < N ; i++){
|
|
for(int j = 0; j < N; j++){
|
|
if (realU[i][j] > groesste && realU[i][j] != (N * N) + 1){
|
|
groesste = realU[i][j];
|
|
ii = i;
|
|
jj = j;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (richtung == 'u') {
|
|
if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) {
|
|
return 1;
|
|
}
|
|
}
|
|
else if (richtung == 'd') {
|
|
if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) {
|
|
return 1;
|
|
}
|
|
}
|
|
else if (richtung == 'l') {
|
|
if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) {
|
|
return 1;
|
|
|
|
}
|
|
}
|
|
else {
|
|
if (realU[ii][jj + 1] != (N*N) + 1 && realU[ii][jj + 1] != 0) {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int update(int realU[N][N],char richtung) {
|
|
int groesste = 0;
|
|
int ii, jj;
|
|
for(int i = 0; i < N; i++) {
|
|
for(int j = 0; j < N; j++) {
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int probe(int input){
|
|
return input;
|
|
}
|