summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-05-10 14:52:30 +0200
committerErich Eckner <git@eckner.net>2020-05-10 14:52:30 +0200
commit5679bdc49a7b70bf2d404ce51e9ca287e37eae02 (patch)
treee52206f9ea54110953b4ec472eefe3a01de0a006
parent8ffb3b862355bf9b370dbc7ae68da9f3ed235adf (diff)
downloadRaetsel-5679bdc49a7b70bf2d404ce51e9ca287e37eae02.tar.xz
Leeren optimiert
-rw-r--r--raetsel.lps99
-rw-r--r--raetselunit.inc20
-rw-r--r--raetselunit.pas44
3 files changed, 107 insertions, 56 deletions
diff --git a/raetsel.lps b/raetsel.lps
index 44c4c43..24d557b 100644
--- a/raetsel.lps
+++ b/raetsel.lps
@@ -9,7 +9,7 @@
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="30" Y="19"/>
- <UsageCount Value="78"/>
+ <UsageCount Value="81"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@@ -19,7 +19,7 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<CursorPos Y="16"/>
- <UsageCount Value="78"/>
+ <UsageCount Value="81"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -32,25 +32,24 @@
<UnitName Value="Unit2"/>
<EditorIndex Value="-1"/>
<CursorPos X="11" Y="27"/>
- <UsageCount Value="77"/>
+ <UsageCount Value="80"/>
</Unit2>
<Unit3>
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="661"/>
- <CursorPos Y="681"/>
- <UsageCount Value="72"/>
+ <TopLine Value="651"/>
+ <CursorPos X="41" Y="659"/>
+ <UsageCount Value="75"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="raetselunit.inc"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
- <TopLine Value="394"/>
- <CursorPos X="34" Y="401"/>
- <UsageCount Value="58"/>
+ <CursorPos X="15" Y="15"/>
+ <UsageCount Value="61"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@@ -113,7 +112,7 @@
<Unit13>
<Filename Value="../units/lowlevelunit.pas"/>
<EditorIndex Value="4"/>
- <UsageCount Value="16"/>
+ <UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
@@ -128,7 +127,7 @@
<EditorIndex Value="5"/>
<TopLine Value="983"/>
<CursorPos X="17" Y="1009"/>
- <UsageCount Value="16"/>
+ <UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit15>
<Unit16>
@@ -152,7 +151,7 @@
<EditorIndex Value="3"/>
<TopLine Value="22"/>
<CursorPos X="59" Y="58"/>
- <UsageCount Value="16"/>
+ <UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit19>
</Units>
@@ -162,123 +161,121 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="raetselunit.pas"/>
- <Caret Line="478" Column="11" TopLine="452"/>
+ <Caret Line="1181" Column="52" TopLine="1162"/>
</Position1>
<Position2>
<Filename Value="raetselunit.pas"/>
- <Caret Line="479" Column="11" TopLine="453"/>
+ <Caret Line="1185" Column="54" TopLine="1162"/>
</Position2>
<Position3>
<Filename Value="raetselunit.pas"/>
- <Caret Line="480" Column="11" TopLine="454"/>
+ <Caret Line="1179" Column="42" TopLine="1162"/>
</Position3>
<Position4>
<Filename Value="raetselunit.pas"/>
- <Caret Line="481" Column="11" TopLine="455"/>
+ <Caret Line="654" TopLine="642"/>
</Position4>
<Position5>
<Filename Value="raetselunit.pas"/>
- <Caret Line="485" Column="25" TopLine="459"/>
+ <Caret Line="660" Column="35" TopLine="644"/>
</Position5>
<Position6>
<Filename Value="raetselunit.pas"/>
- <Caret Line="486" Column="40" TopLine="460"/>
</Position6>
<Position7>
<Filename Value="raetselunit.pas"/>
- <Caret Line="517" Column="21" TopLine="490"/>
+ <Caret Line="108" TopLine="86"/>
</Position7>
<Position8>
<Filename Value="raetselunit.pas"/>
- <Caret Line="518" Column="35" TopLine="491"/>
+ <Caret Line="570" Column="35" TopLine="544"/>
</Position8>
<Position9>
<Filename Value="raetselunit.pas"/>
- <Caret Line="523" Column="13" TopLine="496"/>
+ <Caret Line="573" Column="35" TopLine="547"/>
</Position9>
<Position10>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="524" Column="41" TopLine="497"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="697" TopLine="675"/>
</Position10>
<Position11>
<Filename Value="raetselunit.pas"/>
- <Caret Line="525" Column="15" TopLine="498"/>
+ <Caret Line="1192" Column="11" TopLine="1176"/>
</Position11>
<Position12>
<Filename Value="raetselunit.pas"/>
- <Caret Line="613" Column="11" TopLine="586"/>
+ <Caret Line="1100" Column="20" TopLine="1085"/>
</Position12>
<Position13>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="614" Column="11" TopLine="587"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="697" TopLine="633"/>
</Position13>
<Position14>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="770" Column="28" TopLine="743"/>
+ <Filename Value="raetselunit.inc"/>
</Position14>
<Position15>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="873" Column="19" TopLine="846"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="12" Column="15"/>
</Position15>
<Position16>
<Filename Value="raetselunit.pas"/>
- <Caret Line="875" Column="19" TopLine="848"/>
+ <Caret Line="1196" Column="67" TopLine="1179"/>
</Position16>
<Position17>
<Filename Value="raetselunit.pas"/>
- <Caret Line="934" Column="11" TopLine="907"/>
+ <Caret Line="61" Column="21" TopLine="46"/>
</Position17>
<Position18>
<Filename Value="raetselunit.pas"/>
- <Caret Line="937" Column="11" TopLine="910"/>
+ <Caret Line="100" Column="21" TopLine="72"/>
</Position18>
<Position19>
<Filename Value="raetselunit.pas"/>
- <Caret Line="1010" Column="27" TopLine="1001"/>
+ <Caret Line="351" Column="9" TopLine="324"/>
</Position19>
<Position20>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="34" TopLine="33"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="12" Column="28"/>
</Position20>
<Position21>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="55" Column="29" TopLine="33"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="694" Column="13" TopLine="671"/>
</Position21>
<Position22>
<Filename Value="raetselunit.pas"/>
- <Caret Line="227" Column="38" TopLine="200"/>
+ <Caret Line="656" Column="31" TopLine="646"/>
</Position22>
<Position23>
<Filename Value="raetselunit.pas"/>
- <Caret Line="342" TopLine="325"/>
+ <Caret Line="657" Column="19" TopLine="643"/>
</Position23>
<Position24>
<Filename Value="raetselunit.pas"/>
- <Caret Line="635" TopLine="610"/>
+ <Caret Line="64" Column="27" TopLine="48"/>
</Position24>
<Position25>
<Filename Value="raetselunit.pas"/>
- <Caret Line="636" TopLine="610"/>
+ <Caret Line="660" Column="25" TopLine="633"/>
</Position25>
<Position26>
<Filename Value="raetselunit.pas"/>
- <Caret Line="343" TopLine="327"/>
+ <Caret Line="661" Column="22" TopLine="634"/>
</Position26>
<Position27>
<Filename Value="raetselunit.pas"/>
- <Caret Line="344" TopLine="327"/>
+ <Caret Line="678" Column="20" TopLine="652"/>
</Position27>
<Position28>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="345" TopLine="327"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="12" Column="62"/>
</Position28>
<Position29>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="346" TopLine="327"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="20" Column="27"/>
</Position29>
<Position30>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="347" TopLine="327"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="796" Column="31" TopLine="778"/>
</Position30>
</JumpHistory>
<RunParams>
diff --git a/raetselunit.inc b/raetselunit.inc
index 025d68a..6f9dbcf 100644
--- a/raetselunit.inc
+++ b/raetselunit.inc
@@ -9,6 +9,7 @@ type
{$ENDIF}
private
procedure relativeInhaltsAenderung(diff: longint); override;
+ function naechsterWert(pos: longint): boolean; override;
function absoluteInhaltsAenderung(key: word): boolean; override;
function passtZumZeichnen(spalte,zeile: integer): boolean; override;
function passt(spalte,zeile: integer): boolean; override;
@@ -682,6 +683,25 @@ begin
end;
{$ENDIF}
+{$IFDEF naechsterWert}
+// function tBuchstabenRaetsel.naechsterWert(pos: longint): boolean;
+begin
+ result:=false;
+ if (pos<0) or (pos>=dim*dim) then
+ exit;
+ inhalt[pos]:=inhalt[pos]+1;
+ {$IFDEF hochhaus}
+ if inhalt[pos]=0 then
+ inhalt[pos]:=1;
+ {$ENDIF}
+ if inhalt[pos]>groeszen[0] then begin
+ inhalt[pos]:=groeszen[0];
+ exit;
+ end;
+ result:=true;
+end;
+{$ENDIF}
+
{$IFDEF absoluteInhaltsAenderung}
// function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
begin
diff --git a/raetselunit.pas b/raetselunit.pas
index 34bfef6..4ea8d77 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -104,6 +104,7 @@ type
function besitzerBreite: longint; override;
procedure schreibeZentriert(x,y,i: longint);
procedure relativeInhaltsAenderung(diff: longint); dynamic; abstract;
+ function naechsterWert(pos: longint): boolean; dynamic; abstract;
function absoluteInhaltsAenderung(key: word): boolean; dynamic; abstract;
procedure gesamtRaenderErzeugen; dynamic; abstract;
procedure startFelderFestlegen; override;
@@ -612,8 +613,9 @@ end;
procedure tFelderRaetsel.leeren;
var
- p: tLongintArray;
- i,w: longint;
+ p: tLongintArray;
+ i,w: longint;
+ funktioniert: boolean;
begin
p:=permutation(dim*dim);
progressBar1.step:=1;
@@ -628,7 +630,17 @@ begin
continue;
w:=inhalt[p[i]];
inhalt[p[i]]:=-1;
- if anzLoesungen(-1)<>1 then
+ funktioniert:=true;
+ while funktioniert and naechsterWert(p[i]) do begin
+ if inhalt[p[i]]=w then
+ continue;
+ if passt(p[i] mod dim,p[i] div dim) and (anzLoesungen(-1)>0) then
+ funktioniert:=false;
+ end;
+ writeln;
+ if funktioniert then
+ inhalt[p[i]]:=-1
+ else
inhalt[p[i]]:=w;
end;
@@ -638,8 +650,19 @@ begin
application.processMessages;
if rand[p[i]]<0 then continue;
w:=rand[p[i]];
- rand[p[i]]:=-1;
- if anzLoesungen(-1)<>1 then
+ rand[p[i]]:=0;
+ funktioniert:=true;
+ while funktioniert and (rand[p[i]]<dim) do begin
+ inc(rand[p[i]]);
+ if rand[p[i]]=w then
+ continue;
+ if anzLoesungen(-1)>0 then
+ funktioniert:=false;
+ end;
+ writeln;
+ if funktioniert then
+ rand[p[i]]:=-1
+ else
rand[p[i]]:=w;
end;
progressBar1.visible:=false;
@@ -1058,6 +1081,17 @@ procedure tBuchstabenRaetsel.relativeInhaltsAenderung(diff: integer);
{$UNDEF buchstaben}
{$UNDEF relativeInhaltsAenderung}
+{$DEFINE naechsterWert}
+function tHochhausRaetsel.naechsterWert(pos: longint): boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.naechsterWert(pos: longint): boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF naechsterWert}
+
{$DEFINE absoluteInhaltsAenderung}
function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
{$DEFINE hochhaus}