SRL Archive - Test corner

LeastNextPlayer(Active:Boolean);


phantombmx

2006-04-25 13:28:09

yeah i have attempted to make a NextPlayer that will choose what ever player has worked the least..
the procedure works and everything.. but not the way i wanted it to, unless it takes a bit to start working.. but yeah so far it only goes like backwards NextPlayer for some reason :D

it should be used with some random timer per player.. check it out

procedure LeastNextPlayer(Active:Boolean);
var i, n : Integer;
begin
if(HowManyPlayers<4)then
RandomNextPlayer(Active)
Players[CurrentPlayer].Active:=Active
WriteLn('Next Player')
LogOut;
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + ((PlayerCurTime - PlayerStartTime) / 60);
repeat
n:=Min(Players[0].Worked, Players[1].Worked)
CurrentPlayer:=0
if(n = Players[1].Worked)then
CurrentPlayer:=1
for i:=2 to HowManyPlayers-1 do
begin
n:=Min(n, Players[i].Worked)
if(n = Players[i].Worked)then
CurrentPlayer:=i
end;
until(Players[CurrentPlayer].Active = True)
if(Players[CurrentPlayer].Active = True)then
Logs:=Logs+1
LoginPlayer;
end;

WT-Fakawi

2006-04-25 13:33:20

haha, looks complicated.

Remembers me of the frustration i had when designing the Login PlayerArray thingy…

phantombmx

2006-04-25 13:55:33

yeah it took me a good 2 hours to figure it out.. it works.. but im not sure how well.. i havent tried it with a high enough random yet… so far that ive seen it do is go player 1, 4, 3, 2, 1 then it repeats.. like backwards nextplayer… oh yeah this also makes it to where if you have less than 4 players then it will do a randomnextplayer instead.. but yeah lemme do further tests with it before i can confirm that it will choose the least used player..

Dankness

2006-04-25 16:50:44

Ahaha Nice Theory, Personally i use the Random Next player variable on all my scripts, and it seems over the course of 8 hrs it all seems to avg out. But thats with 12-20 chars running from 8-20 hrs at a time.

phantombmx

2006-04-25 16:55:07

yeah i got it when RandomNextPlayer was thought of.. this way all players work equally but random enough for jagex not to tell

BenLand100

2006-04-25 21:28:36

procedure LeastNextPlayer(Active: boolean);
var
i, LeastTime: integer;
begin
Players[CurrentPlayer].Active:= Active;
WriteLn('Next Player');
LogOut;
PlayerCurTime:= (GetSystemTime div 1000);
Players[CurrentPlayer].Worked:= Players[CurrentPlayer].Worked + ((PlayerCurTime - PlayerStartTime) / 60);
LeastTime:= Players[0].Worked;
CurrentPlayer:= 0;
for i:= 0 to HowManyPlayers - 1 do
if (Players[i].Active and (Players[i].Worked < LeastTime)) then
begin
CurrentPlayer:= i;
LeastTime:= Players[i].Worked;
end;
LoginPlayer;
end;
That might work a little better ;)

phantombmx

2006-04-25 21:33:50

yeah yeah ben.. i was on the right track tho eh? ill test yours out and see how well it works..