diff options
author | Erich Eckner <git@eckner.net> | 2018-10-01 11:21:32 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-01 11:21:32 +0200 |
commit | fe01ae9355e0fddf2100e165d07fb41ae68b3470 (patch) | |
tree | a766e156d5367ed4b40213cf57b38d74882ec575 /raetselunit.inc | |
parent | 0c70d338a4157e59cb25f4881a349105957486a0 (diff) | |
download | Raetsel-fe01ae9355e0fddf2100e165d07fb41ae68b3470.tar.xz |
raetselunit.inc: passtZumZeichnen neu
Diffstat (limited to 'raetselunit.inc')
-rw-r--r-- | raetselunit.inc | 101 |
1 files changed, 92 insertions, 9 deletions
diff --git a/raetselunit.inc b/raetselunit.inc index 57e68fd..5d40b2d 100644 --- a/raetselunit.inc +++ b/raetselunit.inc @@ -10,6 +10,9 @@ type private // 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; public {$IFDEF buchstaben} NBuchst, @@ -20,16 +23,11 @@ type constructor create(aOwner: tForm); destructor destroy; override; procedure gesamtRaenderErzeugen; -(* function passtZumZeichnen(Spalte,Zeile: integer): boolean; - procedure Zeichnen; - procedure schreibe(was: String; Spalte,Zeile: integer); *) - function passt(spalte,zeile: integer): boolean; override; // function Loesen(lPos: integer): boolean; - function geloest: boolean; -(* procedure leeren; - procedure RandErzeugen; - function anzLoesungen(lPos: integer): integer; - procedure Image2Bemalen; *) +// procedure leeren; +// procedure RandErzeugen; +// function anzLoesungen(lPos: integer): integer; +// procedure Image2Bemalen; end; {$IFDEF hochhaus} @@ -437,3 +435,88 @@ begin closefile(dat); end; {$ENDIF} + +{$IFDEF passtZumZeichnen} +// function tHochhausRaetsel.passtZumZeichnen(spalte,zeile: integer): boolean; +var + I,KS,KZ: Integer; + W,S: Longint; +begin + {$IFDEF buchstaben} + if inhalt[Zeile*dim+Spalte]=-1 then begin + {$ENDIF} + {$IFDEF hochhaus} + if inhalt[Zeile*dim+Spalte]=0 then begin + {$ENDIF} + result:=false; + exit; + end; + W:=0; + S:=0; + for I:=0 to dim-1 do begin + {$IFDEF buchstaben} + W:=W*(NBuchst+2)+inhalt[Zeile*dim+I]+1; + S:=S*(NBuchst+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]; + {$ENDIF} + end; + Result:= + {$IFDEF buchstaben} + (EMoeglich[S*(NBuchst+1)+Rand[Spalte]] or not EMoeglich[S*(NBuchst+1)]) and + (AMoeglich[W*(NBuchst+1)+Rand[dim+Zeile]] or not AMoeglich[W*(NBuchst+1)]) and + (AMoeglich[S*(NBuchst+1)+Rand[2*dim+Spalte]] or not AMoeglich[S*(NBuchst+1)]) and + (EMoeglich[W*(NBuchst+1)+Rand[3*dim+Zeile]] or not EMoeglich[W*(NBuchst+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)]); + {$ENDIF} + {$IFDEF buchstaben} + if inhalt[Zeile*dim+Spalte]=0 then + W:=NLeer + 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); + 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 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 inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]=inhalt[Zeile*dim+Spalte] then + dec(S); + Result:=Result and (S>0); + 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} + |