[Script1] Program Assigned_Area_Speed_Task; var i, j, RnCount : integer; Dmax, Tmax, Vmax, Pmax, PmaxDistance, PmaxTime, N1, N2, N3, F, Fr, Rn, Rd, Rv, BestSpeed, Pc, Pv, Pd : 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 // Izracun osnovnih parametrov. N1 := 0; N2 := 0; N3 := 0; for i:=0 to GetArrayLength(Pilots)-1 do begin If not Pilots[i].isHC Then begin If Pilots[i].takeoff > 0 Then N2 := N2+1; // Tekmovalci, ki so vzleteli If Pilots[i].dis >= 100000 Then N1 := N1+1; // Tekmovalcu z vec kot 100km If Pilots[i].finish > 0 Then N3 := N3+1; // Tekmovalci v cilju end; end; If N2=0 Then Exit; Fr := 1-0.125*(N3/N2); If Fr<0.9 Then Fr := 0.9; F := 1.25*N1/N2; If F > 1 Then F := 1; Dmax := 0; Tmax := 0; Vmax := 0; for i:=0 to GetArrayLength(Pilots)-1 do begin If not Pilots[i].isHC Then begin If (Pilots[i].speed > Vmax) or (Fr*Pilots[i].tspeed > Vmax) Then begin If Pilots[i].speed > Fr*Pilots[i].tspeed Then begin Vmax := Pilots[i].speed; Dmax := Pilots[i].dis; Tmax := Pilots[i].finish-Pilots[i].start; end Else begin Vmax := Fr*Pilots[i].tspeed; Dmax := Pilots[i].tdis; Tmax := Pilots[i].tfinish-Pilots[i].tstart; end; end; end; end; If Vmax=0 Then Exit; PmaxDistance := (5*Dmax/1000)-250; PmaxTime := (400*Tmax/3600.0)-200; Pmax := MinValue( PmaxDistance, PmaxTime, 1000.0 ); // Izracunaj Rn = Stevilo tekmovalcev s hitrostjo vec kot 2/3 najvecje RnCount := 0; for i:=0 to GetArrayLength(Pilots)-1 do begin If not Pilots[i].isHC Then begin If (Pilots[i].speed > (2.0/3.0*Vmax)) or (Pilots[i].tspeed > (2.0/3.0*Vmax)) Then begin RnCount := RnCount+1; end; end; end; Rn := RnCount/N2; for i:=0 to GetArrayLength(Pilots)-1 do begin If Pilots[i].speed>Fr*Pilots[i].tspeed Then BestSpeed := Pilots[i].speed Else BestSpeed := Fr*Pilots[i].tspeed; Rd := BestSpeed / (2.0/3.0*Vmax); If Rd>1 Then Rd := 1; Pd := Rd * (1-((2*Rn)/3.0)) * Pmax; Rv := BestSpeed / Vmax; 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; for i:=0 to GetArrayLength(Pilots)-1 do begin If Pilots[i].speed>Fr*Pilots[i].tspeed Then 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 Else begin Pilots[i].sstart:=Pilots[i].tstart; Pilots[i].sfinish:=Pilots[i].tfinish; Pilots[i].sdis:=(-1)*Pilots[i].tdis; Pilots[i].sspeed:=Pilots[i].tspeed; end; end; Info1 := 'Maximum Points: '+IntToStr(Round(Pmax)); Info2 := 'Day factor = '+FormatFloat('0.000',F); Info3 := 'Timeout speed reduction factor: '+FormatFloat('0.000',Fr); end.