Re: Army Composition
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Oct 11, 2001
- 380 views
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