/*
* sucht nach einem Nachbarfeld zu [zeile][spalte] mit
* der Belegung `feldtyp';
* falls erfolgreich (Return-Wert TRUE),
* wird in x und y die Nachbarposition abgelegt
*/
int suche(int zeile, int spalte, char feldtyp, int *x, int *y)
{ int anzahl; /* Anzahl der Moeglichkeiten */
int i;
int nx[RICHTUNGEN], ny[RICHTUNGEN]; /* Nachbarfelder */
anzahl = 0;
anzahl += teste(zeile-1, spalte , feldtyp, nx, ny, anzahl);
anzahl += teste(zeile , spalte-1, feldtyp, nx, ny, anzahl);
anzahl += teste(zeile , spalte+1, feldtyp, nx, ny, anzahl);
anzahl += teste(zeile+1, spalte , feldtyp, nx, ny, anzahl);
if (anzahl) {
i = random(0, anzahl-1);
* x = nx[i];
* y = ny[i];
return TRUE;
} else
return FALSE;
}
|