Added more char constants for TPipeMaze
This commit is contained in:
parent
d1ae6d0404
commit
cbce1ce794
|
@ -26,6 +26,10 @@ uses
|
|||
|
||||
const
|
||||
CStartChar = 'S';
|
||||
CLeftChar = 'l';
|
||||
CRightChar = 'r';
|
||||
CPathChar = '#';
|
||||
CFloodFillChar = '%';
|
||||
|
||||
type
|
||||
TPointArray = array of TPoint;
|
||||
|
@ -221,8 +225,8 @@ end;
|
|||
|
||||
procedure TPipeMaze.CountEnclosureInside;
|
||||
begin
|
||||
if not TryCountEnclosureSide('l', FPart2) then
|
||||
TryCountEnclosureSide('r', FPart2);
|
||||
if not TryCountEnclosureSide(CLeftChar, FPart2) then
|
||||
TryCountEnclosureSide(CRightChar, FPart2);
|
||||
end;
|
||||
|
||||
function TPipeMaze.TryCountEnclosureSide(const AChar: Char; out OCount: Int64): Boolean;
|
||||
|
@ -247,7 +251,7 @@ begin
|
|||
if GetEnclosureMapChar(position) = AChar then
|
||||
begin
|
||||
stack.Push(position);
|
||||
SetEnclosureMapChar(position, '%');
|
||||
SetEnclosureMapChar(position, CFloodFillChar);
|
||||
Inc(OCount);
|
||||
end;
|
||||
|
||||
|
@ -262,10 +266,10 @@ begin
|
|||
// Checks the neighboring position.
|
||||
neighbor := position + direction;
|
||||
c := GetEnclosureMapChar(neighbor);
|
||||
if (c <> '%') and (c <> '#') then
|
||||
if (c <> CFloodFillChar) and (c <> CPathChar) then
|
||||
begin
|
||||
stack.Push(neighbor);
|
||||
SetEnclosureMapChar(neighbor, '%');
|
||||
SetEnclosureMapChar(neighbor, CFloodFillChar);
|
||||
Inc(OCount);
|
||||
end;
|
||||
end else
|
||||
|
@ -290,19 +294,19 @@ var
|
|||
c: Char;
|
||||
i: Integer;
|
||||
begin
|
||||
SetEnclosureMapChar(APosition, '#');
|
||||
SetEnclosureMapChar(APosition, CPathChar);
|
||||
side := AStepMapping.LeftSide;
|
||||
c := 'l';
|
||||
c := CLeftChar;
|
||||
for i := 1 to 2 do
|
||||
begin
|
||||
for offset in side do
|
||||
begin
|
||||
sidePosition := APosition + offset;
|
||||
if CheckMapBounds(sidePosition) and (GetEnclosureMapChar(sidePosition) <> '#') then
|
||||
if CheckMapBounds(sidePosition) and (GetEnclosureMapChar(sidePosition) <> CPathChar) then
|
||||
SetEnclosureMapChar(sidePosition, c);
|
||||
end;
|
||||
side := AStepMapping.RightSide;
|
||||
c := 'r';
|
||||
c := CRightChar;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
Loading…
Reference in New Issue