home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
281.POPBEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-07-08
|
2KB
|
50 lines
program BestPopStrategy;
{ This produces a little table on strategies on whether to TW or walk
from home planet to terra to pick up colonists. }
var
n : integer;
twthere,
there, back : integer;
oreneeded : integer;
TurnsPerRound,
turns : integer;
pop : integer;
holds : integer;
BestAverage : real;
BestLoad : integer;
begin
write('How far is it from planet to closest fighter cloud to terra? ');
readln( twthere );
write('How far is it from closest approach to terra? ');
readln( there );
write('How far is it terra to planet? ');
readln( back );
write('How many holds do you have available? ');
readln( holds );
BestAverage := holds/(twthere + there +1 + back);
BestLoad := 0;
writeln('Fly to terra, back to planet. Average ', BestAverage:1:2, ' pop/turn');
OreNeeded := 3*(twthere + back);
if twthere = 0 then
TurnsPerRound := there + 2
else
TurnsPerRound := there + 3;
pop := 0;
turns := 1;
n := 1;
repeat
pop := pop + holds - n*OreNeeded + 3*twthere;
turns := turns + TurnsPerRound;
if pop/turns > BestAverage then
begin
bestAverage := pop/turns;
bestLoad := n * OreNeeded;
end;
writeln('Load ', n * OreNeeded : 3, ' ore. Average ', pop/turns : 6 : 2);
n := n + 1;
until ( n * OreNeeded >= holds ) or (0.80 * bestAverage > pop/turns );
writeln;
writeln('Best result: load ', bestLoad, ' ore, for average ', BestAverage : 6 :2 );
readln;
end.