From e9737f0265d30bacddf9b5664a197f84c3a64ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Tue, 19 Dec 2023 13:15:46 +0100 Subject: [PATCH] Moved the constants in UFloorWillBeLava below the types so that they can be together in a single const block --- solvers/UFloorWillBeLava.pas | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/solvers/UFloorWillBeLava.pas b/solvers/UFloorWillBeLava.pas index 986ad80..150e5bc 100644 --- a/solvers/UFloorWillBeLava.pas +++ b/solvers/UFloorWillBeLava.pas @@ -24,10 +24,6 @@ interface uses Classes, SysUtils, Generics.Collections, USolver; -const - CNoDirection: TPoint = (X: 0; Y: 0); - CEmptyChar = '.'; - type { TBeam } @@ -36,10 +32,6 @@ type Position, Direction: TPoint; end; -const - CStartingBeam: TBeam = (Position: (X: 0; Y: 0); Direction: (X: 1; Y: 0)); - -type TEnergyState = (esNone, esWestOrHorizontal, esEastOrVertical, esBoth); { TTransition } @@ -50,7 +42,27 @@ type EnergyChange: TEnergyState; end; + { TFloorWillBeLava } + + TFloorWillBeLava = class(TSolver) + private + FLines: TStringList; + function IsBeamOutOfBounds(constref ABeam: TBeam; const AWidth, AHeight: Integer): Boolean; + function GetTile(constref APosition: TPoint): Char; + function GetNewBeam(constref APosition, ADirection: TPoint): TBeam; + public + constructor Create; + destructor Destroy; override; + procedure ProcessDataLine(const ALine: string); override; + procedure Finish; override; + function GetDataFileName: string; override; + function GetPuzzleName: string; override; + end; + const + CNoDirection: TPoint = (X: 0; Y: 0); + CEmptyChar = '.'; + CStartingBeam: TBeam = (Position: (X: 0; Y: 0); Direction: (X: 1; Y: 0)); CTransitions: array of TTransition = ( (IncomingDirection: (X: 1; Y: 0); OutgoingDirection: (X: 0; Y: -1); SplitDirection: (X: 0; Y: 0); Tile: '/'; EnergyChange: esWestOrHorizontal), @@ -78,25 +90,6 @@ const EnergyChange: esBoth) ); -type - - { TFloorWillBeLava } - - TFloorWillBeLava = class(TSolver) - private - FLines: TStringList; - function IsBeamOutOfBounds(constref ABeam: TBeam; const AWidth, AHeight: Integer): Boolean; - function GetTile(constref APosition: TPoint): Char; - function GetNewBeam(constref APosition, ADirection: TPoint): TBeam; - public - constructor Create; - destructor Destroy; override; - procedure ProcessDataLine(const ALine: string); override; - procedure Finish; override; - function GetDataFileName: string; override; - function GetPuzzleName: string; override; - end; - implementation { TFloorWillBeLava }