diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2c3fd7a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc-11 build active file", + "command": "/usr/bin/gcc-11", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/src/Umgebung b/src/Umgebung new file mode 100755 index 0000000..50b1912 Binary files /dev/null and b/src/Umgebung differ diff --git a/src/Umgebung.c b/src/Umgebung.c index 4c0330b..62185cc 100644 --- a/src/Umgebung.c +++ b/src/Umgebung.c @@ -139,4 +139,43 @@ void Apfel(int realU[N][N]){ re; } } -} \ No newline at end of file +} + + + +int lose(int realU[N][N], int realU1[N-1][N-1], 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 (realU1[i][j] > groesste){ + groesste = realU1[i][j]; + ii = i; + jj = j; + } + } + } + if(richtung == 'u'){ + if(realU[ii - 1][jj] != 0){ + return 1; + } + } + if(richtung == 'd'){ + if(realU[ii + 1][jj] != N){ + return 1; + } + } + if(richtung == 'l'){ + if(realU[ii][jj-1] != 0){ + return 1; + } + } + if(richtung == 'r'){ + if(realU[ii][jj + 1] > N){ + return 1; + } + } + return 0; + + +} \ No newline at end of file