forked from hkociemba/CubeExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunSetup.pas
111 lines (96 loc) · 3.1 KB
/
RunSetup.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
unit RunSetup;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TStartManSetupForm = class(TForm)
Button1: TButton;
GroupBox1: TGroupBox;
RBTwoPhase: TRadioButton;
RBOptimal: TRadioButton;
BCancel: TButton;
GBTriggerLength: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure BCancelClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
StartManSetupForm: TStartManSetupForm;
implementation
uses RubikMain, CubeDefs, OptSearch,TripSearch;
{$R *.dfm}
procedure TStartManSetupForm.Button1Click(Sender: TObject);
var i,k,minStartLength: Integer; j: Face;
begin
for i:= 0 to fcN-1 do
if fc[i].running and fc[i].selected then
begin
Application.MessageBox(PChar(Err[29]),'Error');
StartManSetupForm.Hide;
Exit;
end;
if RadioButton1.Checked then minStartLength:=RadioButton1.Tag+1;
if RadioButton2.Checked then minStartLength:=RadioButton2.Tag+1;
if RadioButton3.Checked then minStartLength:=RadioButton3.Tag+1;
if RadioButton4.Checked then minStartLength:=RadioButton4.Tag+1;
k:=0;
for i:= 0 to fcN-1 do
if not fc[i].running and fc[i].selected and (Pos('*',fc[i].optManeuver)=0)
and (fc[i].phase2Length>=minStartLength) then Inc(k);
if k>500 then
begin
Application.MessageBox(PChar(Err[30]),'Error');
StartManSetupForm.Hide;
Exit;
end;
for i:= 0 to fcN-1 do
begin
if (not fc[i].selected) or fc[i].running then continue; //laufende Berechnungen lassen
if (Pos('*',fc[i].optManeuver)<>0) then continue;//Maneuver already is optimal
if fc[i].phase2Length<minStartLength then continue;
if RBOptimal.Checked then fc[i].runOptimal:=true else fc[i].runOptimal:=false;
if fc[i].runOptimal then
begin
if (fc[i].optSearch=nil) then
begin
fc[i].optSearch:=OptimalSearch.Create(fc[i]);
fc[i].optStartTime:=Now;
end;
(fc[i].optSearch as OptimalSearch).NextSolution
end
else
begin
if fc[i].phase2Length<minStartLength then continue;
if (fc[i].tripSearch=nil) then
begin
for j:=U1 to B9 do fc[i].faceOrig[j]:= fc[i].PFace^[j];
fc[i].tripSearch:=TripleSearch.Create(fc[i]);
end;
if (fc[i].tripSearch as TripleSearch).length=-1 then //no better solution
begin
// Application.MessageBox(PChar(Err[5]),'Maneuver Window',MB_ICONWARNING);
continue;
end
else
begin (fc[i].tripSearch as TripleSearch).NextSolution; end;
end;
fc[i].running:=true;
for k:= 0 to MAXNUM do
if ButRun[k].Tag=i then ButRun[k].Glyph:=Form1.BMStop;
end;
StartManSetupForm.Hide;
end;
procedure TStartManSetupForm.BCancelClick(Sender: TObject);
begin
StartManSetupForm.Hide;
end;
end.