Re: Army Composition

new topic     » goto parent     » topic index » view thread      » older message » newer message

CK,

Perhaps this is what you are looking for  -- a function which does the
calculation, to be embedded in your program:

function get_tiers(integer pop,sequence tiers)
   --tiers is a sequnce of ratios, first element is ratio of
   --lowest level of leaders to grunts, second is ratio
   --of second-lowest level of leaders to lowest level, etc.
   --returns a sequence one longer than the tiers, with number of
   --each rank from grunts on up.
   --No error checking is done.
   integer num_tiers
   num_tiers=length(tiers)
   if num_tiers=0 then return {pop} end if
   tiers[1]+=1
   for i=2 to num_tiers do
      tiers[i]=tiers[i]*tiers[i-1]+1
   end for
   tiers=floor(pop/tiers)
   for i=1 to num_tiers do
      pop-=tiers[i]
   end for
   return pop & tiers
end function

-- Mike Nelson

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu