summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-01 16:14:03 +0200
committerErich Eckner <git@eckner.net>2018-10-01 16:14:03 +0200
commitab7b912fe2e31fdbb0978979df8606724c387d10 (patch)
tree4b028fbe33a9cb73f2f281b75c6e3ce325d7730e
parent667f65d6f46dc71482e307ee483e994f8f78b522 (diff)
downloadRaetsel-ab7b912fe2e31fdbb0978979df8606724c387d10.tar.xz
geht schon fast
-rw-r--r--raetsel.lps149
-rw-r--r--raetselunit.inc495
-rw-r--r--raetselunit.pas272
3 files changed, 714 insertions, 202 deletions
diff --git a/raetsel.lps b/raetsel.lps
index 67fe025..aaeac78 100644
--- a/raetsel.lps
+++ b/raetsel.lps
@@ -3,13 +3,13 @@
<ProjectSession>
<Version Value="10"/>
<BuildModes Active="Default"/>
- <Units Count="14">
+ <Units Count="15">
<Unit0>
<Filename Value="raetsel.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="35" Y="10"/>
- <UsageCount Value="49"/>
+ <UsageCount Value="53"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@@ -20,7 +20,7 @@
<ResourceBaseClass Value="Form"/>
<TopLine Value="32"/>
<CursorPos Y="52"/>
- <UsageCount Value="49"/>
+ <UsageCount Value="53"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -33,7 +33,7 @@
<UnitName Value="Unit2"/>
<EditorIndex Value="4"/>
<CursorPos X="20" Y="12"/>
- <UsageCount Value="48"/>
+ <UsageCount Value="52"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
@@ -41,210 +41,217 @@
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="108"/>
- <CursorPos X="30" Y="127"/>
- <UsageCount Value="43"/>
+ <TopLine Value="500"/>
+ <CursorPos X="8" Y="523"/>
+ <UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
+ <Filename Value="raetselunit.inc"/>
+ <IsPartOfProject Value="True"/>
+ <IsVisibleTab Value="True"/>
+ <EditorIndex Value="3"/>
+ <TopLine Value="475"/>
+ <CursorPos X="8" Y="487"/>
+ <UsageCount Value="33"/>
+ <Loaded Value="True"/>
+ </Unit4>
+ <Unit5>
<Filename Value="buchstabenunit.pas"/>
<EditorIndex Value="-1"/>
<CursorPos Y="18"/>
<UsageCount Value="23"/>
- </Unit4>
- <Unit5>
+ </Unit5>
+ <Unit6>
<Filename Value="hochhausunit.pas"/>
<EditorIndex Value="-1"/>
<CursorPos Y="18"/>
<UsageCount Value="23"/>
- </Unit5>
- <Unit6>
+ </Unit6>
+ <Unit7>
<Filename Value="Unit1.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="17"/>
<UsageCount Value="8"/>
- </Unit6>
- <Unit7>
+ </Unit7>
+ <Unit8>
<Filename Value="RaetselFileUnit.pas"/>
<UnitName Value="raetselFileUnit"/>
<EditorIndex Value="-1"/>
<UsageCount Value="8"/>
- </Unit7>
- <Unit8>
+ </Unit8>
+ <Unit9>
<Filename Value="raetselFileUnit.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="28" Y="11"/>
<UsageCount Value="8"/>
- </Unit8>
- <Unit9>
+ </Unit9>
+ <Unit10>
<Filename Value="ori_Unit1.pas"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<EditorIndex Value="5"/>
- <TopLine Value="1742"/>
- <CursorPos X="24" Y="1985"/>
- <UsageCount Value="14"/>
+ <TopLine Value="1044"/>
+ <CursorPos X="34" Y="993"/>
+ <UsageCount Value="17"/>
<Loaded Value="True"/>
- </Unit9>
- <Unit10>
+ </Unit10>
+ <Unit11>
<Filename Value="/usr/share/lazarus/lcl/stdctrls.pp"/>
<UnitName Value="StdCtrls"/>
<EditorIndex Value="-1"/>
<TopLine Value="1255"/>
<CursorPos X="3" Y="1277"/>
<UsageCount Value="8"/>
- </Unit10>
- <Unit11>
+ </Unit11>
+ <Unit12>
<Filename Value="/usr/share/lazarus/lcl/dialogs.pp"/>
<UnitName Value="Dialogs"/>
<EditorIndex Value="-1"/>
<TopLine Value="487"/>
<CursorPos X="10" Y="509"/>
<UsageCount Value="9"/>
- </Unit11>
- <Unit12>
+ </Unit12>
+ <Unit13>
<Filename Value="../units/lowlevelunit.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
- </Unit12>
- <Unit13>
- <Filename Value="raetselunit.inc"/>
- <IsPartOfProject Value="True"/>
- <IsVisibleTab Value="True"/>
- <EditorIndex Value="3"/>
- <TopLine Value="397"/>
- <CursorPos Y="417"/>
- <UsageCount Value="28"/>
- <Loaded Value="True"/>
</Unit13>
+ <Unit14>
+ <Filename Value="/usr/lib/lazarus/lcl/include/canvas.inc"/>
+ <EditorIndex Value="-1"/>
+ <TopLine Value="1681"/>
+ <CursorPos X="16" Y="1705"/>
+ <UsageCount Value="10"/>
+ </Unit14>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="674" TopLine="660"/>
</Position1>
<Position2>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="679" TopLine="660"/>
</Position2>
<Position3>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="681" TopLine="660"/>
</Position3>
<Position4>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="684" Column="16" TopLine="660"/>
</Position4>
<Position5>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="93" TopLine="82"/>
</Position5>
<Position6>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="94" TopLine="82"/>
</Position6>
<Position7>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="95" TopLine="82"/>
</Position7>
<Position8>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="96" TopLine="82"/>
</Position8>
<Position9>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position9>
<Position10>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position10>
<Position11>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position11>
<Position12>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position12>
<Position13>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position13>
<Position14>
<Filename Value="raetselunit.inc"/>
- <Caret Line="412" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position14>
<Position15>
<Filename Value="raetselunit.inc"/>
- <Caret Line="413" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position15>
<Position16>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position16>
<Position17>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position17>
<Position18>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position18>
<Position19>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position19>
<Position20>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position20>
<Position21>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position21>
<Position22>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position22>
<Position23>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position23>
<Position24>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position24>
<Position25>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="130" TopLine="108"/>
</Position25>
<Position26>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="131" TopLine="108"/>
</Position26>
<Position27>
<Filename Value="raetselunit.inc"/>
- <Caret Line="415" TopLine="390"/>
+ <Caret Line="128" TopLine="108"/>
</Position27>
<Position28>
<Filename Value="raetselunit.inc"/>
- <Caret Line="414" TopLine="390"/>
+ <Caret Line="130" Column="54" TopLine="137"/>
</Position28>
<Position29>
<Filename Value="raetselunit.inc"/>
- <Caret Line="408" TopLine="390"/>
+ <Caret Line="13" Column="31"/>
</Position29>
<Position30>
- <Filename Value="raetselunit.inc"/>
- <Caret Line="284" TopLine="264"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="270" Column="35" TopLine="272"/>
</Position30>
</JumpHistory>
</ProjectSession>
<Debugging>
- <Watches Count="5">
+ <Watches Count="7">
<Item1>
<Expression Value="W"/>
</Item1>
@@ -260,6 +267,12 @@
<Item5>
<Expression Value="inhalt"/>
</Item5>
+ <Item6>
+ <Expression Value="loesen"/>
+ </Item6>
+ <Item7>
+ <Expression Value="p"/>
+ </Item7>
</Watches>
</Debugging>
</CONFIG>
diff --git a/raetselunit.inc b/raetselunit.inc
index 6c796ce..3176ade 100644
--- a/raetselunit.inc
+++ b/raetselunit.inc
@@ -8,22 +8,18 @@ type
tBuchstabenRaetsel = class(tFelderRaetsel)
{$ENDIF}
private
-// procedure relativeInhaltsAenderung(diff: longint); override;
-// function absoluteInhaltsAenderung(key: word): boolean; override;
+ procedure relativeInhaltsAenderung(diff: longint); override;
+ function absoluteInhaltsAenderung(key: word): boolean; override;
function passtZumZeichnen(spalte,zeile: integer): boolean; override;
function passt(spalte,zeile: integer): boolean; override;
function geloest: boolean; override;
procedure gesamtRaenderErzeugen; override;
+ procedure randErzeugen; override;
+ function loesen(lPos: integer): boolean; override;
+ function anzLoesungen(lPos: integer): integer; override;
public
- NSqrt: integer;
- AMoeglich,EMoeglich: array of boolean;
constructor create(aOwner: tForm);
destructor destroy; override;
-// function Loesen(lPos: integer): boolean;
-// procedure leeren;
-// procedure RandErzeugen;
-// function anzLoesungen(lPos: integer): integer;
-// procedure Image2Bemalen;
end;
{$IFDEF hochhaus}
@@ -107,26 +103,17 @@ begin
K:=K*(groeszen[0]+2)+inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]+1;
{$ENDIF}
{$IFDEF hochhaus}
- W:=W*(dim+1)+inhalt[Zeile*dim+I];
- S:=S*(dim+1)+inhalt[I*dim+Spalte];
- K:=K*(dim+1)+inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)];
+ W:=W*(dim+1)+max(0,inhalt[Zeile*dim+I]);
+ S:=S*(dim+1)+max(0,inhalt[I*dim+Spalte]);
+ K:=K*(dim+1)+max(0,inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]);
{$ENDIF}
end;
result:=
- {$IFDEF buchstaben}
AMoeglich[K*(groeszen[0]+1)] and
- EMoeglich[S*(groeszen[0]+1)+Rand[Spalte]] and
- AMoeglich[W*(groeszen[0]+1)+Rand[dim+Zeile]] and
- AMoeglich[S*(groeszen[0]+1)+Rand[2*dim+Spalte]] and
- EMoeglich[W*(groeszen[0]+1)+Rand[3*dim+Zeile]];
- {$ENDIF}
- {$IFDEF hochhaus}
- AMoeglich[K*(dim+1)] and
- EMoeglich[S*(dim+1)+Rand[Spalte]] and
- AMoeglich[W*(dim+1)+Rand[dim+Zeile]] and
- AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] and
- EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]];
- {$ENDIF}
+ EMoeglich[S*(groeszen[0]+1)+max(0,Rand[Spalte])] and
+ AMoeglich[W*(groeszen[0]+1)+max(0,Rand[dim+Zeile])] and
+ AMoeglich[S*(groeszen[0]+1)+max(0,Rand[2*dim+Spalte])] and
+ EMoeglich[W*(groeszen[0]+1)+max(0,Rand[3*dim+Zeile])];
end
else begin
for I:=0 to dim-1 do begin
@@ -135,23 +122,15 @@ begin
S:=S*(groeszen[0]+2)+inhalt[I*dim+Spalte]+1;
{$ENDIF}
{$IFDEF hochhaus}
- W:=W*(dim+1)+inhalt[Zeile*dim+I];
- S:=S*(dim+1)+inhalt[I*dim+Spalte];
+ W:=W*(dim+1)+max(0,inhalt[Zeile*dim+I]);
+ S:=S*(dim+1)+max(0,inhalt[I*dim+Spalte]);
{$ENDIF}
end;
result:=
- {$IFDEF buchstaben}
- EMoeglich[S*(groeszen[0]+1)+Rand[Spalte]] and
- AMoeglich[W*(groeszen[0]+1)+Rand[dim+Zeile]] and
- AMoeglich[S*(groeszen[0]+1)+Rand[2*dim+Spalte]] and
- EMoeglich[W*(groeszen[0]+1)+Rand[3*dim+Zeile]];
- {$ENDIF}
- {$IFDEF hochhaus}
- EMoeglich[S*(dim+1)+Rand[Spalte]] and
- AMoeglich[W*(dim+1)+Rand[dim+Zeile]] and
- AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] and
- EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]];
- {$ENDIF}
+ EMoeglich[S*(groeszen[0]+1)+max(0,Rand[Spalte])] and
+ AMoeglich[W*(groeszen[0]+1)+max(0,Rand[dim+Zeile])] and
+ AMoeglich[S*(groeszen[0]+1)+max(0,Rand[2*dim+Spalte])] and
+ EMoeglich[W*(groeszen[0]+1)+max(0,Rand[3*dim+Zeile])];
end;
if diagonalenCB.checked then begin
if Zeile=Spalte then begin
@@ -163,7 +142,7 @@ begin
{$ENDIF}
{$IFDEF hochhaus}
for I:=0 to dim-1 do
- W:=W*(dim+1)+inhalt[I*(dim+1)];
+ W:=W*(dim+1)+max(0,inhalt[I*(dim+1)]);
result:=result and AMoeglich[W*(dim+1)];
{$ENDIF}
end;
@@ -176,7 +155,7 @@ begin
{$ENDIF}
{$IFDEF hochhaus}
for I:=0 to dim-1 do
- W:=W*(dim+1)+inhalt[(I+1)*(dim-1)];
+ W:=W*(dim+1)+max(0,inhalt[(I+1)*(dim-1)]);
Result:=Result and AMoeglich[W*(dim+1)];
{$ENDIF}
end;
@@ -193,10 +172,10 @@ begin
for i:=0 to dim-1 do
for j:=0 to dim-1 do
if (not passt(i,j)) or (inhalt[i+dim*j]<0)
- {$IFDEF hochhaus}
- or (inhalt[I+dim*j]=0)
- {$ENDIF}
- then exit;
+ {$IFDEF hochhaus}
+ or (inhalt[I+dim*j]=0)
+ {$ENDIF}
+ then exit;
result:=true;
end;
{$ENDIF}
@@ -272,6 +251,8 @@ begin
(length(EMoeglich) = AK) then
exit;
+ lw:=0; // silence warning
+
if fileexists(extractfilepath(application.exename)+dat_name) then begin
assignfile(dat,extractfilepath(application.exename)+dat_name);
reset(dat,1);
@@ -321,21 +302,21 @@ begin
B:=true;
{$IFDEF buchstaben}
Nullen:=groeszen[1];
- For I:=0 to length(Nums)-1 do
- begin
+ For I:=0 to length(Nums)-1 do begin
B:=B and (Nums[I]<>0);
- if Nums[I]=1 then dec(Nullen)
- else
- For J:=0 to I-1 do
- B:=B and (Nums[I]<>Nums[J]);
- end;
+ if Nums[I]=1 then
+ dec(Nullen)
+ else
+ for J:=0 to I-1 do
+ B:=B and (Nums[I]<>Nums[J]);
+ end;
B:=B and (Nullen>=0);
{$ENDIF}
{$IFDEF hochhaus}
For I:=0 to length(Nums)-1 do begin
B:=B and (Nums[I]<>0);
- For J:=0 to I-1 do
- B:=B and (Nums[I]<>Nums[J]);
+ for J:=0 to I-1 do
+ B:=B and (Nums[I]<>Nums[J]);
end;
{$ENDIF}
if B then begin
@@ -431,80 +412,368 @@ var
W,S: Longint;
begin
result:=false;
- {$IFDEF buchstaben}
- if inhalt[Zeile*dim+Spalte]=-1 then
- exit;
- {$ENDIF}
- {$IFDEF hochhaus}
- if inhalt[Zeile*dim+Spalte]=0 then
- exit;
- {$ENDIF}
- W:=0;
- S:=0;
- for I:=0 to dim-1 do begin
+ if (spalte>=0) and (zeile>=0) and (spalte<dim) and (zeile<dim) then begin // im inneren
{$IFDEF buchstaben}
- W:=W*(groeszen[0]+2)+inhalt[Zeile*dim+I]+1;
- S:=S*(groeszen[0]+2)+inhalt[I*dim+Spalte]+1;
+ if inhalt[Zeile*dim+Spalte]=-1 then
+ exit;
{$ENDIF}
{$IFDEF hochhaus}
- W:=W*(dim+1)+inhalt[Zeile*dim+I];
- S:=S*(dim+1)+inhalt[I*dim+Spalte];
+ if inhalt[Zeile*dim+Spalte]<=0 then
+ exit;
{$ENDIF}
- end;
- Result:=
+ W:=0;
+ S:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ W:=W*(groeszen[0]+2)+inhalt[Zeile*dim+I]+1;
+ S:=S*(groeszen[0]+2)+inhalt[I*dim+Spalte]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ W:=W*(dim+1)+max(0,inhalt[Zeile*dim+I]);
+ S:=S*(dim+1)+max(0,inhalt[I*dim+Spalte]);
+ {$ENDIF}
+ end;
+ Result:=
+ EMoeglich[S*(groeszen[0]+1)+max(0,Rand[Spalte])] and
+ AMoeglich[W*(groeszen[0]+1)+max(0,Rand[dim+Zeile])] and
+ AMoeglich[S*(groeszen[0]+1)+max(0,Rand[2*dim+Spalte])] and
+ EMoeglich[W*(groeszen[0]+1)+max(0,Rand[3*dim+Zeile])];
{$IFDEF buchstaben}
- (EMoeglich[S*(groeszen[0]+1)+Rand[Spalte]] or not EMoeglich[S*(groeszen[0]+1)]) and
- (AMoeglich[W*(groeszen[0]+1)+Rand[dim+Zeile]] or not AMoeglich[W*(groeszen[0]+1)]) and
- (AMoeglich[S*(groeszen[0]+1)+Rand[2*dim+Spalte]] or not AMoeglich[S*(groeszen[0]+1)]) and
- (EMoeglich[W*(groeszen[0]+1)+Rand[3*dim+Zeile]] or not EMoeglich[W*(groeszen[0]+1)]);
- {$ENDIF}
- {$IFDEF hochhaus}
- (EMoeglich[S*(dim+1)+Rand[Spalte]] or not EMoeglich[S*(dim+1)]) and
- (AMoeglich[W*(dim+1)+Rand[dim+Zeile]] or not AMoeglich[W*(dim+1)]) and
- (AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] or not AMoeglich[S*(dim+1)]) and
- (EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]] or not EMoeglich[W*(dim+1)]);
+ if inhalt[Zeile*dim+Spalte]=0 then
+ W:=groeszen[1]
+ else
{$ENDIF}
- {$IFDEF buchstaben}
- if inhalt[Zeile*dim+Spalte]=0 then
- W:=groeszen[1]
- else
- {$ENDIF}
- W:=1;
- if diagonalenCB.checked then begin
- if Zeile=Spalte then begin
- S:=W;
- for I:=0 to dim-1 do
- if (I<>Zeile) and (inhalt[I*(dim+1)]=inhalt[Zeile*dim+Spalte]) then
- dec(S);
- Result:=Result and (S>0);
+ W:=1;
+ if diagonalenCB.checked then begin
+ if Zeile=Spalte then begin
+ S:=W;
+ for I:=0 to dim-1 do
+ if (I<>Zeile) and (inhalt[I*(dim+1)]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ end;
+ if Zeile+Spalte=dim-1 then begin
+ S:=W;
+ For I:=0 to dim-1 do
+ if (I<>Zeile) and (inhalt[(I+1)*(dim-1)]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ end;
end;
- if Zeile+Spalte=dim-1 then begin
- S:=W;
+ if sudokuCB.checked then begin
+ KZ:=(Zeile div NSqrt)*NSqrt;
+ KS:=(Spalte div NSqrt)*NSqrt;
+ S:=W+1;
For I:=0 to dim-1 do
- if (I<>Zeile) and (inhalt[(I+1)*(dim-1)]=inhalt[Zeile*dim+Spalte]) then
+ if inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]=inhalt[Zeile*dim+Spalte] then
dec(S);
Result:=Result and (S>0);
end;
- end;
- if sudokuCB.checked then begin
- KZ:=(Zeile div NSqrt)*NSqrt;
- KS:=(Spalte div NSqrt)*NSqrt;
- S:=W+1;
+ S:=W;
For I:=0 to dim-1 do
- if inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]=inhalt[Zeile*dim+Spalte] then
+ if (I<>Zeile) and (inhalt[I*dim+Spalte]=inhalt[Zeile*dim+Spalte]) then
dec(S);
Result:=Result and (S>0);
+ S:=W;
+ For I:=0 to dim-1 do
+ if (I<>Spalte) and (inhalt[Zeile*dim+I]=inhalt[Zeile*dim+Spalte]) then
+ dec(S);
+ Result:=Result and (S>0);
+ end
+ else begin // auf dem Rand
+ if zeile=-1 then begin
+ if rand[spalte]=-1 then
+ exit;
+ s:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ S:=S*(groeszen[0]+2)+inhalt[I*dim+Spalte]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ S:=S*(dim+1)+max(0,inhalt[I*dim+Spalte]);
+ {$ENDIF}
+ end;
+ result:=
+ EMoeglich[S*(groeszen[0]+1)+max(0,Rand[Spalte])] or
+ not EMoeglich[S*(groeszen[0]+1)];
+ exit;
+ end;
+ if spalte=dim then begin
+ if rand[dim+zeile]=-1 then
+ exit;
+ w:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ w:=w*(groeszen[0]+2)+inhalt[zeile*dim+i]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ w:=w*(dim+1)+max(0,inhalt[zeile*dim+i]);
+ {$ENDIF}
+ end;
+ result:=
+ AMoeglich[w*(groeszen[0]+1)+max(0,Rand[dim+zeile])] or
+ not AMoeglich[w*(groeszen[0]+1)];
+ exit;
+ end;
+ if zeile=dim then begin
+ if rand[2*dim+spalte]=-1 then
+ exit;
+ s:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ S:=S*(groeszen[0]+2)+inhalt[I*dim+Spalte]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ S:=S*(dim+1)+max(0,inhalt[I*dim+Spalte]);
+ {$ENDIF}
+ end;
+ result:=
+ AMoeglich[S*(groeszen[0]+1)+max(0,Rand[2*dim+Spalte])] or
+ not EMoeglich[S*(groeszen[0]+1)];
+ exit;
+ end;
+ if spalte=-1 then begin
+ if rand[3*dim+zeile]=-1 then
+ exit;
+ w:=0;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ w:=w*(groeszen[0]+2)+inhalt[zeile*dim+i]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ w:=w*(dim+1)+max(0,inhalt[zeile*dim+i]);
+ {$ENDIF}
+ end;
+ result:=
+ EMoeglich[w*(groeszen[0]+1)+max(0,Rand[3*dim+zeile])] or
+ not EMoeglich[w*(groeszen[0]+1)];
+ exit;
+ end;
end;
- S:=W;
- For I:=0 to dim-1 do
- if (I<>Zeile) and (inhalt[I*dim+Spalte]=inhalt[Zeile*dim+Spalte]) then
- dec(S);
- Result:=Result and (S>0);
- S:=W;
- For I:=0 to dim-1 do
- if (I<>Spalte) and (inhalt[Zeile*dim+I]=inhalt[Zeile*dim+Spalte]) then
- dec(S);
- Result:=Result and (S>0);
end;
{$ENDIF}
+{$IFDEF randErzeugen}
+// procedure tHochhausRaetsel.RandErzeugen;
+var
+ i,j: integer;
+{$IFDEF hochhaus}
+ h,z: integer;
+{$ENDIF}
+begin
+ for i:=0 to dim-1 do begin
+ {$IFDEF hochhaus}
+ h:=0;
+ z:=0;
+ {$ENDIF}
+ for j:=0 to dim-1 do begin
+ if inhalt[i+dim*j]=-1 then begin
+ {$IFDEF hochhaus}
+ z:=0;
+ {$ENDIF}
+ break;
+ end;
+ {$IFDEF buchstaben}
+ if inhalt[i+dim*j]=0 then
+ continue;
+ Rand[I]:=inhalt[I+dim*J];
+ break;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if inhalt[I+dim*J]>H then begin
+ H:=inhalt[I+dim*J];
+ inc(Z);
+ end;
+ {$ENDIF}
+ end;
+ {$IFDEF hochhaus}
+ Rand[I]:=Z;
+
+ H:=0;
+ Z:=0;
+ {$ENDIF}
+ For J:=dim-1 downto 0 do begin
+ if inhalt[I+dim*J]=-1 then begin
+ {$IFDEF hochhaus}
+ z:=0;
+ {$ENDIF}
+ break;
+ end;
+ {$IFDEF buchstaben}
+ if inhalt[i+dim*j]=0 then
+ continue;
+ Rand[2*dim+I]:=inhalt[I+dim*J];
+ break;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if inhalt[I+dim*J]>H then begin
+ H:=inhalt[I+dim*J];
+ inc(Z);
+ end;
+ {$ENDIF}
+ end;
+ {$IFDEF hochhaus}
+ Rand[2*dim+I]:=Z;
+
+ H:=0;
+ Z:=0;
+ {$ENDIF}
+ For J:=dim-1 downto 0 do begin
+ if inhalt[J+dim*I]=-1 then begin
+ {$IFDEF hochhaus}
+ z:=0;
+ {$ENDIF}
+ break;
+ end;
+ {$IFDEF buchstaben}
+ if inhalt[J+dim*I]=0 then
+ continue;
+ Rand[dim+I]:=inhalt[J+dim*I];
+ break;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if inhalt[J+dim*I]>H then begin
+ H:=inhalt[J+dim*I];
+ inc(Z);
+ end;
+ {$ENDIF}
+ end;
+ {$IFDEF hochhaus}
+ Rand[dim+I]:=Z;
+
+ H:=0;
+ Z:=0;
+ {$ENDIF}
+ For J:=0 to dim-1 do begin
+ if inhalt[J+dim*I]=-1 then begin
+ {$IFDEF hochhaus}
+ Z:=0;
+ {$ENDIF}
+ break;
+ end;
+ {$IFDEF buchstaben}
+ if inhalt[J+dim*I]=0 then continue;
+ Rand[dim+I]:=inhalt[J+dim*I];
+ break;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if inhalt[J+dim*I]>H then begin
+ H:=inhalt[J+dim*I];
+ inc(Z);
+ end;
+ {$ENDIF}
+ end;
+ {$IFDEF hochhaus}
+ Rand[3*dim+I]:=Z;
+ {$ENDIF}
+ end;
+end;
+{$ENDIF}
+
+{$IFDEF relativeInhaltsAenderung}
+// procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: longint);
+begin
+ if (cursorPosition<0) or (cursorPosition>=dim*dim) then
+ exit;
+ {$IFDEF hochhaus}
+ if inhalt[cursorPosition]=-1 then
+ inhalt[cursorPosition]:=0;
+ {$ENDIF}
+ inhalt[cursorPosition]:=min(max(-1,inhalt[cursorPosition]+diff),groeszen[0]);
+ {$IFDEF hochhaus}
+ if inhalt[cursorPosition]=0 then
+ inhalt[cursorPosition]:=-1;
+ {$ENDIF}
+end;
+{$ENDIF}
+
+{$IFDEF absoluteInhaltsAenderung}
+// function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
+begin
+ result:=true;
+ {$IFDEF buchstaben}
+ if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin
+ inhalt[cursorPosition]:=key-ord('A')+1;
+ exit;
+ end;
+ if (key in [109,189]) then begin
+ inhalt[cursorPosition]:=0;
+ exit;
+ end;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if (key>=ord('1')) and (key<=min(ord('1')+groeszen[0]-1,ord('9'))) then begin
+ inhalt[cursorPosition]:=key-ord('1')+1;
+ exit;
+ end;
+ {$ENDIF}
+ if (key=ord(' ')) or (key=46) or (key=8) then begin
+ inhalt[cursorPosition]:=-1;
+ exit;
+ end;
+ result:=false;
+end;
+{$ENDIF}
+
+{$IFDEF loesen}
+// function tHochhausRaetsel.loesen(lPos: integer): boolean;
+var
+ i,p: integer;
+ perm: tLongintArray;
+begin
+ result:=false;
+ setlength(perm,0);
+ for p:=lPos+1 to dim*dim-1 do
+ if inhalt[P]=-1 then begin
+ {$IFDEF buchstaben}
+ perm:=permutation(groeszen[0]+1);
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ perm:=permutation(dim);
+ {$ENDIF}
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ inhalt[P]:=Perm[I];
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ inhalt[P]:=Perm[I]+1;
+ {$ENDIF}
+ if passt(P mod dim,P div dim) then
+ if loesen(P) then begin
+ result:=true;
+ exit;
+ end;
+ end;
+ inhalt[P]:=-1;
+ exit;
+ end;
+ result:=true;
+end;
+{$ENDIF}
+
+{$IFDEF anzLoesungen}
+// function tHochhausRaetsel.anzLoesungen(lPos: integer): integer;
+var
+ i,p: integer;
+begin
+ result:=0;
+ for P:=lPos+1 to dim*dim-1 do
+ if inhalt[P]=-1 then begin
+ for
+ {$IFDEF hochhaus} I:=1 {$ENDIF}
+ {$IFDEF buchstaben}I:=0 {$ENDIF}
+ to groeszen[0] do begin
+ inhalt[P]:=I;
+ if passt(P mod dim,P div dim) then
+ result:=result+Anzloesungen(P);
+ if result>=2 then begin
+ inhalt[P]:=-1;
+ exit;
+ end;
+ end;
+ inhalt[P]:=-1;
+ exit;
+ end;
+ result:=1;
+end;
+{$ENDIF}
diff --git a/raetselunit.pas b/raetselunit.pas
index 6c77ce6..19306a8 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, Forms, Spin, Controls, StdCtrls, ExtCtrls, LCLType,
- lowlevelunit, Messages, ComCtrls;
+ lowlevelunit, Messages, ComCtrls, Graphics;
type
tAlphabetFunktion = function(i: longint): string;
@@ -16,6 +16,10 @@ type
procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
end;
+ tSmarterCheckBox = class(tCheckBox)
+ function width: longint;
+ end;
+
tRaetsel = class
private
besitzer: tForm;
@@ -23,18 +27,25 @@ type
zeichenflaeche: tImage;
erzeugeBtn: tButtonWithArrowKeys;
progressbar1: tProgressBar;
+ aktuelleFarbe: tColor;
function besitzerHoehe: longint; dynamic;
function besitzerBreite: longint; dynamic;
procedure zeichenFlaecheNeuKreieren;
procedure onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); dynamic; abstract;
procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); dynamic; abstract;
+ procedure onFarbWahlMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint);
+ procedure onFarbWahlMouseMove(sender: tObject; shiftState: tShiftState; x,y: longint);
+ procedure onFarbWahlMouseUp(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint);
procedure erzeugeOnClick(sender: tObject);
+ procedure farbWahlFlaecheBemalen;
procedure loeschen; dynamic; abstract;
procedure leeren; dynamic; abstract;
- function loesen(inhaltBehalten: boolean; lPos: longint): longint; dynamic; abstract;
+ function loesen(lPos: longint): boolean; dynamic; abstract;
+ function anzLoesungen(lPos: longint): longint; dynamic; abstract;
function passtZumZeichnen(spalte,zeile: integer): boolean; dynamic; abstract;
function passt(spalte,zeile: integer): boolean; dynamic; abstract;
function geloest: boolean; dynamic; abstract;
+ procedure randErzeugen; dynamic; abstract;
public
constructor create(aOwner: tForm);
destructor destroy; override;
@@ -42,11 +53,13 @@ type
end;
tFelderRaetsel = class(tRaetsel)
+ private
spinEdits: array of tSpinEdit;
- diagonalenCB,sudokuCB: tCheckBox;
+ diagonalenCB,sudokuCB: tSmarterCheckBox;
groeszen,inhalt,rand: array of longint;
- moeglich: array of int64;
- dim,schriftGroesze,cursorPosition: longint;
+ AMoeglich,EMoeglich: array of boolean;
+ dim,nSqrt,schriftGroesze,
+ cursorPosition: longint;
zellGroesze: extended;
uebersetze: tAlphabetFunktion;
procedure anzSEsOnChange(sender: tObject);
@@ -80,13 +93,16 @@ type
{$UNDEF interface}
+function farbverlauf(wo: extended): tColor;
+function RGB2TColor(R,G,B: Extended): TColor; inline;
+
const
spacing = 2;
implementation
uses
- math, dialogs;
+ math, dialogs, lclintf;
{$DEFINE alphabetFunktion}
function zahlenAlphabetFunktion(i: longint): string;
@@ -99,6 +115,37 @@ function buchstabenAlphabetFunktion(i: longint): string;
{$UNDEF buchstaben}
{$UNDEF alphabetFunktion}
+function farbverlauf(wo: extended): tColor;
+const
+ R: array[0..6] of extended = (0.5,0.9,0.9, 0, 0,0.2,0);
+ G: array[0..6] of extended = ( 0,0.5,0.9,0.7,0.7,0.2,0);
+ B: array[0..6] of extended = (0.7, 0, 0, 0,0.7, 1,0);
+var
+ i: integer;
+begin
+ wo:=wo*(length(R)-1);
+ I:=floor(Wo);
+ Wo:=Wo-I;
+ if I<0 then begin
+ result:=RGB2TColor(R[0],G[0],B[0]);
+ exit;
+ end;
+ if I>=(length(R)-1) then begin
+ result:=RGB2TColor(R[length(R)-1],G[length(R)-1],B[length(R)-1]);
+ exit;
+ end;
+ result:=RGB2TColor(R[I+1]*Wo+R[I]*(1-Wo),
+ G[I+1]*Wo+G[I]*(1-Wo),
+ B[I+1]*Wo+B[I]*(1-Wo));
+end;
+
+function RGB2TColor(R,G,B: extended): tColor;
+begin
+ result:=max(0,min($FF,round(R*$100))) or
+ (max(0,min($FF,round(G*$100))) shl 8) or
+ (max(0,min($FF,round(B*$100))) shl 16);
+end;
+
// tButtonWithArrowkeys ********************************************************
procedure tButtonWithArrowkeys.WMGetDlgCode(var msg: tWMGetDLGCODE);// message WM_GETDLGCODE;
@@ -107,6 +154,20 @@ begin
msg.Result := msg.Result or DLGC_WANTARROWS;
end;
+// tSmarterCheckBox ************************************************************
+
+function tSmarterCheckBox.width: longint;
+var
+ c: tCanvas;
+begin
+ c:=tCanvas.create;
+ c.handle:=getDC(handle);
+ c.font:=font;
+ result:=height+c.textWidth(caption);
+ releaseDC(handle,c.handle);
+ c.free;
+end;
+
// tRaetsel ********************************************************************
constructor tRaetsel.create(aOwner: tForm);
@@ -116,6 +177,11 @@ begin
zeichenflaeche:=tImage.create(besitzer);
zeichenflaeche.parent:=besitzer;
zeichenflaeche.onMouseDown:=@onMouseDown;
+ farbWahlFlaeche:=tImage.create(besitzer);
+ farbWahlFlaeche.parent:=besitzer;
+ farbWahlFlaeche.onMouseDown:=@onFarbWahlMouseDown;
+ farbWahlFlaeche.onMouseMove:=@onFarbWahlMouseMove;
+ farbWahlFlaeche.onMouseUp:=@onFarbWahlMouseUp;
erzeugeBtn:=tButtonWithArrowKeys.create(besitzer);
erzeugeBtn.parent:=besitzer;
erzeugeBtn.left:=spacing;;
@@ -131,6 +197,7 @@ end;
destructor tRaetsel.destroy;
begin
zeichenflaeche.free;
+ farbWahlFlaeche.free;
inherited destroy;
end;
@@ -158,13 +225,67 @@ begin
i.onMouseDown:=zeichenflaeche.onMouseDown;
zeichenflaeche.free;
zeichenflaeche:=i;
+
+ i:=tImage.create(besitzer);
+ i.parent:=farbWahlFlaeche.parent;
+ i.left:=farbWahlFlaeche.left;
+ i.top:=farbWahlFlaeche.top;
+ i.width:=farbWahlFlaeche.width;
+ i.height:=farbWahlFlaeche.height;
+ i.onMouseDown:=farbWahlFlaeche.onMouseDown;
+ i.onMouseMove:=farbWahlFlaeche.onMouseMove;
+ i.onMouseUp:=farbWahlFlaeche.onMouseUp;
+ farbWahlFlaeche.free;
+ farbWahlFlaeche:=i;
+ farbWahlFlaecheBemalen;
+end;
+
+procedure tRaetsel.onFarbWahlMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint);
+begin
+ if Button<>mbLeft then
+ exit;
+ aktuelleFarbe:=Farbverlauf(X/farbWahlFlaeche.Width);
+ farbWahlFlaecheBemalen;
+end;
+
+procedure tRaetsel.onFarbWahlMouseMove(sender: tObject; shiftState: tShiftState; x,y: longint);
+begin
+ if not(ssLeft in shiftState) then
+ exit;
+ aktuelleFarbe:=Farbverlauf(X/farbWahlFlaeche.Width);
+ farbWahlFlaecheBemalen;
+end;
+
+procedure tRaetsel.onFarbWahlMouseUp(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint);
+begin
+ if Button<>mbLeft then
+ exit;
+ aktuelleFarbe:=Farbverlauf(X/farbWahlFlaeche.Width);
+ farbWahlFlaecheBemalen;
end;
procedure tRaetsel.erzeugeOnClick(sender: tObject);
begin
loeschen;
- loesen(true,-1);
+ loesen(-1);
+ randErzeugen;
leeren;
+ // TODO: Startfelder setzen
+ zeichnen;
+end;
+
+procedure tRaetsel.farbWahlFlaecheBemalen;
+var
+ i: integer;
+begin
+ farbWahlFlaeche.Canvas.Pen.Color:=aktuelleFarbe;
+ farbWahlFlaeche.Canvas.Brush.Color:=aktuelleFarbe;
+ farbWahlFlaeche.Canvas.Rectangle(0,0,farbWahlFlaeche.width,farbWahlFlaeche.height div 2);
+ For I:=0 to farbWahlFlaeche.width-1 do begin
+ farbWahlFlaeche.Canvas.Pen.Color:=farbverlauf(I/farbWahlFlaeche.Width);
+ farbWahlFlaeche.Canvas.Moveto(I,farbWahlFlaeche.height div 2);
+ farbWahlFlaeche.Canvas.Lineto(I,farbWahlFlaeche.height);
+ end;
end;
// tFelderRaetsel **************************************************************
@@ -180,6 +301,7 @@ begin
setlength(groeszen,length(spinEdits)-1);
for i:=0 to length(spinEdits)-1 do begin
spinEdits[i]:=tSpinEdit.create(besitzer);
+ spinEdits[i].onKeyDown:=@onKeyDown;
if i=1 then
groeszen[i-1]:=5
else if i>1 then
@@ -200,18 +322,23 @@ begin
spinEdits[0].showHint:=true;
spinEdits[0].hint:='Schriftgröße';
spinEdits[0].value:=14;
- diagonalenCB:=tCheckBox.create(besitzer);
+ diagonalenCB:=tSmarterCheckBox.create(besitzer);
diagonalenCB.parent:=besitzer;
diagonalenCB.caption:='Diagonalen';
- diagonalenCB.top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
- diagonalenCB.left:=spinEdits[length(spinEdits)-1].left+spinEdits[length(spinEdits)-1].width+spacing;
- sudokuCB:=tCheckBox.create(besitzer);
+ diagonalenCB.top:=spinEdits[length(spinEdits)-1].top+spinEdits[length(spinEdits)-1].height+spacing;
+ diagonalenCB.left:=spacing;
+ diagonalenCB.onKeyDown:=@onKeyDown;
+ sudokuCB:=tSmarterCheckBox.create(besitzer);
sudokuCB.parent:=besitzer;
sudokuCB.caption:='Sudoku';
- sudokuCB.top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
+ sudokuCB.top:=diagonalenCB.top;
sudokuCB.left:=diagonalenCB.left+diagonalenCB.width+spacing;
+ sudokuCB.onKeyDown:=@onKeyDown;
+ farbWahlFlaeche.left:=spacing;
+ farbWahlFlaeche.top:=diagonalenCB.top+diagonalenCB.height+spacing;
+ farbWahlFlaeche.height:=16;
zeichenflaeche.left:=spacing;
- zeichenflaeche.top:=diagonalenCB.top+diagonalenCB.height+spacing;
+ zeichenflaeche.top:=farbWahlFlaeche.top+farbWahlFlaeche.height+spacing;
aktualisiereGroesze;
end;
@@ -284,7 +411,13 @@ begin
dim:=dim+groeszen[i];
end;
setlength(inhalt,dim*dim);
- setlength(rand,4*(dim+1));
+ setlength(rand,4*dim);
+
+ NSqrt:=round(sqrt(dim));
+ sudokuCB.enabled:=Sqr(NSqrt)=dim;
+ if (not sudokuCB.enabled) and sudokuCB.checked then
+ sudokuCB.checked:=false;
+
loeschen;
cursorPosition:=0;
gesamtRaenderErzeugen;
@@ -307,23 +440,33 @@ var
i,w: longint;
begin
p:=permutation(dim*dim);
+ progressbar1.step:=1;
+ progressbar1.min:=0;
+ progressbar1.max:=dim*(dim+4);
+ progressbar1.position:=0;
+ progressbar1.visible:=true;
for i:=0 to length(p)-1 do begin
+ progressbar1.stepIt;
+ application.processMessages;
if inhalt[p[i]]<0 then
continue;
w:=inhalt[p[i]];
inhalt[p[i]]:=-1;
- if loesen(false,-1)<>1 then
+ if anzLoesungen(-1)<>1 then
inhalt[p[i]]:=w;
end;
- p:=permutation((dim+1)*4);
+ p:=permutation(dim*4);
for i:=0 to length(p)-1 do begin
+ progressbar1.stepIt;
+ application.processMessages;
if rand[p[i]]<0 then continue;
w:=rand[p[i]];
rand[p[i]]:=-1;
- if loesen(false,-1)<>1 then
+ if anzLoesungen(-1)<>1 then
rand[p[i]]:=w;
end;
+ progressbar1.visible:=false;
end;
procedure tFelderRaetsel.aktualisiereZeichenflaechenGroesze;
@@ -337,10 +480,17 @@ begin
);
zeichenflaeche.height:=round((dim+2)*zellGroesze);
zeichenflaeche.width:=zeichenflaeche.height;
+ farbWahlFlaeche.height:=16;
+ farbWahlFlaeche.width:=zeichenflaeche.width;
zeichenFlaecheNeuKreieren;
- progressbar1.width:=besitzerBreite;
besitzer.height:=besitzerHoehe;
- besitzer.width:=besitzerBreite;
+ besitzer.width:=
+ max(max(
+ besitzerBreite,
+ sudokuCB.left+sudokuCB.width+spacing),
+ spinEdits[length(spinEdits)-1].left+spinEdits[length(spinEdits)-1].width+spacing
+ );
+ progressbar1.width:=besitzer.width;
zeichnen;
end;
@@ -370,7 +520,7 @@ begin
s:=uebersetze(i);
with zeichenflaeche.canvas do begin
brush.color:=$FFFFFF - $181818*byte(diagonalenCB.checked and ((x=y) or (x+y=dim+1)));
- if (x>=0) and (y>=0) and (x<dim) and (y<dim) and not passtZumZeichnen(x,y) then
+ if not passtZumZeichnen(x,y) then
font.color:=$0000FF
else if geloest then
font.color:=$007F00
@@ -398,6 +548,22 @@ begin
zeichenflaeche.canvas.rectangle(-10,-10,zeichenflaeche.width+10,zeichenflaeche.height+10);
zeichenflaeche.canvas.pen.width:=3;
zeichenflaeche.canvas.pen.color:=$000000;
+ if diagonalenCB.checked then
+ for i:=1 to dim do begin
+ zeichenflaeche.canvas.brush.color:=$ffffff - $181818;
+ zeichenflaeche.canvas.fillRect(
+ round(i*zellGroesze),
+ round(i*zellGroesze),
+ round((i+1)*zellGroesze),
+ round((i+1)*zellGroesze)
+ );
+ zeichenflaeche.canvas.fillRect(
+ round(i*zellGroesze),
+ round((dim-i+1)*zellGroesze),
+ round((i+1)*zellGroesze),
+ round((dim-i+2)*zellGroesze)
+ );
+ end;
for i:=0 to dim do
with zeichenflaeche.canvas do begin
moveTo(round((i+1)*zellGroesze),round(zellGroesze));
@@ -406,13 +572,22 @@ begin
lineTo(round((dim+1)*zellGroesze),round((i+1)*zellGroesze));
end;
zeichenflaeche.canvas.pen.color:=$8080ff;
- if (cursorPosition>=0) and (dim>0) then
+ if (cursorPosition>=0) and (dim>0) then begin
+ zeichenflaeche.canvas.brush.color:=
+ $ffffff - $181818 * byte(
+ diagonalenCB.checked and (
+ (cursorPosition mod (dim+1)=0) or
+ (cursorPosition mod (dim-1)=0)
+ )
+ );
zeichenflaeche.canvas.rectangle(
round(((cursorPosition mod dim)+1)*zellGroesze),
round(((cursorPosition div dim)+1)*zellGroesze),
round(((cursorPosition mod dim)+2)*zellGroesze+1),
round(((cursorPosition div dim)+2)*zellGroesze+1)
);
+ end;
+ zeichenflaeche.canvas.brush.color:=$ffffff;
for i:=0 to dim-1 do begin
schreibeZentriert(i,-1,rand[i]);
schreibeZentriert(dim,i,rand[dim+i]);
@@ -490,5 +665,60 @@ function tBuchstabenRaetsel.passtZumZeichnen(spalte,zeile: integer): boolean;
{$UNDEF buchstaben}
{$UNDEF passtZumZeichnen}
+{$DEFINE randErzeugen}
+procedure tHochhausRaetsel.randErzeugen;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+procedure tBuchstabenRaetsel.randErzeugen;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF randErzeugen}
+
+{$DEFINE relativeInhaltsAenderung}
+procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: integer);
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+procedure tBuchstabenRaetsel.relativeInhaltsAenderung(diff: integer);
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF relativeInhaltsAenderung}
+
+{$DEFINE absoluteInhaltsAenderung}
+function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.absoluteInhaltsAenderung(key: word): boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF absoluteInhaltsAenderung}
+
+{$DEFINE loesen}
+function tHochhausRaetsel.loesen(lPos: integer): boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.loesen(lPos: integer): boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF loesen}
+
+{$DEFINE anzLoesungen}
+function tHochhausRaetsel.anzLoesungen(lPos: integer): integer;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.anzLoesungen(lPos: integer): integer;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF anzLoesungen}
+
end.