-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathunit1.pas
1063 lines (984 loc) · 39.4 KB
/
unit1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(******************************************************************************)
(* Einstein ??.??.???? *)
(* *)
(* Version : 0.03 *)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* Support : www.Corpsman.de *)
(* *)
(* Description : Program to solve Einstein like puzzles *)
(* *)
(* License : See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(* Warranty : There is no warranty, neither in correctness of the *)
(* implementation, nor anything other that could happen *)
(* or go wrong, use at your own risk. *)
(* *)
(* Known Issues: none *)
(* *)
(* History : 0.01 - Initial version *)
(* 0.02 - Fix Absturz, wenn Brutefoce keine Lösung mehr findet. *)
(* 0.03 - IntDepends Regel implementiert *)
(* *)
(******************************************************************************)
{
http://www.techinsider.io/how-to-solve-einsteins-riddle-video-2015-9
https://www.logisch-gedacht.de/logikraetsel/einsteinraetsel/loesung/
https://udel.edu/~os/riddle-solution.html
}
Unit Unit1;
{$MODE objfpc}{$H+}
Interface
Uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Grids, Menus, ueinstein, ComCtrls;
Type
{ TForm1 }
TForm1 = Class(TForm)
ApplicationProperties1: TApplicationProperties;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
ComboBox1: TComboBox;
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
MenuItem10: TMenuItem;
MenuItem11: TMenuItem;
MenuItem12: TMenuItem;
MenuItem13: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
MenuItem8: TMenuItem;
MenuItem9: TMenuItem;
OpenDialog1: TOpenDialog;
PageControl1: TPageControl;
PageControl2: TPageControl;
PopupMenu1: TPopupMenu;
SaveDialog1: TSaveDialog;
ScrollBar1: TScrollBar;
StringGrid1: TStringGrid;
TabSheet6: TTabSheet;
TabSheet7: TTabSheet;
TabSheet8: TTabSheet;
Procedure ApplicationProperties1Idle(Sender: TObject; Var Done: Boolean);
Procedure Button1Click(Sender: TObject);
Procedure Button2Click(Sender: TObject);
Procedure Button3Click(Sender: TObject);
Procedure Button4Click(Sender: TObject);
Procedure Button5Click(Sender: TObject);
Procedure FormCloseQuery(Sender: TObject; Var CanClose: boolean);
Procedure FormCreate(Sender: TObject);
Procedure FormShow(Sender: TObject);
Procedure MenuItem10Click(Sender: TObject);
Procedure MenuItem11Click(Sender: TObject);
Procedure MenuItem12Click(Sender: TObject);
Procedure MenuItem13Click(Sender: TObject);
Procedure MenuItem2Click(Sender: TObject);
Procedure MenuItem3Click(Sender: TObject);
Procedure MenuItem4Click(Sender: TObject);
Procedure MenuItem5Click(Sender: TObject);
Procedure MenuItem6Click(Sender: TObject);
Procedure MenuItem8Click(Sender: TObject);
Procedure MenuItem9Click(Sender: TObject);
Procedure OnHideSetPage(Sender: TObject);
Procedure ScrollBar1Change(Sender: TObject);
Procedure StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
private
{ private declarations }
defcaption: String;
RuleList: Array Of TEinsteinRuleFrame;
Filename: String;
Procedure FixRulePositions;
Function ResolveXY(x, y: integer): String; // X = Durchnummerierung der Mengen, y = Eintrag (beides beginnend mit 0, -1 = nichts, -2 = Name der Kategorie
Procedure RefreshTexts;
Procedure SelfDeleteCallback(Sender: TEinsteinRuleFrame);
Procedure SavetoFile(FName: String);
Procedure LoadFromFile(Fname: String);
Procedure LogEvent(Logentry: String);
public
{ public declarations }
Procedure NewDimensions(SetCount, ElementPerSetCount: integer); // Löscht alles alte und Initialisiert entsprechend neu
End;
Var
Form1: TForm1;
DeletionItem: integer = -1;
Implementation
Uses
unit2, Unit3, unit4, ufifo,
LazFileUtils,
lazutf8, LCLType,
math,
IniFiles,
usetframe,
uonesetruleframe,
uonesetattribruleframe,
utwosetattribruleframe,
utwosetruleframe,
umultisetframe,
uintdepframe;
Var
Form1ShowFirst: Boolean = true; // Sorgt dafür das der Form1.Onshow nur 1 mal gemacht wird.
{$R *.lfm}
Const
// Inhalt der Combobox zur Auswahl der Regeln
(*
Depends on
Depends distance on
Eliminate
Eliminate distance
Left of
Left distance of
Right of
Right distance of
MultiEliminate
IntegerDepends
*)
IndexDependsOn = 0;
IndexDistanceDependsOn = 1;
IndexEliminate = 2;
IndexDistanceEliminate = 3;
IndexLeftOf = 4;
IndexDistanceLeftOf = 5;
IndexRightOf = 6;
IndexDistanceRightOf = 7;
IndexMultiEliminate = 8;
IndexIntegerDepends = 9;
// Farben
Rot = 0;
Gruen = 1;
Gelb = 2;
Blau = 3;
Weiss = 4;
// Nationalitäten
Brite = 0;
Schwede = 1;
Daene = 2;
Norweger = 3;
Deutsche = 4;
// Getränke
Tee = 0;
Kaffee = 1;
Milch = 2;
Bier = 3;
Wasser = 4;
// Zigaretten
Pallmall = 0;
Dunhill = 1;
Marlboro = 2;
Winfield = 3;
Rothmanns = 4;
// Tier
Hund = 0;
Vogel = 1;
Katze = 2;
Pferd = 3;
// Fisch = 4; -- Den gilt es zu bestimmen, deswegen ist der in keiner Regel ;)
(*
* Die Musterlösung :
*)
//Nummer 1 2 3 4 5
//Farbe gelb blau rot grün weiß
//Nationalität Norweger Däne Brite Deutscher Schwede
//Getränk Wasser Tee Milch Kaffee Bier
//Zigaretten Dunhill Marlboro Pall-Mall Rothmanns Winfield
//Tier Katze Pferd Vogel Fisch Hund
{ TForm1 }
Procedure TForm1.Button1Click(Sender: TObject);
Type
TFieldQueue = specialize TBufferedFifo < TDataField > ;
TStringQueue = specialize TBufferedFifo < String > ;
Function Clon(Const Source: TDataField): TDataField;
Var
i, j, k: integer;
Begin
setlength(result, length(source), length(source[0]));
For i := 0 To high(Source) Do Begin
For j := 0 To high(source[i]) Do Begin
setlength(result[i, j].pencils, length(source[i, j].pencils));
result[i, j].value := Source[i, j].value;
For k := 0 To high(source[i, j].pencils) Do Begin
result[i, j].pencils[k] := source[i, j].pencils[k];
End;
End;
End;
End;
Procedure Free_(Var Data: TDataField);
Var
i, j: Integer;
Begin
For i := 0 To high(data) Do Begin
For j := 0 To high(data[i]) Do Begin
setlength(data[i, j].pencils, 0);
End;
setlength(data[i], 0);
End;
setlength(data, 0);
End;
Var
x, xx, y, i, j, k: integer;
Rules: Array Of TRule;
m: TMemberSet;
found: Boolean;
s: String;
q: TFieldQueue;
sq: TStringQueue;
b: Boolean;
bkup: TDataField;
Begin
// Wenn ein Feld aufgrund eines vorangegangenen Versuches via Bruteforce Platt gemacht wurde, dann wird es hier neu erzeugt.
If Not assigned(data) Then Begin
setlength(data, EinsteinWidth, EinsteinHeight);
For i := 0 To EinsteinWidth - 1 Do Begin
For j := 0 To EinsteinHeight - 1 Do Begin
setlength(data[i, j].Pencils, EinsteinWidth);
End;
End;
End;
rules := Nil;
form2.ListBox1.Clear;
// Einlesen der Regeln
For i := 0 To high(RuleList) Do Begin
If RuleList[i].ValidRule Then Begin
setlength(rules, high(Rules) + 2);
rules[high(Rules)] := RuleList[i].DeriveRule;
rules[high(Rules)].Number := i + 1;
rules[high(Rules)].ResolveXY := @ResolveXY;
End;
End;
// Ein Leeres Feld
ResetData;
If (Not solve(rules, @logEvent, MenuItem11.Checked, false)) And MenuItem10.Checked Then Begin // 1 mal Raten
setlength(rules, high(Rules) + 2);
setlength(m, EinsteinHeight);
rules[high(rules)] := TGuess.Create(m);
rules[high(Rules)].Number := length(rules);
rules[high(Rules)].ResolveXY := @ResolveXY;
For y := 0 To EinsteinHeight - 1 Do
m[y] := Nichts;
found := false;
For x := 0 To EinsteinWidth - 1 Do Begin
m[0] := x;
For y := 1 To EinsteinHeight - 1 Do Begin
For xx := 0 To EinsteinWidth - 1 Do Begin
m[y] := xx;
form2.ListBox1.Clear;
(rules[high(Rules)] As TGuess).Active := false;
(rules[high(Rules)] As TGuess).UpdateGuess(m);
// Ein Leeres Feld
ResetData;
// 1. Soweit Lösen wie Möglich
found := solve(rules, @LogEvent, MenuItem11.Checked, true); // Da die Regel evtl durch den Plausibilitätscheck fällt muss hier die Warnung bereits unterbunden werden.
If Not found Then Begin
LogEvent('Could not solve the puzzle, adding guess rule.');
// 2. Die Vermutung anstellen und weiter Lösen
(rules[high(Rules)] As TGuess).Active := true;
// Was noch nicht sicher ist, ob geprüft werden muss, ob die Regel
// einen Schaden Anrichtet oder nicht (wenn, dann fliegt die AV bei SetValue)
found := solve(rules, @LogEvent, MenuItem11.Checked, true);
End;
If found Then break;
End;
If found Then break;
m[y] := Nichts; // In dieser Teilmenge gabs keine Lösung, also in der Nächsten Suchen..
End;
If found Then break;
End;
If found Then Begin
LogEvent('Attention, due to guessing the solution might not the one you''d expected.');
End;
End;
If (Not IsSolved) And MenuItem13.Checked Then Begin // Da guessing und BruteForce sich ausschließen reicht diese Prüfung
form2.ListBox1.items.Add('-- Enable bruteforce logic --');
q := TFieldQueue.create;
sq := TStringQueue.create;
sq.Push(Form2.ListBox1.Items.Text);
q.Push(clon(data));
Free_(data);
While (Not q.isempty) Do Begin
data := q.Pop;
Form2.ListBox1.Items.Text := sq.Pop;
// 1. Versuchen zu Lösen
found := solve(rules, @LogEvent, MenuItem11.Checked, true); // Da die Regel evtl durch den Plausibilitätscheck fällt muss hier die Warnung bereits unterbunden werden.
If found Then Begin
// Data ist Gültig, also die Queue leeren, damit die Ausgabe kommen kann
While (Not q.isempty) Do Begin
q.Pop;
End;
While (Not sq.isempty) Do Begin
sq.Pop;
End;
End
Else Begin
// 2. Hat nicht Geklappt, das näcshte "Freie" Feld suchen und mit allen Kombinationen Puschen die es gibt.
b := false;
For i := 0 To EinsteinWidth - 1 Do Begin
For j := 0 To EinsteinHeight - 1 Do Begin
If Data[i, j].value = nichts Then Begin
bkup := clon(data);
free_(Data);
For k := 0 To EinsteinWidth - 1 Do Begin
If bkup[i, j].pencils[k] Then Begin
data := Clon(bkup);
s := Form2.ListBox1.Items.Text;
SetValue(i, j, k);
s := s + format('Set [%s, %s] = %s', [ResolveXY(0, i), ResolveXY(j, ueinstein.SetName), ResolveXY(j, k)]);
sq.Push(s);
q.Push(Clon(data));
free_(data);
End;
End;
free_(bkup);
b := true;
break;
End;
End;
If b Then break;
End;
End;
End;
sq.free;
q.free;
End;
// Ausgabe
// Regeln wieder Frei geben
For i := 0 To high(rules) Do Begin
rules[i].free;
End;
setlength(Rules, 0);
StringGrid1.ColCount := EinsteinWidth + 1 + ord(MenuItem12.Checked);
StringGrid1.RowCount := EinsteinHeight;
For j := 0 To EinsteinHeight - 1 Do Begin
StringGrid1.Cells[0, j] := ResolveXY(j, ueinstein.SetName);
For i := 0 To EinsteinWidth - 1 Do Begin
If assigned(data) Then Begin
StringGrid1.Cells[i + 1, j] := ResolveXY(j, data[i, j].Value);
End
Else Begin
StringGrid1.Cells[i + 1, j] := '';
End;
End;
End;
// Anzeigen der Mengeninhalte
If MenuItem12.Checked Then Begin
StringGrid1.Cells[StringGrid1.ColCount - 1, 0] := 'Sets';
For j := 1 To EinsteinHeight - 1 Do Begin
s := '';
For i := 0 To EinsteinWidth - 1 Do Begin
If s <> '' Then s := s + ', ';
s := s + ResolveXY(j, i);
End;
StringGrid1.Cells[StringGrid1.ColCount - 1, j] := s;
End;
End;
// Automatische Breitenanpassung
For i := 0 To StringGrid1.ColCount - 1 Do Begin
k := StringGrid1.Canvas.TextWidth(StringGrid1.Cells[i, 0]);
For j := 0 To EinsteinHeight - 1 Do Begin
k := max(k, StringGrid1.Canvas.TextWidth(StringGrid1.Cells[i, j]));
End;
If MenuItem8.Checked Then Begin
StringGrid1.ColWidths[i] := k + 10 + 18;
End
Else Begin
StringGrid1.ColWidths[i] := k + 10;
End;
End;
End;
Procedure TForm1.ApplicationProperties1Idle(Sender: TObject; Var Done: Boolean);
Var
j: integer;
Begin
If DeletionItem <> -1 Then Begin
RuleList[DeletionItem].Free;
For j := DeletionItem To high(RuleList) - 1 Do Begin
RuleList[j] := RuleList[j + 1];
End;
SetLength(RuleList, high(RuleList));
Scrollbar1.position := max(0, min(high(RuleList), Scrollbar1.position));
FixRulePositions;
DeletionItem := -1;
End;
done := true;
End;
Procedure TForm1.Button2Click(Sender: TObject);
Begin
SetLength(RuleList, high(RuleList) + 2);
Case ComboBox1.ItemIndex Of
// Alle 1 Set Regeln
IndexDependsOn: Begin // Depends on
RuleList[high(RuleList)] := TOneSetRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsDependsOn;
End;
// Alle 2 Set Regeln
IndexEliminate: Begin
RuleList[high(RuleList)] := TTwoSetRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsEliminate;
End;
IndexDistanceLeftOf: Begin
RuleList[high(RuleList)] := TTwoSetAttribRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsDistanceLeftOf;
RuleList[high(RuleList)].SetAttributeCountAndLabels(['Distance']);
End;
IndexDistanceRightOf: Begin
RuleList[high(RuleList)] := TTwoSetAttribRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsDistanceRightOf;
RuleList[high(RuleList)].SetAttributeCountAndLabels(['Distance']);
End;
IndexDistanceDependsOn: Begin
RuleList[high(RuleList)] := TTwoSetAttribRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsDistanceDependsOn;
RuleList[high(RuleList)].SetAttributeCountAndLabels(['Distance']);
End;
IndexLeftOf: Begin
RuleList[high(RuleList)] := TTwoSetRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsLeftOf;
End;
IndexRightOf: Begin
RuleList[high(RuleList)] := TTwoSetRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsRightOf;
End;
IndexDistanceEliminate: Begin
RuleList[high(RuleList)] := TTwoSetAttribRuleFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsDistanceEliminate;
RuleList[high(RuleList)].SetAttributeCountAndLabels(['Distance']);
End;
IndexIntegerDepends: Begin
RuleList[high(RuleList)] := TIntDepSetFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsIntDepends;
//RuleList[high(RuleList)].SetAttributeCountAndLabels(['Distance']);
End;
IndexMultiEliminate: Begin
RuleList[high(RuleList)] := TMultiSetFrame.Create(TabSheet7);
RuleList[high(RuleList)].Rule := rsMultiEliminate;
End
Else Begin
Raise exception.create('Error, missing implementation : ' + ComboBox1.Items[ComboBox1.ItemIndex]);
End;
End;
// Callbacks aller
RuleList[high(RuleList)].Parent := TabSheet7;
RuleList[high(RuleList)].ResolveXY := @ResolveXY;
RuleList[high(RuleList)].SelfDeleteCallback := @SelfDeleteCallback;
// Neu Positionieren und Texte neu Einlesen
ScrollBar1.Max := high(RuleList);
ScrollBar1.Position := high(RuleList);
FixRulePositions;
RefreshTexts;
End;
Procedure TForm1.Button3Click(Sender: TObject);
Begin
// Es wird nur so komisch gescrollt, weil Lazarus heute den Senkrechten Scollbalken auf der Pagecontroll nicht mag, ka warum ..
Scrollbar1.position := max(0, min(Scrollbar1.position + 1, High(RuleList)));
FixRulePositions;
End;
Procedure TForm1.Button4Click(Sender: TObject);
Begin
// Es wird nur so komisch gescrollt, weil Lazarus heute den Senkrechten Scollbalken auf der Pagecontroll nicht mag, ka warum ..
Scrollbar1.position := max(Scrollbar1.position - 1, 0);
FixRulePositions;
End;
Procedure TForm1.Button5Click(Sender: TObject);
Begin
form4.show;
End;
Procedure TForm1.FormCloseQuery(Sender: TObject; Var CanClose: boolean);
Var
DataChanged: Boolean;
i: integer;
Begin
DataChanged := false;
// Wurde eine Menge geändert ?
For i := 0 To PageControl1.PageCount - 1 Do Begin
DataChanged := DataChanged Or (PageControl1.Page[i].Components[0] As TSetframe).DataChanged;
End;
// Wurde eine Regel geändert ?
For i := 0 To High(RuleList) Do Begin
DataChanged := DataChanged Or RuleList[i].DataChanged;
End;
If DataChanged Then Begin
If Application.MessageBox('Some settings have been changed, close without saving ?', 'Attention', mb_YesNo Or MB_ICONQUESTION) = ID_No Then Begin
CanClose := False;
End;
End;
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
defcaption := 'Einstein puzzle solver ver. 0.03 by Corpsman | www.Corpsman.de |';
caption := defcaption;
PageControl2.ActivePageIndex := 0;
PageControl2.Align := alClient;
Filename := '';
StringGrid1.Color := clWhite;
TabSheet6.OnHide := @OnHideSetPage;
End;
Procedure TForm1.FormShow(Sender: TObject);
Var
s: tsetframe;
Begin
If Form1ShowFirst Then Begin
Form1ShowFirst := false;
If FileExistsUTF8(ParamStrUTF8(1)) Then Begin
LoadFromFile(ParamStrUTF8(1));
End
Else Begin
(*
* Initialisieren mit dem Klassischen Einstein Rätsel
*)
NewDimensions(6, 5);
// Die Farben
s := PageControl1.Pages[0].Components[0] As TSetframe;
s.SetValues(['Places', '1', '2', '3', '4', '5']);
s := PageControl1.Pages[1].Components[0] As TSetframe;
s.SetValues(['Color', 'red', 'green', 'yellow', 'blue', 'white']);
// Die Nationalitäten
s := PageControl1.Pages[2].Components[0] As TSetframe;
s.SetValues(['Nationality', 'Briton', 'Swedish', 'Dane', 'Norwegian', 'German']);
// Die Getränke
s := PageControl1.Pages[3].Components[0] As TSetframe;
s.SetValues(['Drink', 'Tea', 'Coffee', 'Milk', 'Beer', 'Water']);
// Die Zigaretten
s := PageControl1.Pages[4].Components[0] As TSetframe;
s.SetValues(['Smoke', 'Pallmall', 'Dunhill', 'Marlboro', 'Winfield', 'Rothmanns']);
// Die Tiere
s := PageControl1.Pages[5].Components[0] As TSetframe;
s.SetValues(['Pet', 'Dog', 'Bird', 'Cat', 'Horse', 'Fish']);
PageControl1.ActivePageIndex := 0; // Reset der Mengeneingabe Auswahl
// Die Regeln
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Rot, Brite, Nichts, Nichts, Nichts])); // Der Brite lebt im roten Haus.
RuleList[high(RuleList)].SetUserHint(', The briton lifes in the red house.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Nichts, Schwede, Nichts, Nichts, Hund])); // Der Schwede haelt sich einen Hund.
RuleList[high(RuleList)].SetUserHint(', The Swedish owns the dog.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Nichts, Daene, Tee, Nichts, Nichts])); // Der Daene trinkt gern Tee.
RuleList[high(RuleList)].SetUserHint(', The Dane drinks tea.');
ComboBox1.ItemIndex := IndexDistanceLeftOf; // Left of
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Gruen, Nichts, Nichts, Nichts, Nichts])); // Das gruene Haus steht links neben dem weissen Haus.
RuleList[high(RuleList)].SetSet(1, TMS([Nichts, Weiss, Nichts, Nichts, Nichts, Nichts])); // Das gruene Haus steht links neben dem weissen Haus.
RuleList[high(RuleList)].SetAttribute(0, 1);
RuleList[high(RuleList)].SetUserHint(', The green house is immediately to the right of the white house.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Gruen, Nichts, Kaffee, Nichts, Nichts])); // Der Besitzer des gruenen Hauses trinkt Kaffee.
RuleList[high(RuleList)].SetUserHint(', Coffee is drunk in the green house.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Nichts, Nichts, Nichts, Pallmall, Vogel])); // Die Person, die Pall Mall raucht, hat einen Vogel.
RuleList[high(RuleList)].SetUserHint(', The Pallmall smoker owns the bird.');
ComboBox1.ItemIndex := IndexDependsOn;
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([2, Nichts, Nichts, Milch, Nichts, Nichts])); // Der Mann im mittleren Haus trinkt Milch.
RuleList[high(RuleList)].SetUserHint(', Milk is drunk in the middle house.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Gelb, Nichts, Nichts, Dunhill, Nichts])); // Der Bewohner des gelben Hauses raucht Dunhill.
RuleList[high(RuleList)].SetUserHint(', Dunhills are smoked in the yellow house.');
ComboBox1.ItemIndex := IndexDependsOn;
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([0, Nichts, Norweger, Nichts, Nichts, Nichts])); // Der Norweger lebt im ersten Haus.
RuleList[high(RuleList)].SetUserHint(', The Norwegian lives in the first house.');
ComboBox1.ItemIndex := IndexDistanceDependsOn; // Neighbour of
button2.Click;
RuleList[high(RuleList)].SetSet(0, tms([Nichts, Nichts, Nichts, Nichts, Marlboro, Nichts])); // Der Marlboro-Raucher wohnt neben der Person mit der Katze.
RuleList[high(RuleList)].SetSet(1, tms([Nichts, Nichts, Nichts, Nichts, Nichts, Katze])); // Der Marlboro-Raucher wohnt neben der Person mit der Katze.
RuleList[high(RuleList)].SetAttribute(0, 1);
RuleList[high(RuleList)].SetUserHint(', The man who smokes Marlboro lives in the house next to the man with the cat.');
ComboBox1.ItemIndex := IndexDistanceDependsOn; // Neighbour of
button2.Click;
RuleList[high(RuleList)].SetSet(0, tms([Nichts, Nichts, Nichts, Nichts, Nichts, Pferd])); // Der Mann mit dem Pferd lebt neben der Person, die Dunhill raucht.
RuleList[high(RuleList)].SetSet(1, tms([Nichts, Nichts, Nichts, Nichts, Dunhill, Nichts])); // Der Mann mit dem Pferd lebt neben der Person, die Dunhill raucht.
RuleList[high(RuleList)].SetAttribute(0, 1);
RuleList[high(RuleList)].SetUserHint(', Dunhills are smoked in the house next to the house where the horse is kept.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Nichts, Nichts, Bier, Winfield, Nichts])); // Der Winfield-Raucher trinkt gern Bier.
RuleList[high(RuleList)].SetUserHint(', The Winfield smoker drinks Beer.');
ComboBox1.ItemIndex := IndexDistanceDependsOn; // Neighbour of
button2.Click;
RuleList[high(RuleList)].SetSet(0, tms([Nichts, Nichts, Norweger, Nichts, Nichts, Nichts])); // Der Norweger wohnt neben dem blauen Haus.
RuleList[high(RuleList)].SetSet(1, tms([Nichts, Blau, Nichts, Nichts, Nichts, Nichts])); // Der Norweger wohnt neben dem blauen Haus.
RuleList[high(RuleList)].SetAttribute(0, 1);
RuleList[high(RuleList)].SetUserHint(', The Norwegian lives next to the blue house.');
ComboBox1.ItemIndex := IndexDependsOn; // Member
button2.Click;
RuleList[high(RuleList)].SetSet(0, TMS([Nichts, Nichts, Deutsche, Nichts, Rothmanns, Nichts])); // Der Deutsche raucht Rothmanns.
RuleList[high(RuleList)].SetUserHint(', The German smokes Rothmanns.');
ComboBox1.ItemIndex := IndexDistanceDependsOn; // Neighbour of
button2.Click;
RuleList[high(RuleList)].SetSet(0, tms([Nichts, Nichts, Nichts, Nichts, Marlboro, Nichts])); // Der Marlboro-Raucher hat einen Nachbarn, der Wasser trinkt.
RuleList[high(RuleList)].SetSet(1, tms([Nichts, Nichts, Nichts, Wasser, Nichts, Nichts])); // Der Marlboro-Raucher hat einen Nachbarn, der Wasser trinkt.
RuleList[high(RuleList)].SetAttribute(0, 1);
RuleList[high(RuleList)].SetUserHint(', The man who smokes Marlboro lifes next to the man who drinks water.');
Scrollbar1.position := 0; // Nach ganz oben Scrollen
FixRulePositions; // Anzeigen der Scrollposition
ComboBox1.ItemIndex := 0; // Reset der Regelauswahl
// Button1.Click; -- Theoretisch könnte die Lösung zum start auch gleich berechnet werden, ..
End;
End;
End;
Procedure TForm1.MenuItem10Click(Sender: TObject);
Begin
// Enable guessing
MenuItem10.Checked := Not MenuItem10.Checked;
If MenuItem10.Checked Then MenuItem13.Checked := false;
End;
Procedure TForm1.MenuItem11Click(Sender: TObject);
Begin
// Add user hints to conclusions
MenuItem11.Checked := Not MenuItem11.Checked;
End;
Procedure TForm1.MenuItem12Click(Sender: TObject);
Begin
// show set contents on each row
MenuItem12.Checked := Not MenuItem12.Checked;
End;
Procedure TForm1.MenuItem13Click(Sender: TObject);
Begin
// Enable Brute Force
MenuItem13.Checked := Not MenuItem13.Checked;
If MenuItem13.Checked Then MenuItem10.Checked := false;
End;
Procedure TForm1.MenuItem2Click(Sender: TObject);
Begin
form3.ModalResult := mrCancel;
form3.edit1.text := inttostr(EinsteinHeight);
form3.edit2.text := inttostr(EinsteinWidth);
If form3.ShowModal = mrOK Then Begin
NewDimensions(
strtointdef(form3.edit1.text, EinsteinHeight),
strtointdef(form3.edit2.text, EinsteinWidth)
);
End;
End;
Procedure TForm1.MenuItem3Click(Sender: TObject);
Begin
// Load
If Filename <> '' Then Begin
OpenDialog1.InitialDir := ExtractFilePath(Filename);
End
Else Begin
OpenDialog1.InitialDir := ExtractFilePath(ParamStrUTF8(0));
End;
If OpenDialog1.Execute Then Begin
LoadFromFile(OpenDialog1.FileName);
End;
End;
Procedure TForm1.MenuItem4Click(Sender: TObject);
Begin
// Save
If Filename <> '' Then Begin
SavetoFile(Filename);
End
Else Begin
MenuItem5Click(Nil);
End;
End;
Procedure TForm1.MenuItem5Click(Sender: TObject);
Begin
// Save as
If Filename <> '' Then Begin
SaveDialog1.InitialDir := ExtractFilePath(Filename);
End
Else Begin
SaveDialog1.InitialDir := ExtractFilePath(ParamStrUTF8(0));
End;
If SaveDialog1.Execute Then Begin
SavetoFile(SaveDialog1.Filename);
End;
End;
Procedure TForm1.MenuItem6Click(Sender: TObject);
Begin
close;
End;
Procedure TForm1.MenuItem8Click(Sender: TObject);
Begin
// Show pencils
MenuItem8.Checked := Not MenuItem8.Checked;
StringGrid1.Invalidate;
End;
Procedure TForm1.MenuItem9Click(Sender: TObject);
Begin
form2.show;
End;
Procedure TForm1.OnHideSetPage(Sender: TObject);
Begin
RefreshTexts; // Neu Einlesen der Texte beim Tabwechsel
End;
Procedure TForm1.ScrollBar1Change(Sender: TObject);
Begin
FixRulePositions;
End;
Procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
Procedure Plot(x, y: integer; Black: Boolean);
Var
c: TColor;
Begin
If Black Then
c := clblack
Else
c := $BFBFBF;
StringGrid1.Canvas.Pixels[x, y] := c;
StringGrid1.Canvas.Pixels[x - 1, y] := c;
StringGrid1.Canvas.Pixels[x + 1, y] := c;
StringGrid1.Canvas.Pixels[x, y - 1] := c;
StringGrid1.Canvas.Pixels[x, y + 1] := c;
End;
Begin
If MenuItem8.Checked Then Begin
If (acol = 0) Or (arow = 0) Then exit;
If (acol > length(data)) Or (aRow >= length(data[0])) Then exit;
Case EinsteinWidth Of // Visualisierung der Pencils Hardcodiert Anhand der bisher benötigten Nummern, da fehlen also durchaus noch welche *g*
3: Begin
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[2]);
End;
4: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[3]);
End;
5: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[3]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[4]);
End;
6: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[3]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[4]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[5]);
End;
7: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[3]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[4]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[5]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 + 0, data[aCol - 1, aRow].Pencils[6]);
End;
8: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[3]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[4]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[5]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[6]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[7]);
End;
9: Begin
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[0]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[1]);
Plot((aRect.Right) - 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[2]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[3]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 + 0, data[aCol - 1, aRow].Pencils[4]);
Plot((aRect.Right) + 0 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[5]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 6, data[aCol - 1, aRow].Pencils[6]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 - 0, data[aCol - 1, aRow].Pencils[7]);
Plot((aRect.Right) + 6 - 14, (aRect.Top + aRect.Bottom) Div 2 + 6, data[aCol - 1, aRow].Pencils[8]);
End;
End;
End;
End;
Procedure TForm1.FixRulePositions;
Var
tl, i: integer;
Begin
tl := 0;
For i := 0 To high(RuleList) Do Begin
If i >= Scrollbar1.position Then Begin
RuleList[i].Visible := true;
RuleList[i].name := 'Rule' + inttostr(i + 1);
RuleList[i].Top := 50 + tl;
RuleList[i].left := 10;
RuleList[i].SetCaption(' Rule ' + inttostr(i + 1) + ' (' + RuleSelectorToString(RuleList[i].Rule) + ') ');
tl := tl + RuleList[i].Height;
End
Else Begin
RuleList[i].Visible := false;
End;
End;
End;
Function TForm1.ResolveXY(x, y: integer): String;
Var
f: TSetframe;
Begin
If y = Nichts Then Begin
result := '-';
exit;
End;
f := PageControl1.Pages[x].Components[0] As TSetframe;
If y = ueinstein.SetName Then Begin
result := f.Edit1.Text;
exit;
End;
result := f.SetEdits[y].Text;
End;
Procedure TForm1.RefreshTexts;
Var
i: Integer;
Begin
For i := 0 To high(RuleList) Do Begin
RuleList[i].RefreshTexts;
End;
End;
Procedure TForm1.SelfDeleteCallback(Sender: TEinsteinRuleFrame);
Var
i: integer;
Begin
// Das Löschen muss so komisch gemacht werden, weil unter Windows sonst eine AV kommt
// Der Eventhandler scheint noch auf das Freigegebene Element zugreifen zu wollen, das geht natürlich nicht
// Im OnIdle wird nach DeleteItem geschaut und dann das entsprechende gelöscht
If DeletionItem <> -1 Then exit;
For i := 0 To high(RuleList) Do Begin
If Sender = RuleList[i] Then Begin
DeletionItem := i;
exit;
End;
End;
End;
Procedure TForm1.SavetoFile(FName: String);
Var
ini: Tinifile;
f: TSetframe;
i: Integer;
Begin
// Vorher Löschen, das nur im File ist, was auch Rein gehört ..
If FileExistsUTF8(FName) And (fname <> '') Then Begin
If Not DeleteFileUTF8(FName) Then Begin
ShowMessage('Error could not cleanup file : "' + Filename + '"' + LineEnding + 'Nothing stored.');
exit;
End;
End;
Filename := FName;
ini := TIniFile.Create(FName);
ini.WriteInteger('General', 'Setcount', EinsteinHeight);
ini.WriteInteger('General', 'Elementcount', EinsteinWidth);
For i := 0 To PageControl1.PageCount - 1 Do Begin
f := TSetframe(PageControl1.Pages[i].Components[0]);
f.SaveToFile(ini, i);
End;
ini.WriteInteger('Rules', 'Count', length(RuleList));
For i := 0 To high(RuleList) Do Begin
RuleList[i].SaveToFile(ini, i);
End;
ini.free;
caption := defcaption + ' : ' + ExtractFileNameOnly(FName);
End;
Procedure TForm1.LoadFromFile(Fname: String);
Var
ini: TIniFile;
i, j: Integer;
f: TSetframe;
s: String;
Begin
Filename := Fname;
ini := TIniFile.Create(Fname);
// Laden der Generellen Einstellungen
EinsteinHeight := ini.ReadInteger('General', 'Setcount', EinsteinHeight);
EinsteinWidth := ini.ReadInteger('General', 'Elementcount', EinsteinWidth);
NewDimensions(EinsteinHeight, EinsteinWidth); // New, bzw anlegen der ganzen Platzhalter..
// Laden der Mengen
For i := 0 To PageControl1.PageCount - 1 Do Begin
f := TSetframe(PageControl1.Pages[i].Components[0]);
f.LoadFromFile(ini, i);
End;
// Laden der Regeln
j := ini.ReadInteger('Rules', 'Count', 0);
For i := 0 To j - 1 Do Begin
s := ini.ReadString('Rule' + inttostr(i), 'Name', '');
Case StringToRuleSelector(s) Of
rsDependsOn: ComboBox1.ItemIndex := IndexDependsOn;
rsDistanceDependsOn: ComboBox1.ItemIndex := IndexDistanceDependsOn;
rsDistanceLeftOf: ComboBox1.ItemIndex := IndexDistanceLeftOf;
rsDistanceRightOf: ComboBox1.ItemIndex := IndexDistanceRightOf;
rsEliminate: ComboBox1.ItemIndex := IndexEliminate;
rsLeftOf: ComboBox1.ItemIndex := IndexLeftOf;
rsRightOf: ComboBox1.ItemIndex := IndexRightOf;
rsDistanceEliminate: ComboBox1.ItemIndex := IndexDistanceEliminate;
rsMultiEliminate: ComboBox1.ItemIndex := IndexMultiEliminate;
rsIntDepends: ComboBox1.ItemIndex := IndexIntegerDepends;