1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45:
| function WaterScan(row,col,depth;integer;plPos:tPosition):tposition; var PosA,Posb,PosC,PosD:tPosition;
begin inc(depth);
PosA:=MakePos(-1,-1); PosB:=MakePos(-1,-1); posc:=MakePos(-1,-1); posd:=MakePos(-1,-1);
if Walkable2(row+1,col) and (depth<4) then if IsWasser(row+1,col) then PosA:=MakePos(row+1,col) else PosA:=WaterScan(row+1,col,depth,plpos); if Walkable2(row-1,col) and (depth<4) then if IsWasser(row-1,col) then posb:=MakePos(row-1,col) else posb:=WaterScan(row-1,col,depth,plpos);
if Walkable2(row,col+1)and (depth<4) then if IsWasser(row,col+1) then posc:=MakePos(row,col+1) else posc:=WaterScan(row,col+1,depth,plpos);
if Walkable2(row,col-1)and (depth<4) then if IsWasser(row,col-1) then posd:=MakePos(row,col-1); else posd:=WaterScan(row,col-1,depth,plpos,f);
WaterScan:=NearerPos(posa,NearerPos(posb,NearerPos(posc,posd,plpos),plpos),plpos);
end; |