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