diff options
-rw-r--r-- | buchstabenunit.pas | 14 | ||||
-rw-r--r-- | hochhausunit.pas | 6 | ||||
-rw-r--r-- | raetsel.lps | 111 | ||||
-rw-r--r-- | raetselunit.pas | 73 |
4 files changed, 139 insertions, 65 deletions
diff --git a/buchstabenunit.pas b/buchstabenunit.pas index 718a70d..42d7f33 100644 --- a/buchstabenunit.pas +++ b/buchstabenunit.pas @@ -15,6 +15,7 @@ type public constructor create(aOwner: tForm); destructor destroy; override; + function gleichzeitigMoeglich(num: longint): longint; override; function _loesen(lm: tFelderLoesMeta): longint; override; end; @@ -84,7 +85,17 @@ begin result:=false; end; +function tBuchstabenRaetsel.gleichzeitigMoeglich(num: longint): longint; +begin + if num=0 then + result:=groeszen[0] // so viele Leerzeichen + else + result:=1; // jeder Buchstabe nur ein Mal +end; + function tBuchstabenRaetsel._loesen(lm: tFelderLoesMeta): longint; +var + w: longint; begin if not lm.fwd then begin result:=1; @@ -99,8 +110,9 @@ begin //for if not lm.inhaltBehalten then begin + w:=inhalt[lm.posi]; inhalt[lm.posi]:=-1; - lm.aktualisiereInhalt(lm.posi); + lm.aktualisiereInhalt(lm.posi,w); end; end; diff --git a/hochhausunit.pas b/hochhausunit.pas index 7a98f6a..f53270c 100644 --- a/hochhausunit.pas +++ b/hochhausunit.pas @@ -15,6 +15,7 @@ type public constructor create(aOwner: tForm); destructor destroy; override; + function gleichzeitigMoeglich(num: longint): longint; override; function _loesen(lm: tFelderLoesMeta): longint; override; end; @@ -73,6 +74,11 @@ begin result:=false; end; +function tHochhausRaetsel.gleichzeitigMoeglich(num: longint): longint; +begin + result:=1; // jede Höhe nur ein Mal +end; + function tHochhausRaetsel._loesen(lm: tFelderLoesMeta): longint; begin diff --git a/raetsel.lps b/raetsel.lps index 9ca4488..c9d11fe 100644 --- a/raetsel.lps +++ b/raetsel.lps @@ -9,7 +9,7 @@ <IsPartOfProject Value="True"/> <EditorIndex Value="-1"/> <CursorPos Y="18"/> - <UsageCount Value="39"/> + <UsageCount Value="40"/> </Unit0> <Unit1> <Filename Value="unit1.pas"/> @@ -19,7 +19,7 @@ <ResourceBaseClass Value="Form"/> <TopLine Value="10"/> <CursorPos X="38" Y="34"/> - <UsageCount Value="39"/> + <UsageCount Value="40"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> </Unit1> @@ -32,17 +32,18 @@ <UnitName Value="Unit2"/> <EditorIndex Value="4"/> <CursorPos X="20" Y="12"/> - <UsageCount Value="38"/> + <UsageCount Value="39"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> </Unit2> <Unit3> <Filename Value="raetselunit.pas"/> <IsPartOfProject Value="True"/> + <IsVisibleTab Value="True"/> <EditorIndex Value="1"/> - <TopLine Value="22"/> - <CursorPos Y="51"/> - <UsageCount Value="33"/> + <TopLine Value="148"/> + <CursorPos X="64" Y="181"/> + <UsageCount Value="34"/> <Loaded Value="True"/> </Unit3> <Unit4> @@ -99,140 +100,142 @@ <Unit11> <Filename Value="buchstabenunit.pas"/> <IsPartOfProject Value="True"/> - <IsVisibleTab Value="True"/> <EditorIndex Value="3"/> - <TopLine Value="8"/> - <CursorPos X="8" Y="26"/> - <UsageCount Value="20"/> + <TopLine Value="60"/> + <CursorPos X="55" Y="93"/> + <UsageCount Value="21"/> <Loaded Value="True"/> </Unit11> <Unit12> <Filename Value="hochhausunit.pas"/> <IsPartOfProject Value="True"/> <EditorIndex Value="2"/> - <CursorPos X="36" Y="8"/> - <UsageCount Value="20"/> + <TopLine Value="45"/> + <CursorPos X="22" Y="19"/> + <UsageCount Value="21"/> <Loaded Value="True"/> </Unit12> </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> - <Filename Value="hochhausunit.pas"/> - <Caret Line="65"/> + <Filename Value="buchstabenunit.pas"/> + <Caret Line="91" Column="20" TopLine="62"/> </Position1> <Position2> - <Filename Value="hochhausunit.pas"/> - <Caret Line="21"/> + <Filename Value="buchstabenunit.pas"/> + <Caret Line="19"/> </Position2> <Position3> - <Filename Value="unit1.pas"/> - <Caret Line="8" Column="76"/> + <Filename Value="hochhausunit.pas"/> + <Caret Line="26" Column="8"/> </Position3> <Position4> - <Filename Value="unit1.pas"/> - <Caret Line="34" Column="38" TopLine="10"/> + <Filename Value="hochhausunit.pas"/> + <Caret Line="8" Column="36"/> </Position4> <Position5> - <Filename Value="hochhausunit.pas"/> - <Caret Line="8" Column="33"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="135" Column="18" TopLine="92"/> </Position5> <Position6> <Filename Value="raetselunit.pas"/> - <Caret Line="84" TopLine="62"/> + <Caret Line="22" Column="27" TopLine="7"/> </Position6> <Position7> - <Filename Value="hochhausunit.pas"/> - <Caret Line="8" Column="40"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="98" TopLine="82"/> </Position7> <Position8> - <Filename Value="hochhausunit.pas"/> - <Caret Line="15" Column="21"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="335" Column="18" TopLine="299"/> </Position8> <Position9> - <Filename Value="buchstabenunit.pas"/> - <Caret Line="21"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="132" Column="36" TopLine="115"/> </Position9> <Position10> - <Filename Value="buchstabenunit.pas"/> - <Caret Line="84" Column="36" TopLine="62"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="30" Column="33" TopLine="8"/> </Position10> <Position11> <Filename Value="raetselunit.pas"/> + <Caret Line="132" Column="45" TopLine="96"/> </Position11> <Position12> <Filename Value="raetselunit.pas"/> - <Caret Line="46" Column="21" TopLine="31"/> + <Caret Line="372" Column="34" TopLine="339"/> </Position12> <Position13> <Filename Value="raetselunit.pas"/> - <Caret Line="330" Column="18" TopLine="294"/> + <Caret Line="357" Column="34" TopLine="335"/> </Position13> <Position14> <Filename Value="raetselunit.pas"/> - <Caret Line="349" Column="15" TopLine="325"/> + <Caret Line="31" Column="37" TopLine="8"/> </Position14> <Position15> <Filename Value="raetselunit.pas"/> - <Caret Line="366" Column="11" TopLine="325"/> + <Caret Line="132" Column="51" TopLine="110"/> </Position15> <Position16> - <Filename Value="hochhausunit.pas"/> - <Caret Line="15" Column="14"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="144" Column="49" TopLine="122"/> </Position16> <Position17> - <Filename Value="raetselunit.pas"/> - <Caret Line="54" Column="3" TopLine="47"/> + <Filename Value="buchstabenunit.pas"/> + <Caret Line="106" Column="36" TopLine="65"/> </Position17> <Position18> <Filename Value="raetselunit.pas"/> - <Caret Line="330" Column="18" TopLine="294"/> + <Caret Line="143" Column="38" TopLine="113"/> </Position18> <Position19> <Filename Value="raetselunit.pas"/> - <Caret Line="349" Column="15" TopLine="328"/> + <Caret Line="132" Column="36" TopLine="121"/> </Position19> <Position20> <Filename Value="raetselunit.pas"/> - <Caret Line="361" Column="15" TopLine="328"/> + <Caret Line="30" Column="33" TopLine="8"/> </Position20> <Position21> <Filename Value="raetselunit.pas"/> + <Caret Line="132" Column="45" TopLine="96"/> </Position21> <Position22> - <Filename Value="hochhausunit.pas"/> - <Caret Line="15" Column="14"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="372" Column="26" TopLine="336"/> </Position22> <Position23> <Filename Value="raetselunit.pas"/> - <Caret Line="46" Column="55" TopLine="28"/> + <Caret Line="375" Column="28" TopLine="339"/> </Position23> <Position24> <Filename Value="raetselunit.pas"/> - <Caret Line="91" Column="16" TopLine="69"/> + <Caret Line="58" Column="14"/> </Position24> <Position25> <Filename Value="raetselunit.pas"/> - <Caret Line="46" Column="53" TopLine="12"/> + <Caret Line="143" Column="14" TopLine="121"/> </Position25> <Position26> - <Filename Value="hochhausunit.pas"/> - <Caret Line="19"/> + <Filename Value="buchstabenunit.pas"/> + <Caret Line="106" Column="35" TopLine="68"/> </Position26> <Position27> <Filename Value="buchstabenunit.pas"/> - <Caret Line="91" Column="20" TopLine="62"/> + <Caret Line="19"/> </Position27> <Position28> <Filename Value="buchstabenunit.pas"/> - <Caret Line="19"/> + <Caret Line="93" Column="55" TopLine="60"/> </Position28> <Position29> <Filename Value="hochhausunit.pas"/> - <Caret Line="26" Column="8"/> + <Caret Line="79" Column="39" TopLine="40"/> </Position29> <Position30> - <Filename Value="hochhausunit.pas"/> - <Caret Line="8" Column="36"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="171" TopLine="133"/> </Position30> </JumpHistory> </ProjectSession> diff --git a/raetselunit.pas b/raetselunit.pas index 2d60340..dc6741c 100644 --- a/raetselunit.pas +++ b/raetselunit.pas @@ -19,6 +19,7 @@ type _perm: tLongintArray; _mgl: tInt64Array; _posi: longint; + _fr: tFelderRaetsel; public constructor create(ib: boolean; fr: tFelderRaetsel); destructor destroy; @@ -26,8 +27,8 @@ type function fwd: boolean; procedure rev; property inhaltBehalten: boolean read _inh; - procedure aktualisiereInhalt(p: longint); - procedure aktualisiereRand(p: longint); + procedure aktualisiereInhalt(p,alt: longint); + procedure aktualisiereRand(p,alt: longint); end; tRaetsel = class @@ -47,6 +48,7 @@ type public constructor create(aOwner: tForm); destructor destroy; override; + function gleichzeitigMoeglich(num: longint): longint; dynamic; abstract; function _loesen(lm: tFelderLoesMeta): longint; dynamic; abstract; procedure zeichnen; dynamic; abstract; end; @@ -93,6 +95,7 @@ var i: longint; begin inherited create; + _fr:=fr; _inh:=ib; _perm:=permutation(length(fr.inhalt)); setlength(_perm,length(_perm)+1); @@ -127,14 +130,64 @@ begin dec(_posi); end; -procedure tFelderLoesMeta.aktualisiereInhalt(p: longint); +procedure tFelderLoesMeta.aktualisiereInhalt(p,alt: longint); +var + i,j,x,y,cnt,neu: longint; + maske: int64; begin - + // hier sollte die Zeile und Spalte von _mgl[p] aktualisiert werden + x:=p mod _fr.dim; + y:=p div _fr.dim; + neu:=_fr.inhalt[p]; + if neu<>-1 then begin + if alt<>-1 then begin + _fr.inhalt[p]:=-1; + aktualisiereInhalt(p,alt); + _fr.inhalt[p]:=neu; + alt:=-1; + end; + cnt:=_fr.gleichzeitigMoeglich(p); + maske:=1 shr _fr.inhalt[p]; + _mgl[p]:=maske; + if cnt>1 then begin + j:=0; + for i:=0 to _fr.dim-1 do + j:=j+byte(_fr.inhalt[y*_fr.dim+i]=neu); + if j>=cnt then + for i:=0 to _fr.dim-2 do + _mgl[i*_fr.dim+i+byte(i>=x)]:=_mgl[i*_fr.dim+i+byte(i>=x)] and not maske; + j:=0; + for i:=0 to _fr.dim-1 do + j:=j+byte(_fr.inhalt[i*_fr.dim+x]=neu); + if j>=cnt then + for i:=0 to _fr.dim-2 do + _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] and not maske; + // TODO: Diagonalen + end + else begin + for i:=0 to _fr.dim-2 do begin + _mgl[y*_fr.dim+i+byte(i>=x)]:=_mgl[y*_fr.dim+i+byte(i>=x)] and not maske; + _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] and not maske; + end; + // TODO: Diagonalen + end; + end + else begin + if alt=-1 then + exit; + maske:=1 shr alt; + for i:=0 to _fr.dim-2 do begin + _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] or maske; + _mgl[y*_fr.dim+x+byte(i>=x)]:=_mgl[y*_fr.dim+x+byte(i>=x)] or maske; + end; + // TODO: Diagonalen + // TODO: _mgl[p] + end; end; -procedure tFelderLoesMeta.aktualisiereRand(p: longint); +procedure tFelderLoesMeta.aktualisiereRand(p,alt: longint); begin - + // hier sollte die Zeile bzw. Spalte von _rand[p] aktualisiert werden end; // tRaetsel ******************************************************************** @@ -345,10 +398,10 @@ begin if inhalt[p[i]]<0 then continue; w:=inhalt[p[i]]; inhalt[p[i]]:=-1; - lm.aktualisiereInhalt(p[i]); + lm.aktualisiereInhalt(p[i],w); if _loesen(lm)<>1 then begin inhalt[p[i]]:=w; - lm.aktualisiereInhalt(p[i]); + lm.aktualisiereInhalt(p[i],-1); end; end; @@ -357,10 +410,10 @@ begin if rand[p[i]]<0 then continue; w:=rand[p[i]]; rand[p[i]]:=-1; - lm.aktualisiereRand(p[i]); + lm.aktualisiereRand(p[i],w); if _loesen(lm)<>1 then begin rand[p[i]]:=w; - lm.aktualisiereRand(p[i]); + lm.aktualisiereRand(p[i],-1); end; end; lm.free; |