Imagine
2012-05-27 22:14:36
So I was bored and I decided to experiment, it's still in it's early stages at the moment, but it's a concept for simple, repeatable, actions. For now it can only decide between three different options. The number 6000, for now, is arbitrary, I just used it because it is divisible by a buncha stuff. I set the default as 3 options, you can edit it depending on how many options you have. Unfortunately, you can't have the script dynamically change it (or so I've heard).
To call this function in a loop, you'd ideally call it once with the Setup as true, then for the remaining times in the loop, or until you relocated or something, you'd call it with the Setup as false.
Integers : Array of Integer;
procedure Choice(NumberOfChoices, Tries : Integer; Setup: Boolean);
var
LengthA, LengthB, LengthC, i, a, Placeholder, Percentage : Integer;
begin
if Setup then
begin
for i := 0 to NumberOfChoices do
Integers[i] := ((6000 * (i + 1))/NumberOfChoices)
end;
for i := 0 to NumberOfChoices do
IntegersT[i] := Integers[i];
LengthA := Integers[0] - 0;
LengthB := Integers[1] - Integers[0];
LengthC := Integers[2] - Integers[1];
for a := 0 to tries do
begin
case Random(Integers[NumberOfChoices]) of
0 .. Integers[0] : begin
if DoActionOne then // Pseudocode
begin
LengthA := LengthA * 1.5; //1.5 is arbitrary
Placeholder := 6000 - (LengthA);
Percentage := Placeholder/(LengthB + LengthC);
Integers[0] := 0 + (LengthA);
Integers[1] := Integers[0] + (Percentage * LengthB);
Integers[2] := Integers[1] + (Percentage * LengthC);
Break;
end else
Integers[0] := 0;
Placeholder := LengthB + LengthC;
Percentage := 6000/Placeholder;
Integers[1] := Percentage * LengthB;
Integers[2] := Percentage * LengthC;
end;
Integers[0] .. Integers[1] : begin
if DoActionTwo then // Pseudocode
begin
LengthB := LengthB*1.5;
Placeholder := 6000 - LengthB;
Percentage := Placeholder(LengthA + LengthC);
Integers[0] := LengthA * Percentage;
Integers[1] := LengthB + Integers[0];
Integers[2] := Integers[1] * (Percentage * LengthC);
Break;
end else
Placeholder := LengthA + LengthC;
Percentage := 6000/Placeholder;
Integers[0] := LengthA * Percentage;
Integers[1] := Integers[0] + 1;
Integers[2] := Integers[1] + (Percentage * LengthC)
end;
Integers[1] .. Integers[2] : begin
if DoActionThree then // Pseudocode
begin
LengthC := LengthC*1.5;
Placeholder := 6000 - LengthC;
Percentage := Placeholder(LengthA + LengthB);
Integers[0] := LengthA * Percentage;
Integers[1] := (LengthB * Percentage) + Integers[0];
Integers[2] := Integers[1] * (LengthC);
Break;
end else
Placeholder := LengthA + LengthB;
Percentage := 6000/Placeholder;
Integers[0] := LengthA * Percentage;
Integers[1] := Integers[0] + (Percentage* LengthB);
Integers[2] := Integers[1] + 1;
end;
end;
end;
end;
To call this function in a loop, you'd ideally call it once with the Setup as true, then for the remaining times in the loop, or until you relocated or something, you'd call it with the Setup as false.