123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- unit UCheckmaze;
- interface
- uses Unit1;
-
- procedure InitValidate;
- procedure Validate(X,Z:Integer; Height:THeight);
-
- var valid:array [-mapsize..mapsize,-mapsize..mapsize,THeight] of Boolean;
- var validated:array [-mapsize..mapsize,-mapsize..mapsize,THeight] of Boolean;
- var validating:array [-mapsize..mapsize,-mapsize..mapsize,THeight] of Boolean;
- implementation
- uses UCreateRaum;
- procedure InitValidate;
- var C1,C2:Integer;
- C3: THeight;
- begin
- for C1:=-mapsize to mapsize do
- for C2:=-mapsize to mapsize do
- for C3:=Down to Up do begin
- valid[C1,C2,C3]:=false;
- validated[C1,C2,C3]:=false;
- validating[C1,C2,C3]:=false;
- end;
- end;
- function Walkable(FromX,FromZ:Integer; Dir:TRichtung; Height:THeight):Boolean;
- begin
- Result:=not (
- (Dir in Map[FromX,FromZ].Walls)
- or ((Dir in Map[FromX,FromZ].UpWalls) and (Height=Up))
- or ((Dir in Map[FromX,FromZ].DownWalls) and (Height=Down)));
- end;
- procedure Validate(X,Z:Integer; Height:THeight);
- begin
- if not Map[X,Z].created then
- CreateRaum(X,Z);
- if GetRT(X,Z).PortTo[Up] and (Height=Down) then begin
- Height:=Up;
- end;
- if GetRT(X,Z).PortTo[Up] and (Height=Down) then begin
- Height:=Down;
- end;
- if validating[X,Z,Height] then Exit;
- if validated[X,Z,Height] then Exit;
-
- if GetRT(X,Z).WinAtArrival
- then begin
- valid[X,Z,Height]:=true;
- validated[X,Z,Height]:=true;
- Exit;
- end;
- if not GetRT(X,Z).Passierbar then begin
- valid[X,Z,Height]:=false;
- validated[X,Z,Height]:=true;
- Exit;
- end;
- validating[X,Z,Height]:=true;
- if (X<>mapsize)
- and Walkable(X,Z,px,Height) then begin
- Validate(X+1,Z,Height);
- if valid[X+1,Z,Height] then begin
- valid[X,Z,Height]:=true;
- // validated[X,Z,Height]:=true;
- // validating[X,Z,Height]:=false;
- // Exit;
- end;
- end;
- if (X<>-mapsize)
- and Walkable(X,Z,nx,Height) then begin
- Validate(X-1,Z,Height);
- if valid[X-1,Z,Height] then begin
- valid[X,Z,Height]:=true;
- // validated[X,Z,Height]:=true;
- // validating[X,Z,Height]:=false;
- // Exit;
- end;
- end;
- if (Z<>mapsize)
- and Walkable(X,Z,pz,Height) then begin
- Validate(X,Z+1,Height);
- if valid[X,Z+1,Height] then begin
- valid[X,Z,Height]:=true;
- // validated[X,Z,Height]:=true;
- // validating[X,Z,Height]:=false;
- // Exit;
- end;
- end;
- if (Z<>-mapsize)
- and Walkable(X,Z,nz,Height) then begin
- Validate(X,Z-1,Height);
- if valid[X,Z-1,Height] then begin
- valid[X,Z,Height]:=true;
- // validated[X,Z,Height]:=true;
- // validating[X,Z,Height]:=false;
- // Exit;
- end;
- end;
- validated[X,Z,Height]:=true;
- validating[X,Z,Height]:=false;
- Exit;
- end;
- end.
|