From 565f8ecaaf6faea718784b42c64594d0b6f50471 Mon Sep 17 00:00:00 2001 From: Emman Mensdorf Date: Thu, 8 Feb 2024 12:07:26 +0100 Subject: [PATCH] =?UTF-8?q?Puzzle.c=20koenig=20sucher=20erg=C3=A4nzt,=20Em?= =?UTF-8?q?man=20Mensdorf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schach_in_ein_puzzle/PuzzleI.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/schach_in_ein_puzzle/PuzzleI.c b/src/schach_in_ein_puzzle/PuzzleI.c index 8d6f5d8..e011acd 100644 --- a/src/schach_in_ein_puzzle/PuzzleI.c +++ b/src/schach_in_ein_puzzle/PuzzleI.c @@ -71,4 +71,29 @@ void Puzzlebrettspeicher_freigeben(char** Brett) { } free(Brett); +} + +bool loesung_abchecken(char** Brett) { + // checke nach dem gegnerischen König (kleines 'k') ab + int koenig_X = -1, koenig_Y = -1; + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + if (Brett[i][j] == 'k') { + koenig_X = i; + koenig_Y = j; + break; + } + } + if (koenig_X != -1 && koenig_Y != -1) { + break; + } + } + + // Überprüfe, ob der gegnerische König schachmatt auf dem feld + if (koenig_X == -1 || koenig_Y == -1) { + // König nicht gefunden -> error + return false; + } + + } \ No newline at end of file