NCDS
2010-09-14 02:24:25
All the code is in Skills.Simba.
I just ran 2 loads of mining and everything seems to be working well.
Skills.Simba:
I just ran 2 loads of mining and everything seems to be working well.
Skills.Simba:
{******************************************************************************}
{ function MSI_RandomizeArray(Objs: TIntegerArray): TIntegerArray; }
{ By: NCDS & Coh3n }
{ Description: Returns the Objects array in a random order }
{******************************************************************************}
function MSI_RandomizeArray(Objs: TIntegerArray): TIntegerArray;
var
i, o: Integer;
begin
SetLength(Result, Length(Objs));
while (Length(Objs) <> 0) do
for i := 0 to High(Result) do
begin
o := Random(Length(Objs));
Writeln(IntToStr(Objs[o]));
Result[i] := Objs[o];
DeleteValueInIntArray(Objs, o);
end;
end;
{******************************************************************************}
{ function SumTIA(TIA: TIntegerArray); }
{ By: RM }
{ Description: Returns the Sum of 'TIA' }
{******************************************************************************}
function SumTIA(TIA: TIntegerArray): Integer;
var
i: Integer;
begin
for i := High(TIA) downto 0 do
Result := Result + TIA[i];
end;
{******************************************************************************}
{ function MSI_ChooseObject(Priorities: TIntegerArray): Integer; }
{ By: RM, Coh3n, NCDS }
{ Description: Chooses an Object based on 'Priorities' }
{******************************************************************************}
function MSI_ChooseObject(Priorities: TIntegerArray): Integer;
var
TIA: TIntegerArray;
i , Sum, CurrSum: Integer;
begin
SetLength(TIA, Length(Priorities));
Sum := SumTIA(Priorities);
for i := 0 to High(Priorities) do
begin
CurrSum := CurrSum + Priorities[i];
TIA[i] := CurrSum;
end;
Sum := Random(Sum) + 1;
for Result := 0 to High(TIA) do
if Sum <= TIA[Result] then
break;
end;
{******************************************************************************}
{ function MSI_RearrangeArray(Objs, Priorities: TIntegerArray): TIntegerArray; }
{ By: NCDS & Coh3n }
{ Description: Returns the Objs array in a rearranged order }
{******************************************************************************}
function MSI_RearrangeArray(Objs, Priorities: TIntegerArray): TIntegerArray;
var
i, o: Integer;
begin
SetLength(Result, Length(Objs));
if (Length(Objs) <> Length(Priorities)) or (Length(Priorities) = 0) then
begin
Result := MSI_RandomizeArray(Objs);
Exit;
end;
while (Length(Objs) > 0) do
for i := 0 to High(Result) do
begin
o := MSI_ChooseObject(Priorities);
Result[i] := Objs[o];
DeleteValueInIntArray(Objs, o);
DeleteValueInIntArray(Priorities, o);
end;
end;