So I am trying to help a friend out with an assignment application. There are 12 hunters in this group. There are 4 blinds that they can use...2 hunters per blind per day. I have this code that does what needs to be done, but I don't like the fact that the pairings never change:
it produces this:
[tt]08/20/08 Wed
6 Blind 1
2 Blind 1
1 Blind 2
7 Blind 2
4 Blind 3
12 Blind 3
10 Blind 4
9 Blind 4
08/21/08 Thu
3 Blind 1
11 Blind 1
5 Blind 2
8 Blind 2
6 Blind 3
2 Blind 3
1 Blind 4
7 Blind 4
08/23/08 Sat
4 Blind 1
12 Blind 1
10 Blind 2
9 Blind 2
3 Blind 3
11 Blind 3
5 Blind 4
8 Blind 4[/tt]
What I would like for it to do is random select two hunters for each blind each day, but I can't quite get my head around the logic....
any suggestions appreciated!
leslie
Code:
procedure TForm_Main.Btn_StartClick(Sender: TObject);
var
J, i, h: integer;
dtStart, dtEnd: TDateTime;
slTemp: TStringList;
AvailDays: set of 1..7;
begin
AvailDays:= [];
if CheckBox1.Checked
then Include(AvailDays, 1);
if CheckBox2.Checked
then Include(AvailDays, 2);
if CheckBox3.Checked
then Include(AvailDays, 3);
if CheckBox4.Checked
then Include(AvailDays, 4);
if CheckBox5.Checked
then Include(AvailDays, 5);
if CheckBox6.Checked
then Include(AvailDays, 6);
if CheckBox7.Checked
then Include(AvailDays, 7);
slTemp:= TStringList.Create;
Memo1.Clear;
dtStart:= dtPickerStart.Date;
dtEnd:= dtPickerEnd.Date;
h := 0;
J:= Trunc(dtStart);
while J <= Trunc(dtEnd) do
begin
if DayOfTheWeek(J) in AvailDays
then
begin
slTemp:= GetHunters;
for i := 1 to 4 do
begin
if i = 1 then
begin
Memo1.Lines.Add(FormatDateTime('mm/dd/yy ddd', J));
Memo1.Lines.Add(EmptyStr);
end;
memo1.lines.add(Format(' %2s Blind ' + IntToStr(i), [slTemp[h]]));
inc(h);
if h > slTemp.Count - 1 then h := 0;
memo1.lines.add(Format(' %2s Blind ' + IntToStr(i), [slTemp[h]]));
inc(h);
Memo1.Lines.Add(EmptyStr);
if h > slTemp.Count - 1 then h := 0;
end;
end;
Inc(J);
end;
slTemp.Free;
end;
it produces this:
[tt]08/20/08 Wed
6 Blind 1
2 Blind 1
1 Blind 2
7 Blind 2
4 Blind 3
12 Blind 3
10 Blind 4
9 Blind 4
08/21/08 Thu
3 Blind 1
11 Blind 1
5 Blind 2
8 Blind 2
6 Blind 3
2 Blind 3
1 Blind 4
7 Blind 4
08/23/08 Sat
4 Blind 1
12 Blind 1
10 Blind 2
9 Blind 2
3 Blind 3
11 Blind 3
5 Blind 4
8 Blind 4[/tt]
What I would like for it to do is random select two hunters for each blind each day, but I can't quite get my head around the logic....
any suggestions appreciated!
leslie