- function CalculateNextStep(S,G,AP,PP: Byte): smallint;
- var
- i: Integer;
- B: Smallint;
- begin
- CalculatePossibilitys(@Sets[S-1,G],@Sets[S],AP,PP);
- if S=N then begin
- if (S/2)=Trunc(S/2) then begin
- result:=100;
- for i := 1 to Sets[S-1,G].Possibilitys do begin
- if Sets[S,i].Balance<result then begin
- result:=Sets[S,i].Balance;
- end;
- end
- end else begin
- result:=-100;
- for i := 1 to Sets[S-1,G].Possibilitys do begin
- if Sets[S,i].Balance>result then
- result:=Sets[S,i].Balance;
- end
- else result:=-99;
- end;
- end else begin
- if (S/2)=Trunc(S/2) then begin
- result:=100;
- for i := 1 to Sets[S-1,G].Possibilitys do begin
- B:=CalculateNextStep(S+1,i,PP,AP); /// selbstaufruf!!!
- if (B<result) and (B<>-100) then begin
- result:=B;
- end;
- end
- end else begin
- result:=-100;
- for i := 1 to Sets[S-1,G].Possibilitys do begin
- B:=CalculateNextStep(S+1,i,PP,AP); /// selbstaufruf!!!
- if (B>result) and (B<>100) then begin
- result:=B;
- end;
- end
- end;
- end;
- end;