[Script0] Program Assigned_Speed_Task; var i, j, RnTemp : integer; Dh, Vh, Pmax, PmaxDistance, PmaxSpeed, Pu, Pd, Pv, Rd, Rv, Rn, F, N1, N2 : double; Function MinValue( a,b,c : double ) : double; var m : double; begin m := 9999999; If a < m Then m := a; If b < m Then m := b; If c < m Then m := c; MinValue := m; end; begin // Izracunam osnovne parametre Dh := 0; Vh := 0; Pmax := 0; N1 := 0; N2 := 0; for i:=0 to GetArrayLength(Pilots)-1 do begin If not Pilots[i].isHC Then begin If Pilots[i].dis > Dh Then Dh := Pilots[i].dis; If Pilots[i].speed > Vh Then Vh := Pilots[i].speed; If Pilots[i].takeoff > 0 Then N2 := N2+1; If Pilots[i].dis >= 100000 Then N1 := N1+1; end; end; If N2=0 Then Exit; PmaxDistance := 5*Dh/1000-250; If Vh>0 Then PmaxSpeed := (400*(Dh/1000)/(Vh*3.6))-200 Else PmaxSpeed := 1000; Pmax := MinValue( PmaxDistance, PmaxSpeed, 1000.0 ); F := 1.25*N1/N2; If F > 1 Then F := 1; // izracunam Rn, stevilo tekmovalcev, katerih hitrost je > 66% zmagovalceve // in ali je kdo dosegel cilj RnTemp := 0; j := 0; for i:=0 to GetArrayLength(Pilots)-1 do begin If not Pilots[i].isHC Then begin If Pilots[i].speed > Vh*0.66 Then RnTemp := RnTemp+1; If Pilots[i].finish > 0 Then j := 1; end; end; If N2>0 Then Rn := RnTemp/N2 Else Rn := 0; If j=0 Then begin // Scoring, ce nihce ni obletel discipline for i:=0 to GetArrayLength(Pilots)-1 do begin Pilots[i].Points := Pilots[i].dis / Dh * Pmax * F; end; end Else begin //Scoring, ko je vsaj eden obletel disciplino for i:=0 to GetArrayLength(Pilots)-1 do begin If Pilots[i].finish > 0 Then Rd := 1 Else Rd := Pilots[i].dis / Dh; Pd := Rd*(1-((2.0/3.0)*Rn))*Pmax; Rv := Pilots[i].speed / Vh; Pv := 2*(Rv-(2.0/3.0))*Rn*Pmax; If Pv<0 Then Pv := 0; Pilots[i].Points := Round( F*(Pd+Pv) - Pilots[i].Penalty ); end; end; for i:=0 to GetArrayLength(Pilots)-1 do begin Pilots[i].sstart:=Pilots[i].start; Pilots[i].sfinish:=Pilots[i].finish; Pilots[i].sdis:=Pilots[i].dis; Pilots[i].sspeed:=Pilots[i].speed; end; Info1 := 'Maximum Points: '+IntToStr(Round(Pmax)); Info2 := 'Day factor = '+FormatFloat('0.000',F); end.