ich würde etwas in dieser Art verwenden:
Delphi-Quellcode:
Function CheckField(Const Field : Array Of Array Of Byte;Const SameCoinCount : Byte) : Byte;
// Return value: 0 or ID of winning player
Function CheckRow(Const Row : Byte) : Byte;
Var
X,
Coin,
Count : Byte;
Begin
X:=0;
While (X <= Length(Field[Row]) - SameCoinCount) Do Begin
Coin:=Field[Row,X];
If (Coin = 0) Then Begin
Inc(X);
Continue;
end;
Count:=1;
While (X + Count < Length(Field[Row])) and (Field[Row,X + Count] = Coin) Do Inc(Count);
If (Count >= SameCoinCount) Then Begin
Result:=Coin;
Exit;
end;
Inc(X,Count);
end;
Result:=0;
end;
Var
X : Byte;
Begin
For X:=1 To Length(Field) Do Begin
Result:=CheckRow(X - 1);
If (Result > 0) Then Exit;
end;
Result:=0;
end;
(Analog dazu CheckColumn)